lghorizon 0.7.3__tar.gz → 0.7.3b1__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.
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/PKG-INFO +1 -1
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lghorizon/__init__.py +1 -5
- lghorizon-0.7.3b1/lghorizon/exceptions.py +11 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lghorizon/lghorizon_api.py +14 -35
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lghorizon/models.py +0 -3
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lghorizon.egg-info/PKG-INFO +1 -1
- lghorizon-0.7.3/lghorizon/exceptions.py +0 -17
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/.coverage +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/.flake8 +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/.github/workflows/build-on-pr.yml +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/.github/workflows/publish-to-pypi.yml +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/.gitignore +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/LICENSE +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/README.md +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/instructions.txt +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lghorizon/const.py +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lghorizon/helpers.py +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lghorizon/py.typed +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lghorizon.egg-info/SOURCES.txt +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lghorizon.egg-info/dependency_links.txt +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lghorizon.egg-info/not-zip-safe +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lghorizon.egg-info/requires.txt +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lghorizon.egg-info/top_level.txt +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/lib64 +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/pyvenv.cfg +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/renovate.json +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/secrets_stub.json +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/setup.cfg +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/setup.py +0 -0
- {lghorizon-0.7.3 → lghorizon-0.7.3b1}/test.py +0 -0
|
@@ -9,11 +9,7 @@ from .models import (
|
|
|
9
9
|
LGHorizonRecordingEpisode,
|
|
10
10
|
LGHorizonCustomer,
|
|
11
11
|
)
|
|
12
|
-
from .exceptions import
|
|
13
|
-
LGHorizonApiUnauthorizedError,
|
|
14
|
-
LGHorizonApiConnectionError,
|
|
15
|
-
LGHorizonApiLockedError,
|
|
16
|
-
)
|
|
12
|
+
from .exceptions import LGHorizonApiUnauthorizedError, LGHorizonApiConnectionError
|
|
17
13
|
from .const import (
|
|
18
14
|
ONLINE_RUNNING,
|
|
19
15
|
ONLINE_STANDBY,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Exceptions for the LGHorizon API."""
|
|
2
|
+
|
|
3
|
+
class LGHorizonApiError(Exception):
|
|
4
|
+
"""Generic GeocachingApi exception."""
|
|
5
|
+
|
|
6
|
+
class LGHorizonApiConnectionError(LGHorizonApiError):
|
|
7
|
+
"""Generic GeocachingApi exception."""
|
|
8
|
+
|
|
9
|
+
class LGHorizonApiUnauthorizedError(Exception):
|
|
10
|
+
"""Generic GeocachingApi exception."""
|
|
11
|
+
|
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
import json
|
|
5
5
|
import sys, traceback
|
|
6
|
-
from .exceptions import
|
|
7
|
-
LGHorizonApiUnauthorizedError,
|
|
8
|
-
LGHorizonApiConnectionError,
|
|
9
|
-
LGHorizonApiLockedError,
|
|
10
|
-
)
|
|
6
|
+
from .exceptions import LGHorizonApiUnauthorizedError, LGHorizonApiConnectionError
|
|
11
7
|
import backoff
|
|
12
8
|
from requests import Session, exceptions as request_exceptions
|
|
13
9
|
from paho.mqtt.client import WebsocketConnectionError
|
|
@@ -86,6 +82,9 @@ class LGHorizonApi:
|
|
|
86
82
|
self._identifier = identifier
|
|
87
83
|
self._profile_id = profile_id
|
|
88
84
|
|
|
85
|
+
@backoff.on_exception(
|
|
86
|
+
backoff.expo, LGHorizonApiConnectionError, max_tries=3, logger=_logger
|
|
87
|
+
)
|
|
89
88
|
def _authorize(self) -> None:
|
|
90
89
|
ctry_code = self._country_code[0:2]
|
|
91
90
|
if ctry_code == "be":
|
|
@@ -112,8 +111,6 @@ class LGHorizonApi:
|
|
|
112
111
|
error = error_json["error"]
|
|
113
112
|
if error and error["statusCode"] == 97401:
|
|
114
113
|
raise LGHorizonApiUnauthorizedError("Invalid credentials")
|
|
115
|
-
elif error and error["statusCode"] == 97117:
|
|
116
|
-
raise LGHorizonApiLockedError("Account locked")
|
|
117
114
|
elif error:
|
|
118
115
|
raise LGHorizonApiConnectionError(error["message"])
|
|
119
116
|
else:
|
|
@@ -239,14 +236,7 @@ class LGHorizonApi:
|
|
|
239
236
|
_logger.debug(f"MQTT token: {self._auth.mqttToken}")
|
|
240
237
|
|
|
241
238
|
@backoff.on_exception(
|
|
242
|
-
backoff.expo,
|
|
243
|
-
BaseException,
|
|
244
|
-
jitter=None,
|
|
245
|
-
max_tries=3,
|
|
246
|
-
logger=_logger,
|
|
247
|
-
giveup=lambda e: isinstance(
|
|
248
|
-
e, (LGHorizonApiLockedError, LGHorizonApiUnauthorizedError)
|
|
249
|
-
),
|
|
239
|
+
backoff.expo, BaseException, jitter=None, max_time=600, logger=_logger
|
|
250
240
|
)
|
|
251
241
|
def connect(self) -> None:
|
|
252
242
|
self._config = self._get_config(self._country_code)
|
|
@@ -266,7 +256,7 @@ class LGHorizonApi:
|
|
|
266
256
|
def disconnect(self):
|
|
267
257
|
"""Disconnect."""
|
|
268
258
|
_logger.debug("Disconnect from API")
|
|
269
|
-
if not self._mqttClient
|
|
259
|
+
if not self._mqttClient.is_connected:
|
|
270
260
|
return
|
|
271
261
|
self._mqttClient.disconnect()
|
|
272
262
|
|
|
@@ -277,14 +267,7 @@ class LGHorizonApi:
|
|
|
277
267
|
box.register_mqtt()
|
|
278
268
|
|
|
279
269
|
def _on_mqtt_message(self, message: str, topic: str) -> None:
|
|
280
|
-
if "
|
|
281
|
-
self._update_customer()
|
|
282
|
-
self._channels.clear()
|
|
283
|
-
self._get_channels()
|
|
284
|
-
box: LGHorizonBox
|
|
285
|
-
for box in self.settop_boxes.values():
|
|
286
|
-
box.update_channels(self._channels)
|
|
287
|
-
elif "source" in message:
|
|
270
|
+
if "source" in message:
|
|
288
271
|
deviceId = message["source"]
|
|
289
272
|
if not isinstance(deviceId, str):
|
|
290
273
|
_logger.debug("ignoring message - not a string")
|
|
@@ -296,7 +279,6 @@ class LGHorizonApi:
|
|
|
296
279
|
self.settop_boxes[deviceId].update_state(message)
|
|
297
280
|
if "status" in message:
|
|
298
281
|
self._handle_box_update(deviceId, message)
|
|
299
|
-
|
|
300
282
|
except Exception:
|
|
301
283
|
_logger.exception("Could not handle status message")
|
|
302
284
|
_logger.warning(f"Full message: {str(message)}")
|
|
@@ -396,9 +378,14 @@ class LGHorizonApi:
|
|
|
396
378
|
return json_response
|
|
397
379
|
|
|
398
380
|
def _register_customer_and_boxes(self):
|
|
399
|
-
|
|
381
|
+
_logger.info("Get personalisation info...")
|
|
382
|
+
personalisation_result = self._do_api_call(
|
|
383
|
+
f"{self._config['personalizationService']['URL']}/v1/customer/{self._auth.householdId}?with=profiles%2Cdevices"
|
|
384
|
+
)
|
|
385
|
+
_logger.debug("Personalisation result: %s ", personalisation_result)
|
|
386
|
+
self.customer = LGHorizonCustomer(personalisation_result)
|
|
400
387
|
self._get_channels()
|
|
401
|
-
if
|
|
388
|
+
if "assignedDevices" not in personalisation_result:
|
|
402
389
|
_logger.warning("No boxes found.")
|
|
403
390
|
return
|
|
404
391
|
_logger.info("Registering boxes")
|
|
@@ -419,14 +406,6 @@ class LGHorizonApi:
|
|
|
419
406
|
self.settop_boxes[box.deviceId] = box
|
|
420
407
|
_logger.info("Box %s registered...", box.deviceId)
|
|
421
408
|
|
|
422
|
-
def _update_customer(self):
|
|
423
|
-
_logger.info("Get customer data")
|
|
424
|
-
personalisation_result = self._do_api_call(
|
|
425
|
-
f"{self._config['personalizationService']['URL']}/v1/customer/{self._auth.householdId}?with=profiles%2Cdevices"
|
|
426
|
-
)
|
|
427
|
-
_logger.debug("Personalisation result: %s ", personalisation_result)
|
|
428
|
-
self.customer = LGHorizonCustomer(personalisation_result)
|
|
429
|
-
|
|
430
409
|
def _get_channels(self):
|
|
431
410
|
self._update_entitlements()
|
|
432
411
|
_logger.info("Retrieving channels...")
|
|
@@ -438,9 +438,6 @@ class LGHorizonBox:
|
|
|
438
438
|
self.manufacturer = platform_type["manufacturer"]
|
|
439
439
|
self.model = platform_type["model"]
|
|
440
440
|
|
|
441
|
-
def update_channels(self, channels: Dict[str, LGHorizonChannel]):
|
|
442
|
-
self._channels = channels
|
|
443
|
-
|
|
444
441
|
def register_mqtt(self) -> None:
|
|
445
442
|
if not self._mqtt_client.is_connected:
|
|
446
443
|
raise Exception("MQTT client not connected.")
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"""Exceptions for the LGHorizon API."""
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class LGHorizonApiError(Exception):
|
|
5
|
-
"""Generic LGHorizon exception."""
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class LGHorizonApiConnectionError(LGHorizonApiError):
|
|
9
|
-
"""Generic LGHorizon exception."""
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class LGHorizonApiUnauthorizedError(Exception):
|
|
13
|
-
"""Generic LGHorizon exception."""
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class LGHorizonApiLockedError(LGHorizonApiUnauthorizedError):
|
|
17
|
-
"""Generic LGHorizon exception."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|