Skip to content

Commit

Permalink
feat: avoid parsing last_update_id (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Jun 10, 2024
1 parent f6ca464 commit ac86b13
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/uiprotect/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from pathlib import Path
from typing import Any, Literal, cast
from urllib.parse import urljoin
from uuid import UUID

import aiofiles
import aiohttp
Expand Down Expand Up @@ -647,7 +646,7 @@ def check_ws(self) -> bool:
def _process_ws_message(self, msg: aiohttp.WSMessage) -> None:
raise NotImplementedError

def _get_last_update_id(self) -> UUID | None:
def _get_last_update_id(self) -> str | None:
raise NotImplementedError


Expand Down Expand Up @@ -833,7 +832,7 @@ def emit_message(self, msg: WSSubscriptionMessage) -> None:
except Exception:
_LOGGER.exception("Exception while running subscription handler")

def _get_last_update_id(self) -> UUID | None:
def _get_last_update_id(self) -> str | None:
if self._bootstrap is None:
return None
return self._bootstrap.last_update_id
Expand Down
5 changes: 2 additions & 3 deletions src/uiprotect/data/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from dataclasses import dataclass
from datetime import datetime
from typing import Any, cast
from uuid import UUID

from aiohttp.client_exceptions import ServerDisconnectedError

Expand Down Expand Up @@ -179,7 +178,7 @@ class Bootstrap(ProtectBaseObject):
sensors: dict[str, Sensor]
doorlocks: dict[str, Doorlock]
chimes: dict[str, Chime]
last_update_id: UUID
last_update_id: str

# TODO:
# schedules
Expand Down Expand Up @@ -546,7 +545,7 @@ def process_ws_packet(

action, data = self._get_frame_data(packet)
if action["newUpdateId"] is not None:
self.last_update_id = UUID(action["newUpdateId"])
self.last_update_id = action["newUpdateId"]

if action["modelKey"] not in ModelType.values():
_LOGGER.debug("Unknown model type: %s", action["modelKey"])
Expand Down
3 changes: 1 addition & 2 deletions src/uiprotect/data/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import zlib
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any
from uuid import UUID

import orjson

Expand Down Expand Up @@ -40,7 +39,7 @@ class WSAction(str, enum.Enum):
@dataclass
class WSSubscriptionMessage:
action: WSAction
new_update_id: UUID
new_update_id: str
changed_data: dict[str, Any]
new_obj: ProtectModelWithId | None = None
old_obj: ProtectModelWithId | None = None
Expand Down

0 comments on commit ac86b13

Please sign in to comment.