Skip to content

Commit 03ee68d

Browse files
authored
Merge pull request #370 from Olen/fix/disable-update-while-disabled
fix: prevent update triggers on disabled sensor entities
2 parents 92fe85c + 5be95f1 commit 03ee68d

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

custom_components/plant/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,15 +964,36 @@ def update_entity_disabled_state(self, meter_sensor) -> None:
964964
"""Disable or enable entities based on whether an external sensor is configured."""
965965
ent_reg = er.async_get(self.hass)
966966
has_sensor = meter_sensor.external_sensor is not None
967+
_LOGGER.debug(
968+
"update_entity_disabled_state: meter=%s, has_sensor=%s, external=%s",
969+
meter_sensor.entity_id,
970+
has_sensor,
971+
meter_sensor.external_sensor,
972+
)
967973
for entity in self._get_related_entities_for_sensor(meter_sensor):
968974
if entity is None:
969975
continue
970976
entry = ent_reg.async_get(entity.entity_id)
971977
if entry is None:
978+
_LOGGER.warning(
979+
"Entity %s not found in registry, skipping disable/enable",
980+
entity.entity_id,
981+
)
972982
continue
973983
if has_sensor:
974984
if entry.disabled_by == er.RegistryEntryDisabler.INTEGRATION:
985+
_LOGGER.debug(
986+
"Enabling %s (was disabled by integration)",
987+
entry.entity_id,
988+
)
975989
ent_reg.async_update_entity(entry.entity_id, disabled_by=None)
990+
elif entry.disabled_by is not None:
991+
_LOGGER.warning(
992+
"Entity %s is disabled by %s (not by integration), "
993+
"cannot auto-enable — please enable manually via the UI",
994+
entry.entity_id,
995+
entry.disabled_by,
996+
)
976997
else:
977998
if entry.disabled_by is None:
978999
ent_reg.async_update_entity(

custom_components/plant/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
"requirements": [
1818
"async-timeout>=4.0.2"
1919
],
20-
"version": "2026.2.1-beta9"
20+
"version": "2026.2.1-beta10"
2121
}

custom_components/plant/sensor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ async def async_update(self) -> None:
392392
@callback
393393
def _schedule_immediate_update(self) -> None:
394394
"""Schedule an immediate state update."""
395+
if not self.enabled:
396+
return
395397
self.async_schedule_update_ha_state(True)
396398

397399
@callback

0 commit comments

Comments
 (0)