python-hilo 2023.3.1__tar.gz → 2023.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/PKG-INFO +1 -1
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/api.py +0 -1
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/const.py +5 -6
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/device/climate.py +1 -1
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/device/light.py +1 -1
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/device/sensor.py +1 -1
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/device/switch.py +1 -1
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/devices.py +16 -3
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/websocket.py +2 -1
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyproject.toml +5 -5
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/LICENSE +0 -0
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/README.md +0 -0
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/__init__.py +0 -0
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/device/__init__.py +0 -0
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/event.py +0 -0
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/exceptions.py +0 -0
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/util/__init__.py +0 -0
- {python_hilo-2023.3.1 → python_hilo-2023.4.2}/pyhilo/util/state.py +0 -0
|
@@ -53,7 +53,6 @@ from pyhilo.device import DeviceAttribute, HiloDevice, get_device_attributes
|
|
|
53
53
|
from pyhilo.exceptions import InvalidCredentialsError, RequestError
|
|
54
54
|
from pyhilo.util import schedule_callback
|
|
55
55
|
from pyhilo.util.state import (
|
|
56
|
-
RegistrationDict,
|
|
57
56
|
TokenDict,
|
|
58
57
|
WebsocketDict,
|
|
59
58
|
WebsocketTransportsDict,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import platform
|
|
3
|
+
from typing import Final
|
|
4
|
+
|
|
3
5
|
import aiohttp
|
|
4
6
|
import homeassistant.core
|
|
5
|
-
from typing import Final
|
|
6
7
|
|
|
7
8
|
LOG: Final = logging.getLogger(__package__)
|
|
8
9
|
DEFAULT_STATE_FILE: Final = "hilo_state.yaml"
|
|
@@ -29,7 +30,7 @@ AUTH_SCOPE: Final = "openid 9870f087-25f8-43b6-9cad-d4b74ce512e1 offline_access"
|
|
|
29
30
|
SUBSCRIPTION_KEY: Final = "20eeaedcb86945afa3fe792cea89b8bf"
|
|
30
31
|
|
|
31
32
|
# API constants
|
|
32
|
-
API_HOSTNAME: Final = "
|
|
33
|
+
API_HOSTNAME: Final = "api.hiloenergie.com"
|
|
33
34
|
API_END: Final = "v1/api"
|
|
34
35
|
API_AUTOMATION_ENDPOINT: Final = f"/Automation/{API_END}"
|
|
35
36
|
API_GD_SERVICE_ENDPOINT: Final = f"/GDService/{API_END}"
|
|
@@ -48,15 +49,13 @@ AUTOMATION_HOSTNAME: Final = "automation.hiloenergie.com"
|
|
|
48
49
|
AUTOMATION_DEVICEHUB_ENDPOINT: Final = "/DeviceHub"
|
|
49
50
|
|
|
50
51
|
# Request constants
|
|
51
|
-
DEFAULT_USER_AGENT: Final = (
|
|
52
|
-
f"HomeAssistantHilo/{HILO_APP_VERSION} HomeAssistant/{homeassistant.core.__version__} aiohttp/{aiohttp.__version__} Python/{platform.python_version()}"
|
|
53
|
-
)
|
|
52
|
+
DEFAULT_USER_AGENT: Final = f"HomeAssistantHilo/{HILO_APP_VERSION} HomeAssistant/{homeassistant.core.__version__} aiohttp/{aiohttp.__version__} Python/{platform.python_version()}"
|
|
54
53
|
|
|
55
54
|
|
|
56
55
|
# NOTE(dvd): Not sure how to get new ones so I'm using the ones from my emulator
|
|
57
56
|
# We can't unfortunately randomize this device id, I believe it's generated when
|
|
58
57
|
# an android device registers to the play store, but I'm no android dev.
|
|
59
|
-
#ANDROID_DEVICE_ID: Final = 3530136576518667218
|
|
58
|
+
# ANDROID_DEVICE_ID: Final = 3530136576518667218
|
|
60
59
|
# NOTE(dvd): Based on issue #113, this can be set to 0
|
|
61
60
|
ANDROID_DEVICE_ID: Final = 3530136576518667218
|
|
62
61
|
|
|
@@ -9,7 +9,7 @@ from pyhilo.device import HiloDevice
|
|
|
9
9
|
|
|
10
10
|
class Climate(HiloDevice):
|
|
11
11
|
def __init__(self, api: API, **kwargs: dict[str, Union[str, int]]):
|
|
12
|
-
super().__init__(api, **kwargs)
|
|
12
|
+
super().__init__(api, **kwargs) # type: ignore
|
|
13
13
|
LOG.debug(f"Setting up Climate device: {self.name}")
|
|
14
14
|
|
|
15
15
|
@property
|
|
@@ -9,7 +9,7 @@ from pyhilo.device import HiloDevice
|
|
|
9
9
|
|
|
10
10
|
class Light(HiloDevice):
|
|
11
11
|
def __init__(self, api: API, **kwargs: dict[str, Union[str, int]]):
|
|
12
|
-
super().__init__(api, **kwargs)
|
|
12
|
+
super().__init__(api, **kwargs) # type: ignore
|
|
13
13
|
LOG.debug(f"Setting up Light device: {self.name}")
|
|
14
14
|
|
|
15
15
|
@property
|
|
@@ -9,7 +9,7 @@ from pyhilo.device import HiloDevice
|
|
|
9
9
|
|
|
10
10
|
class Sensor(HiloDevice):
|
|
11
11
|
def __init__(self, api: API, **kwargs: dict[str, Union[str, int]]):
|
|
12
|
-
super().__init__(api, **kwargs)
|
|
12
|
+
super().__init__(api, **kwargs) # type: ignore
|
|
13
13
|
LOG.debug(f"Setting up Sensor device: {self.name}")
|
|
14
14
|
|
|
15
15
|
@property
|
|
@@ -9,7 +9,7 @@ from pyhilo.device import HiloDevice
|
|
|
9
9
|
|
|
10
10
|
class Switch(HiloDevice):
|
|
11
11
|
def __init__(self, api: API, **kwargs: dict[str, Union[str, int]]):
|
|
12
|
-
super().__init__(api, **kwargs)
|
|
12
|
+
super().__init__(api, **kwargs) # type: ignore
|
|
13
13
|
LOG.debug(f"Setting up Switch device: {self.name}")
|
|
14
14
|
|
|
15
15
|
@property
|
|
@@ -78,11 +78,24 @@ class Devices:
|
|
|
78
78
|
return dev
|
|
79
79
|
|
|
80
80
|
async def update(self) -> None:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
fresh_devices = await self._api.get_devices(self.location_id)
|
|
82
|
+
generated_devices = []
|
|
83
|
+
for raw_device in fresh_devices:
|
|
84
|
+
LOG.debug(f"Generating device {raw_device}")
|
|
85
|
+
dev = self.generate_device(raw_device)
|
|
86
|
+
generated_devices.append(dev)
|
|
84
87
|
if dev not in self.devices:
|
|
85
88
|
self.devices.append(dev)
|
|
89
|
+
for device in self.devices:
|
|
90
|
+
if device not in generated_devices:
|
|
91
|
+
LOG.debug(f"Device unpaired {device}")
|
|
92
|
+
# Don't do anything with unpaired device for now.
|
|
93
|
+
# self.devices.remove(device)
|
|
94
|
+
|
|
95
|
+
async def update_gateway(self) -> None:
|
|
96
|
+
gateway = await self._api.get_gateway(self.location_id)
|
|
97
|
+
LOG.debug(f"Generating device (gateway) {gateway}")
|
|
98
|
+
self.generate_device(gateway)
|
|
86
99
|
|
|
87
100
|
async def async_init(self) -> None:
|
|
88
101
|
"""Initialize the Hilo "manager" class."""
|
|
@@ -181,6 +181,7 @@ class WebsocketClient:
|
|
|
181
181
|
raise InvalidMessageError("Received invalid JSON") from v_exc
|
|
182
182
|
except json.decoder.JSONDecodeError as j_exc:
|
|
183
183
|
LOG.error(f"Received invalid JSON: {msg.data}")
|
|
184
|
+
LOG.exception(j_exc)
|
|
184
185
|
data = {}
|
|
185
186
|
|
|
186
187
|
self._watchdog.trigger()
|
|
@@ -280,7 +281,7 @@ class WebsocketClient:
|
|
|
280
281
|
)
|
|
281
282
|
except (ClientError, ServerDisconnectedError, WSServerHandshakeError) as err:
|
|
282
283
|
LOG.error(f"Unable to connect to WS server {err}")
|
|
283
|
-
if hasattr(err, "status") and err.status in (401, 403, 404, 409):
|
|
284
|
+
if hasattr(err, "status") and err.status in (401, 403, 404, 409):
|
|
284
285
|
raise InvalidCredentialsError("Invalid credentials") from err
|
|
285
286
|
except Exception as err:
|
|
286
287
|
LOG.error(f"Unable to connect to WS server {err}")
|
|
@@ -40,7 +40,7 @@ exclude = ".venv/.*"
|
|
|
40
40
|
|
|
41
41
|
[tool.poetry]
|
|
42
42
|
name = "python-hilo"
|
|
43
|
-
version = "2023.
|
|
43
|
+
version = "2023.04.02"
|
|
44
44
|
description = "A Python3, async interface to the Hilo API"
|
|
45
45
|
readme = "README.md"
|
|
46
46
|
authors = ["David Vallee Delisle <me@dvd.dev>"]
|
|
@@ -75,15 +75,15 @@ voluptuous = ">=0.13.1"
|
|
|
75
75
|
websockets = ">=8.1,<11.0"
|
|
76
76
|
|
|
77
77
|
[tool.poetry.dev-dependencies]
|
|
78
|
-
Sphinx = "^
|
|
78
|
+
Sphinx = "^6.1.3"
|
|
79
79
|
aresponses = "^2.1.4"
|
|
80
80
|
asynctest = "^0.13.0"
|
|
81
|
-
pre-commit = "^2.
|
|
81
|
+
pre-commit = "^3.2.2"
|
|
82
82
|
pytest = "^7.2.0"
|
|
83
83
|
pytest-aiohttp = "^1.0.4"
|
|
84
|
-
pytest-cov = "^
|
|
84
|
+
pytest-cov = "^4.0.0"
|
|
85
85
|
sphinx-rtd-theme = "^1.0.0"
|
|
86
|
-
types-pytz = "^
|
|
86
|
+
types-pytz = "^2023.3.0"
|
|
87
87
|
|
|
88
88
|
[tool.pylint.BASIC]
|
|
89
89
|
expected-line-ending-format = "LF"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|