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
|
||||
# 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)
|
||||
locks = await self._api.async_get_operable_locks(token)
|
||||
doorbells = await self._api.async_get_doorbells(token)
|
||||
locks: list[Lock] = await self._api.async_get_operable_locks(token)
|
||||
doorbells: list[Doorbell] = await self._api.async_get_doorbells(token)
|
||||
if not doorbells:
|
||||
doorbells = []
|
||||
if not locks:
|
||||
|
@ -170,19 +170,6 @@ class AugustData(AugustSubscriberMixin):
|
|||
# detail as we cannot determine if they are usable.
|
||||
# This also allows us to avoid checking for
|
||||
# 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_doorbells()
|
||||
|
||||
|
@ -337,28 +324,26 @@ class AugustData(AugustSubscriberMixin):
|
|||
[str, str], Coroutine[Any, Any, DoorbellDetail | LockDetail]
|
||||
],
|
||||
) -> None:
|
||||
_LOGGER.debug(
|
||||
"Started retrieving detail for %s (%s)",
|
||||
device.device_name,
|
||||
device.device_id,
|
||||
)
|
||||
device_id = device.device_id
|
||||
device_name = device.device_name
|
||||
_LOGGER.debug("Started retrieving detail for %s (%s)", device_name, device_id)
|
||||
|
||||
try:
|
||||
self._device_detail_by_id[device.device_id] = await api_call(
|
||||
self._august_gateway.access_token, device.device_id
|
||||
)
|
||||
detail = await api_call(self._august_gateway.access_token, device_id)
|
||||
except ClientError as ex:
|
||||
_LOGGER.error(
|
||||
"Request error trying to retrieve %s details for %s. %s",
|
||||
device.device_id,
|
||||
device.device_name,
|
||||
device_id,
|
||||
device_name,
|
||||
ex,
|
||||
)
|
||||
_LOGGER.debug(
|
||||
"Completed retrieving detail for %s (%s)",
|
||||
device.device_name,
|
||||
device.device_id,
|
||||
)
|
||||
_LOGGER.debug("Completed retrieving detail for %s (%s)", device_name, device_id)
|
||||
# If the key changes after startup we need to trigger a
|
||||
# discovery to keep it up to date
|
||||
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:
|
||||
"""Get a device by id."""
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"Type": 2,
|
||||
"Created": "2017-12-10T03:12:09.210Z",
|
||||
"Updated": "2017-12-10T03:12:09.210Z",
|
||||
"LockID": "A6697750D607098BAE8D6BAA11EF8063",
|
||||
"LockID": "A6697750D607098BAE8D6BAA11EF8064",
|
||||
"HouseID": "000000000000",
|
||||
"HouseName": "My House",
|
||||
"Calibrated": false,
|
||||
|
@ -30,9 +30,9 @@
|
|||
"operative": true
|
||||
},
|
||||
"keypad": {
|
||||
"_id": "5bc65c24e6ef2a263e1450a8",
|
||||
"serialNumber": "K1GXB0054Z",
|
||||
"lockID": "92412D1B44004595B5DEB134E151A8D3",
|
||||
"_id": "5bc65c24e6ef2a263e1450a9",
|
||||
"serialNumber": "K1GXB0054L",
|
||||
"lockID": "92412D1B44004595B5DEB134E151A8D4",
|
||||
"currentFirmwareVersion": "2.27.0",
|
||||
"battery": {},
|
||||
"batteryLevel": "Medium",
|
||||
|
|
Loading…
Add table
Reference in a new issue