Fix ZHA cover initial state (#71083)

This commit is contained in:
David F. Mulcahey 2022-04-29 18:35:53 -04:00 committed by GitHub
parent 7f094a928b
commit f184f9e142
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 18 deletions

View File

@ -84,7 +84,7 @@ class IasAce(ZigbeeChannel):
@callback
def cluster_command(self, tsn, command_id, args) -> None:
"""Handle commands received to this cluster."""
self.warning(
self.debug(
"received command %s", self._cluster.server_commands[command_id].name
)
self.command_map[command_id](*args)
@ -120,7 +120,7 @@ class IasAce(ZigbeeChannel):
code != self.panel_code
and self.armed_state != AceCluster.PanelStatus.Panel_Disarmed
):
self.warning("Invalid code supplied to IAS ACE")
self.debug("Invalid code supplied to IAS ACE")
self.invalid_tries += 1
zigbee_reply = self.arm_response(
AceCluster.ArmNotification.Invalid_Arm_Disarm_Code
@ -131,12 +131,12 @@ class IasAce(ZigbeeChannel):
self.armed_state == AceCluster.PanelStatus.Panel_Disarmed
and self.alarm_status == AceCluster.AlarmStatus.No_Alarm
):
self.warning("IAS ACE already disarmed")
self.debug("IAS ACE already disarmed")
zigbee_reply = self.arm_response(
AceCluster.ArmNotification.Already_Disarmed
)
else:
self.warning("Disarming all IAS ACE zones")
self.debug("Disarming all IAS ACE zones")
zigbee_reply = self.arm_response(
AceCluster.ArmNotification.All_Zones_Disarmed
)
@ -177,12 +177,12 @@ class IasAce(ZigbeeChannel):
) -> None:
"""Arm the panel with the specified statuses."""
if self.code_required_arm_actions and code != self.panel_code:
self.warning("Invalid code supplied to IAS ACE")
self.debug("Invalid code supplied to IAS ACE")
zigbee_reply = self.arm_response(
AceCluster.ArmNotification.Invalid_Arm_Disarm_Code
)
else:
self.warning("Arming all IAS ACE zones")
self.debug("Arming all IAS ACE zones")
self.armed_state = panel_status
zigbee_reply = self.arm_response(armed_type)
return zigbee_reply

View File

@ -240,14 +240,14 @@ class ZHAGateway:
async def async_initialize_devices_and_entities(self) -> None:
"""Initialize devices and load entities."""
_LOGGER.warning("Loading all devices")
_LOGGER.debug("Loading all devices")
await asyncio.gather(
*(dev.async_initialize(from_cache=True) for dev in self.devices.values())
)
async def fetch_updated_state() -> None:
"""Fetch updated state for mains powered devices."""
_LOGGER.warning("Fetching current state for mains powered devices")
_LOGGER.debug("Fetching current state for mains powered devices")
await asyncio.gather(
*(
dev.async_initialize(from_cache=False)

View File

@ -206,10 +206,8 @@ class ZhaEntity(BaseZhaEntity, RestoreEntity):
signal_override=True,
)
if not self.zha_device.is_mains_powered:
# mains powered devices will get real time state
if last_state := await self.async_get_last_state():
self.async_restore_last_state(last_state)
if last_state := await self.async_get_last_state():
self.async_restore_last_state(last_state)
self.async_accept_signal(
None,

View File

@ -86,12 +86,6 @@ class ZHAEnumSelectEntity(ZhaEntity, SelectEntity):
self._channel.data_cache[self._attr_name] = self._enum[option.replace(" ", "_")]
self.async_write_ha_state()
async def async_added_to_hass(self) -> None:
"""Run when about to be added to hass."""
await super().async_added_to_hass()
if last_state := await self.async_get_last_state():
self.async_restore_last_state(last_state)
@callback
def async_restore_last_state(self, last_state) -> None:
"""Restore previous state."""