Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to qestdb 2.0.3 API #53

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion custom_components/qss/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
CONF_AUTH_Y_KEY = "y_key"

RETRY_WAIT_SECONDS = 5
RETRY_ATTEMPTS = 10
RETRY_ATTEMPTS = 10000
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if I like this approach, I'll have to think about it again.
But I think this change should be done independently with the changes necessary for the questdb client update.


STARTUP_MESSAGE = f"""
-------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion custom_components/qss/event_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def put_event_to_queue(event: Event, entity_filter: Callable[[str], bool], queue
"""Get events with new states and put them in the process queue."""
entity_id = event.data.get(ATTR_ENTITY_ID)
state = event.data.get("new_state")
if all([entity_id, state, state.state != STATE_UNKNOWN, entity_filter(entity_id)]):
if state is not None:
if all([entity_id, state, state.state != STATE_UNKNOWN, entity_filter(entity_id)]):
queue.put(event)


Expand Down
16 changes: 13 additions & 3 deletions custom_components/qss/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from queue import Queue

from homeassistant.core import Event
from questdb.ingress import IngressError, Sender
from questdb.ingress import IngressError, Sender, Protocol
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed

from .const import RETRY_ATTEMPTS, RETRY_WAIT_SECONDS
Expand All @@ -13,7 +13,14 @@


def _insert_row_with_auth(host: str, port: int, auth: tuple, event: Event) -> None:
with Sender(host, port, auth=auth, tls=True) as sender:
with Sender(
Protocol.Tcps,
host,
port,
username=auth[0],
token=auth[1],
token_x=auth[2],
token_y=auth[3]) as sender:
entity_id = event.data["entity_id"]
state = event.data.get("new_state")
attrs = dict(state.attributes)
Expand All @@ -33,7 +40,10 @@ def _insert_row_with_auth(host: str, port: int, auth: tuple, event: Event) -> No


def _insert_row_without_auth(host: str, port: int, event: Event) -> None:
with Sender(host, port) as sender:
with Sender(
Protocol.Tcp,
host,
port) as sender:
entity_id = event.data["entity_id"]
state = event.data.get("new_state")
attrs = dict(state.attributes)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/qss/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"documentation": "https://github.com/CM000n/QSS",
"iot_class": "local_push",
"issue_tracker": "https://github.com/CM000n/QSS/issues",
"requirements": ["questdb>=1.2,<2.0", "tenacity>=8.0"],
"requirements": ["questdb==2.0.3", "tenacity>=8.0"],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we at least support all patch and minor version jumps instead of pinning a specific version?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CM000n no, why? when you pin the dep … you do a release on which you know that it works. someone at questdb releases a breaking version, which results in issues opened here.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they take semantic versioning seriously, minor patch releases should never break the API. With a pin, I see a greater risk that users will then remain on a lower version than currently available and not notice and use security-relevant patches.
Unfortunately, I don't have the time or inclination to publish a Qss release for every questdb patch release.

"version": "v0.0.10"
}
Loading