Starline: Fix "Error updating SLNet token" message in Log (#121122)
Fixes https://github.com/home-assistant/core/issues/116715
This commit is contained in:
parent
001bb3a04e
commit
3ca66be268
1 changed files with 11 additions and 4 deletions
|
@ -9,7 +9,7 @@ from typing import Any
|
|||
from starline import StarlineApi, StarlineDevice
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
@ -65,9 +65,9 @@ class StarlineAccount:
|
|||
)
|
||||
self._api.set_slnet_token(slnet_token)
|
||||
self._api.set_user_id(user_id)
|
||||
self._hass.config_entries.async_update_entry(
|
||||
self._config_entry,
|
||||
data={
|
||||
self._hass.add_job(
|
||||
self._save_slnet_token,
|
||||
{
|
||||
**self._config_entry.data,
|
||||
DATA_SLNET_TOKEN: slnet_token,
|
||||
DATA_EXPIRES: slnet_token_expires,
|
||||
|
@ -77,6 +77,13 @@ class StarlineAccount:
|
|||
except Exception as err: # noqa: BLE001
|
||||
_LOGGER.error("Error updating SLNet token: %s", err)
|
||||
|
||||
@callback
|
||||
def _save_slnet_token(self, data) -> None:
|
||||
self._hass.config_entries.async_update_entry(
|
||||
self._config_entry,
|
||||
data=data,
|
||||
)
|
||||
|
||||
def _update_data(self):
|
||||
"""Update StarLine data."""
|
||||
self._check_slnet_token(self._update_interval)
|
||||
|
|
Loading…
Add table
Reference in a new issue