Fix opentherm_gw availability (#121892)

This commit is contained in:
mvn23 2024-07-15 09:20:32 +02:00 committed by GitHub
parent df00e1a65b
commit 894f3fe439
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 11 deletions

View File

@ -470,3 +470,8 @@ class OpenThermGatewayDevice:
async_dispatcher_send(self.hass, self.update_signal, status)
self.gateway.subscribe(handle_report)
@property
def connected(self):
"""Report whether or not we are connected to the gateway."""
return self.gateway.connection.connected

View File

@ -48,6 +48,7 @@ class OpenThermBinarySensor(BinarySensorEntity):
_attr_should_poll = False
_attr_entity_registry_enabled_default = False
_attr_available = False
def __init__(self, gw_dev, var, source, device_class, friendly_name_format):
"""Initialize the binary sensor."""
@ -85,14 +86,10 @@ class OpenThermBinarySensor(BinarySensorEntity):
_LOGGER.debug("Removing OpenTherm Gateway binary sensor %s", self._attr_name)
self._unsub_updates()
@property
def available(self):
"""Return availability of the sensor."""
return self._attr_is_on is not None
@callback
def receive_report(self, status):
"""Handle status updates from the component."""
self._attr_available = self._gateway.connected
state = status[self._source].get(self._var)
self._attr_is_on = None if state is None else bool(state)
self.async_write_ha_state()

View File

@ -138,7 +138,7 @@ class OpenThermClimate(ClimateEntity):
@callback
def receive_report(self, status):
"""Receive and handle a new report from the Gateway."""
self._attr_available = status != gw_vars.DEFAULT_STATUS
self._attr_available = self._gateway.connected
ch_active = status[gw_vars.BOILER].get(gw_vars.DATA_SLAVE_CH_ACTIVE)
flame_on = status[gw_vars.BOILER].get(gw_vars.DATA_SLAVE_FLAME_ON)
cooling_active = status[gw_vars.BOILER].get(gw_vars.DATA_SLAVE_COOLING_ACTIVE)

View File

@ -45,6 +45,7 @@ class OpenThermSensor(SensorEntity):
_attr_should_poll = False
_attr_entity_registry_enabled_default = False
_attr_available = False
def __init__(
self,
@ -94,14 +95,10 @@ class OpenThermSensor(SensorEntity):
_LOGGER.debug("Removing OpenTherm Gateway sensor %s", self._attr_name)
self._unsub_updates()
@property
def available(self):
"""Return availability of the sensor."""
return self._attr_native_value is not None
@callback
def receive_report(self, status):
"""Handle status updates from the component."""
self._attr_available = self._gateway.connected
value = status[self._source].get(self._var)
self._attr_native_value = value
self.async_write_ha_state()