mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Set lock state to unkown on BMW API error (#118559)
* Revert to previous lock state on BMW API error * Set lock state to unkown on error and force refresh from API --------- Co-authored-by: Richard <rikroe@users.noreply.github.com>
This commit is contained in:
parent
c23ec96174
commit
7c5a6602b3
@ -65,11 +65,13 @@ class BMWLock(BMWBaseEntity, LockEntity):
|
|||||||
try:
|
try:
|
||||||
await self.vehicle.remote_services.trigger_remote_door_lock()
|
await self.vehicle.remote_services.trigger_remote_door_lock()
|
||||||
except MyBMWAPIError as ex:
|
except MyBMWAPIError as ex:
|
||||||
self._attr_is_locked = False
|
# Set the state to unknown if the command fails
|
||||||
|
self._attr_is_locked = None
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
raise HomeAssistantError(ex) from ex
|
raise HomeAssistantError(ex) from ex
|
||||||
|
finally:
|
||||||
self.coordinator.async_update_listeners()
|
# Always update the listeners to get the latest state
|
||||||
|
self.coordinator.async_update_listeners()
|
||||||
|
|
||||||
async def async_unlock(self, **kwargs: Any) -> None:
|
async def async_unlock(self, **kwargs: Any) -> None:
|
||||||
"""Unlock the car."""
|
"""Unlock the car."""
|
||||||
@ -83,11 +85,13 @@ class BMWLock(BMWBaseEntity, LockEntity):
|
|||||||
try:
|
try:
|
||||||
await self.vehicle.remote_services.trigger_remote_door_unlock()
|
await self.vehicle.remote_services.trigger_remote_door_unlock()
|
||||||
except MyBMWAPIError as ex:
|
except MyBMWAPIError as ex:
|
||||||
self._attr_is_locked = True
|
# Set the state to unknown if the command fails
|
||||||
|
self._attr_is_locked = None
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
raise HomeAssistantError(ex) from ex
|
raise HomeAssistantError(ex) from ex
|
||||||
|
finally:
|
||||||
self.coordinator.async_update_listeners()
|
# Always update the listeners to get the latest state
|
||||||
|
self.coordinator.async_update_listeners()
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _handle_coordinator_update(self) -> None:
|
def _handle_coordinator_update(self) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user