diff --git a/custom_components/hubitat/device.py b/custom_components/hubitat/device.py index 381d7d1..54b5a3c 100644 --- a/custom_components/hubitat/device.py +++ b/custom_components/hubitat/device.py @@ -194,7 +194,7 @@ async def async_update_options(hass: HomeAssistant, entry: ConfigEntry) -> None: hub.set_temperature_unit(temp_unit) for entity in hub.entities: if entity.device_class == DEVICE_CLASS_TEMPERATURE: - entity.async_schedule_update_ha_state() + entity.update_state() hass.states.async_set( hub.entity_id, "connected", {CONF_TEMPERATURE_UNIT: hub.temperature_unit} @@ -317,6 +317,11 @@ class HubitatEntity(HubitatBase, Entity): # Hubitat will push device updates should_poll = False + @property + def is_disabled(self) -> bool: + """Indicate whether this device is currently disabled.""" + return self.registry_entry and self.registry_entry.disabled_by + async def async_update(self) -> None: """Fetch new data for this device.""" await self._hub.refresh_device(self.device_id) @@ -329,9 +334,14 @@ async def send_command(self, command: str, *args: Union[int, str]) -> None: def handle_event(self, event: Event) -> None: """Handle a device event.""" - self.async_schedule_update_ha_state() + self.update_state() super().handle_event(event) + def update_state(self) -> None: + """Request that Home Assistant update this device's state.""" + if not self.is_disabled: + self.async_schedule_update_ha_state() + class HubitatEventEmitter(HubitatBase): """An event emitter related to a Hubitat device."""