Keep august offline key up to date when it changes (#116857)
We only did discovery for the key at setup time. If it changed, a reloaded of the integration was needed to update the key. We now update it every time we update the lock detail.
This commit is contained in:
parent
91fa8b50cc
commit
2964471e19
2 changed files with 19 additions and 34 deletions
|
@ -151,8 +151,8 @@ class AugustData(AugustSubscriberMixin):
|
||||||
token = self._august_gateway.access_token
|
token = self._august_gateway.access_token
|
||||||
# This used to be a gather but it was less reliable with august's recent api changes.
|
# This used to be a gather but it was less reliable with august's recent api changes.
|
||||||
user_data = await self._api.async_get_user(token)
|
user_data = await self._api.async_get_user(token)
|
||||||
locks = await self._api.async_get_operable_locks(token)
|
locks: list[Lock] = await self._api.async_get_operable_locks(token)
|
||||||
doorbells = await self._api.async_get_doorbells(token)
|
doorbells: list[Doorbell] = await self._api.async_get_doorbells(token)
|
||||||
if not doorbells:
|
if not doorbells:
|
||||||
doorbells = []
|
doorbells = []
|
||||||
if not locks:
|
if not locks:
|
||||||
|
@ -170,19 +170,6 @@ class AugustData(AugustSubscriberMixin):
|
||||||
# detail as we cannot determine if they are usable.
|
# detail as we cannot determine if they are usable.
|
||||||
# This also allows us to avoid checking for
|
# This also allows us to avoid checking for
|
||||||
# detail being None all over the place
|
# detail being None all over the place
|
||||||
|
|
||||||
# Currently we know how to feed data to yalexe_ble
|
|
||||||
# but we do not know how to send it to homekit_controller
|
|
||||||
# yet
|
|
||||||
_async_trigger_ble_lock_discovery(
|
|
||||||
self._hass,
|
|
||||||
[
|
|
||||||
lock_detail
|
|
||||||
for lock_detail in self._device_detail_by_id.values()
|
|
||||||
if isinstance(lock_detail, LockDetail) and lock_detail.offline_key
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
self._remove_inoperative_locks()
|
self._remove_inoperative_locks()
|
||||||
self._remove_inoperative_doorbells()
|
self._remove_inoperative_doorbells()
|
||||||
|
|
||||||
|
@ -337,28 +324,26 @@ class AugustData(AugustSubscriberMixin):
|
||||||
[str, str], Coroutine[Any, Any, DoorbellDetail | LockDetail]
|
[str, str], Coroutine[Any, Any, DoorbellDetail | LockDetail]
|
||||||
],
|
],
|
||||||
) -> None:
|
) -> None:
|
||||||
_LOGGER.debug(
|
device_id = device.device_id
|
||||||
"Started retrieving detail for %s (%s)",
|
device_name = device.device_name
|
||||||
device.device_name,
|
_LOGGER.debug("Started retrieving detail for %s (%s)", device_name, device_id)
|
||||||
device.device_id,
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._device_detail_by_id[device.device_id] = await api_call(
|
detail = await api_call(self._august_gateway.access_token, device_id)
|
||||||
self._august_gateway.access_token, device.device_id
|
|
||||||
)
|
|
||||||
except ClientError as ex:
|
except ClientError as ex:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Request error trying to retrieve %s details for %s. %s",
|
"Request error trying to retrieve %s details for %s. %s",
|
||||||
device.device_id,
|
device_id,
|
||||||
device.device_name,
|
device_name,
|
||||||
ex,
|
ex,
|
||||||
)
|
)
|
||||||
_LOGGER.debug(
|
_LOGGER.debug("Completed retrieving detail for %s (%s)", device_name, device_id)
|
||||||
"Completed retrieving detail for %s (%s)",
|
# If the key changes after startup we need to trigger a
|
||||||
device.device_name,
|
# discovery to keep it up to date
|
||||||
device.device_id,
|
if isinstance(detail, LockDetail) and detail.offline_key:
|
||||||
)
|
_async_trigger_ble_lock_discovery(self._hass, [detail])
|
||||||
|
|
||||||
|
self._device_detail_by_id[device_id] = detail
|
||||||
|
|
||||||
def get_device(self, device_id: str) -> Doorbell | Lock | None:
|
def get_device(self, device_id: str) -> Doorbell | Lock | None:
|
||||||
"""Get a device by id."""
|
"""Get a device by id."""
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"Type": 2,
|
"Type": 2,
|
||||||
"Created": "2017-12-10T03:12:09.210Z",
|
"Created": "2017-12-10T03:12:09.210Z",
|
||||||
"Updated": "2017-12-10T03:12:09.210Z",
|
"Updated": "2017-12-10T03:12:09.210Z",
|
||||||
"LockID": "A6697750D607098BAE8D6BAA11EF8063",
|
"LockID": "A6697750D607098BAE8D6BAA11EF8064",
|
||||||
"HouseID": "000000000000",
|
"HouseID": "000000000000",
|
||||||
"HouseName": "My House",
|
"HouseName": "My House",
|
||||||
"Calibrated": false,
|
"Calibrated": false,
|
||||||
|
@ -30,9 +30,9 @@
|
||||||
"operative": true
|
"operative": true
|
||||||
},
|
},
|
||||||
"keypad": {
|
"keypad": {
|
||||||
"_id": "5bc65c24e6ef2a263e1450a8",
|
"_id": "5bc65c24e6ef2a263e1450a9",
|
||||||
"serialNumber": "K1GXB0054Z",
|
"serialNumber": "K1GXB0054L",
|
||||||
"lockID": "92412D1B44004595B5DEB134E151A8D3",
|
"lockID": "92412D1B44004595B5DEB134E151A8D4",
|
||||||
"currentFirmwareVersion": "2.27.0",
|
"currentFirmwareVersion": "2.27.0",
|
||||||
"battery": {},
|
"battery": {},
|
||||||
"batteryLevel": "Medium",
|
"batteryLevel": "Medium",
|
||||||
|
|
Loading…
Add table
Reference in a new issue