mirror of
https://github.com/home-assistant/core.git
synced 2025-06-24 06:57:08 +00:00
Fix linky sensor login error (#17110)
* Fix linky sensor login error * Make platform fail-safe Adding following enhancements: * Make sure the platform loads correctly by making the first API request in setup_platform. * Close the session after each API call. * Use timeout parameter everywhere. * Fix Hound CI error: line too long. * Update pylinky library * Remove LinkyClient from update()
This commit is contained in:
parent
26b7c2de7e
commit
e980d1b9fe
@ -16,7 +16,7 @@ from homeassistant.helpers.entity import Entity
|
|||||||
from homeassistant.util import Throttle
|
from homeassistant.util import Throttle
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['pylinky==0.1.6']
|
REQUIREMENTS = ['pylinky==0.1.8']
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
SCAN_INTERVAL = timedelta(minutes=10)
|
SCAN_INTERVAL = timedelta(minutes=10)
|
||||||
@ -37,11 +37,11 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
|
|
||||||
from pylinky.client import LinkyClient, PyLinkyError
|
from pylinky.client import LinkyClient, PyLinkyError
|
||||||
client = LinkyClient(username, password, None, timeout)
|
client = LinkyClient(username, password, None, timeout)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
client.fetch_data()
|
client.fetch_data()
|
||||||
except PyLinkyError as exp:
|
except PyLinkyError as exp:
|
||||||
_LOGGER.error(exp)
|
_LOGGER.error(exp)
|
||||||
|
client.close_session()
|
||||||
return
|
return
|
||||||
|
|
||||||
devices = [LinkySensor('Linky', client)]
|
devices = [LinkySensor('Linky', client)]
|
||||||
@ -80,6 +80,7 @@ class LinkySensor(Entity):
|
|||||||
self._client.fetch_data()
|
self._client.fetch_data()
|
||||||
except PyLinkyError as exp:
|
except PyLinkyError as exp:
|
||||||
_LOGGER.error(exp)
|
_LOGGER.error(exp)
|
||||||
|
self._client.close_session()
|
||||||
return
|
return
|
||||||
|
|
||||||
_LOGGER.debug(json.dumps(self._client.get_data(), indent=2))
|
_LOGGER.debug(json.dumps(self._client.get_data(), indent=2))
|
||||||
|
@ -963,7 +963,7 @@ pylgnetcast-homeassistant==0.2.0.dev0
|
|||||||
pylgtv==0.1.9
|
pylgtv==0.1.9
|
||||||
|
|
||||||
# homeassistant.components.sensor.linky
|
# homeassistant.components.sensor.linky
|
||||||
pylinky==0.1.6
|
pylinky==0.1.8
|
||||||
|
|
||||||
# homeassistant.components.litejet
|
# homeassistant.components.litejet
|
||||||
pylitejet==0.1
|
pylitejet==0.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user