Skip to content

Commit

Permalink
Remove force from async_schedule_update_ha_state for HMIPC (home-assi…
Browse files Browse the repository at this point in the history
…stant#31796)

* remove force from async_schedule_update_ha_state if HMIPC

* Fix lint
  • Loading branch information
SukramJ authored Feb 14, 2020
1 parent ebeab7f commit 2f3ab15
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 11 additions & 2 deletions homeassistant/components/homematicip_cloud/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
STATE_ALARM_DISARMED,
STATE_ALARM_TRIGGERED,
)
from homeassistant.core import callback
from homeassistant.helpers.typing import HomeAssistantType

from . import DOMAIN as HMIPC_DOMAIN
Expand Down Expand Up @@ -95,10 +96,18 @@ async def async_added_to_hass(self) -> None:
"""Register callbacks."""
self._home.on_update(self._async_device_changed)

@callback
def _async_device_changed(self, *args, **kwargs) -> None:
"""Handle device state changes."""
_LOGGER.debug("Event %s (%s)", self.name, CONST_ALARM_CONTROL_PANEL_NAME)
self.async_schedule_update_ha_state(True)
# Don't update disabled entities
if self.enabled:
_LOGGER.debug("Event %s (%s)", self.name, CONST_ALARM_CONTROL_PANEL_NAME)
self.async_schedule_update_ha_state()
else:
_LOGGER.debug(
"Device Changed Event for %s (Alarm Control Panel) not fired. Entity is disabled.",
self.name,
)

@property
def name(self) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ async def _async_manipulate_security_zones(
internal_zone = home.search_group_by_id(internal_zone_id)
internal_zone.active = internal_active

home.from_json(json)
home._get_functionalHomes(json)
home._load_functionalChannels()
home.fire_update_event(json)
await hass.async_block_till_done()

Expand Down

0 comments on commit 2f3ab15

Please sign in to comment.