Skip to content

Commit 8b6c11f

Browse files
authored
Merge pull request #53 from antst/quest_db_2_api
Update to qestdb 2.0.3 API
2 parents a9c09e8 + bd7af8a commit 8b6c11f

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

custom_components/qss/const.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
CONF_AUTH_Y_KEY = "y_key"
1515

1616
RETRY_WAIT_SECONDS = 5
17-
RETRY_ATTEMPTS = 10
17+
RETRY_ATTEMPTS = 150
1818

1919
STARTUP_MESSAGE = f"""
2020
-------------------------------------------------------------------

custom_components/qss/event_handling.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ def put_event_to_queue(event: Event, entity_filter: Callable[[str], bool], queue
1010
"""Get events with new states and put them in the process queue."""
1111
entity_id = event.data.get(ATTR_ENTITY_ID)
1212
state = event.data.get("new_state")
13-
if all([entity_id, state, state.state != STATE_UNKNOWN, entity_filter(entity_id)]):
14-
queue.put(event)
13+
if state is not None:
14+
if all([entity_id, state, state.state != STATE_UNKNOWN, entity_filter(entity_id)]):
15+
queue.put(event)
1516

1617

1718
def get_event_from_queue(queue: Queue) -> Event:

custom_components/qss/io.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from queue import Queue
55

66
from homeassistant.core import Event
7-
from questdb.ingress import IngressError, Sender
7+
from questdb.ingress import IngressError, Protocol, Sender
88
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed
99

1010
from .const import RETRY_ATTEMPTS, RETRY_WAIT_SECONDS
@@ -13,7 +13,7 @@
1313

1414

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

3434

3535
def _insert_row_without_auth(host: str, port: int, event: Event) -> None:
36-
with Sender(host, port) as sender:
36+
with Sender(Protocol.Tcp, host, port) as sender:
3737
entity_id = event.data["entity_id"]
3838
state = event.data.get("new_state")
3939
attrs = dict(state.attributes)

custom_components/qss/manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"documentation": "https://github.com/CM000n/QSS",
77
"iot_class": "local_push",
88
"issue_tracker": "https://github.com/CM000n/QSS/issues",
9-
"requirements": ["questdb>=1.2,<2.0", "tenacity>=8.0"],
10-
"version": "v0.0.10"
9+
"requirements": ["questdb>=2.0.3", "tenacity>=8.0"],
10+
"version": "v0.0.11"
1111
}

pyproject.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "qss"
3-
version = "v0.0.10"
3+
version = "v0.0.11"
44
description = "QuestDB State Storage (QSS) for Home Assistant"
55
authors = ["CM000n"]
66
keywords = [
@@ -17,14 +17,14 @@ readme = "README.md"
1717

1818
[tool.poetry.dependencies]
1919
python = "^3.11"
20-
homeassistant = "^2023.12"
21-
questdb = "^1.2.0"
20+
homeassistant = "^2024.12"
21+
questdb = "^2.0.3"
2222
tenacity = "^8.0.0"
2323

2424

2525
[tool.poetry.dev-dependencies]
2626
voluptuous-stubs = "^0.1"
27-
homeassistant-stubs = "^2023.12"
27+
homeassistant-stubs = "^2024.12"
2828
pre-commit = "^2.21.0"
2929
pre-commit-hooks = "^4.5.0"
3030
codespell = "^2.0.0"

0 commit comments

Comments
 (0)