Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for 0.98: Don't update disabled entities (Homematic IP Cloud) #26236

Merged
merged 4 commits into from Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions homeassistant/components/homematicip_cloud/device.py
Expand Up @@ -76,8 +76,16 @@ async def async_added_to_hass(self):

def _async_device_changed(self, *args, **kwargs):
"""Handle device state changes."""
_LOGGER.debug("Event %s (%s)", self.name, self._device.modelType)
self.async_schedule_update_ha_state()
# Don't update disabled entities
if self.enabled:
_LOGGER.debug("Event %s (%s)", self.name, self._device.modelType)
self.async_schedule_update_ha_state()
else:
_LOGGER.debug(
"Device Changed Event for %s (%s) not fired. Entity is disabled.",
self.name,
self._device.modelType,
)

@property
def name(self) -> str:
Expand Down
5 changes: 5 additions & 0 deletions homeassistant/helpers/entity.py
Expand Up @@ -229,6 +229,11 @@ def entity_registry_enabled_default(self):
# are used to perform a very specific function. Overwriting these may
# produce undesirable effects in the entity's operation.

@property
def enabled(self):
"""Return if the entity is enabled in the entity registry."""
return self.registry_entry is None or not self.registry_entry.disabled

@callback
def async_set_context(self, context):
"""Set the context the entity currently operates under."""
Expand Down
2 changes: 2 additions & 0 deletions tests/helpers/test_entity.py
Expand Up @@ -552,8 +552,10 @@ async def test_disabled_in_entity_registry(hass):
await hass.async_block_till_done()
assert entry2 != entry
assert ent.registry_entry == entry2
assert ent.enabled is True

entry3 = registry.async_update_entity("hello.world", disabled_by="user")
await hass.async_block_till_done()
assert entry3 != entry2
assert ent.registry_entry == entry3
assert ent.enabled is False