Skip to content
Snippets Groups Projects
Commit cf3bb300 authored by SukramJ's avatar SukramJ Committed by Paulus Schoutsen
Browse files

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

* Homematic IP Cloud Fix: Don't update disabled entities

* Added enabled to entity.py

* Update test for enabled

* Update entity.py
parent e69953fe
No related branches found
No related tags found
No related merge requests found
...@@ -76,8 +76,16 @@ class HomematicipGenericDevice(Entity): ...@@ -76,8 +76,16 @@ class HomematicipGenericDevice(Entity):
def _async_device_changed(self, *args, **kwargs): def _async_device_changed(self, *args, **kwargs):
"""Handle device state changes.""" """Handle device state changes."""
_LOGGER.debug("Event %s (%s)", self.name, self._device.modelType) # Don't update disabled entities
self.async_schedule_update_ha_state() 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 @property
def name(self) -> str: def name(self) -> str:
......
...@@ -229,6 +229,11 @@ class Entity: ...@@ -229,6 +229,11 @@ class Entity:
# are used to perform a very specific function. Overwriting these may # are used to perform a very specific function. Overwriting these may
# produce undesirable effects in the entity's operation. # 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 @callback
def async_set_context(self, context): def async_set_context(self, context):
"""Set the context the entity currently operates under.""" """Set the context the entity currently operates under."""
......
...@@ -552,8 +552,10 @@ async def test_disabled_in_entity_registry(hass): ...@@ -552,8 +552,10 @@ async def test_disabled_in_entity_registry(hass):
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry2 != entry assert entry2 != entry
assert ent.registry_entry == entry2 assert ent.registry_entry == entry2
assert ent.enabled is True
entry3 = registry.async_update_entity("hello.world", disabled_by="user") entry3 = registry.async_update_entity("hello.world", disabled_by="user")
await hass.async_block_till_done() await hass.async_block_till_done()
assert entry3 != entry2 assert entry3 != entry2
assert ent.registry_entry == entry3 assert ent.registry_entry == entry3
assert ent.enabled is False
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment