mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Fix opentherm_gw availability (#121892)
This commit is contained in:
parent
df00e1a65b
commit
894f3fe439
@ -470,3 +470,8 @@ class OpenThermGatewayDevice:
|
|||||||
async_dispatcher_send(self.hass, self.update_signal, status)
|
async_dispatcher_send(self.hass, self.update_signal, status)
|
||||||
|
|
||||||
self.gateway.subscribe(handle_report)
|
self.gateway.subscribe(handle_report)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def connected(self):
|
||||||
|
"""Report whether or not we are connected to the gateway."""
|
||||||
|
return self.gateway.connection.connected
|
||||||
|
@ -48,6 +48,7 @@ class OpenThermBinarySensor(BinarySensorEntity):
|
|||||||
|
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
_attr_entity_registry_enabled_default = False
|
_attr_entity_registry_enabled_default = False
|
||||||
|
_attr_available = False
|
||||||
|
|
||||||
def __init__(self, gw_dev, var, source, device_class, friendly_name_format):
|
def __init__(self, gw_dev, var, source, device_class, friendly_name_format):
|
||||||
"""Initialize the binary sensor."""
|
"""Initialize the binary sensor."""
|
||||||
@ -85,14 +86,10 @@ class OpenThermBinarySensor(BinarySensorEntity):
|
|||||||
_LOGGER.debug("Removing OpenTherm Gateway binary sensor %s", self._attr_name)
|
_LOGGER.debug("Removing OpenTherm Gateway binary sensor %s", self._attr_name)
|
||||||
self._unsub_updates()
|
self._unsub_updates()
|
||||||
|
|
||||||
@property
|
|
||||||
def available(self):
|
|
||||||
"""Return availability of the sensor."""
|
|
||||||
return self._attr_is_on is not None
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def receive_report(self, status):
|
def receive_report(self, status):
|
||||||
"""Handle status updates from the component."""
|
"""Handle status updates from the component."""
|
||||||
|
self._attr_available = self._gateway.connected
|
||||||
state = status[self._source].get(self._var)
|
state = status[self._source].get(self._var)
|
||||||
self._attr_is_on = None if state is None else bool(state)
|
self._attr_is_on = None if state is None else bool(state)
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
@ -138,7 +138,7 @@ class OpenThermClimate(ClimateEntity):
|
|||||||
@callback
|
@callback
|
||||||
def receive_report(self, status):
|
def receive_report(self, status):
|
||||||
"""Receive and handle a new report from the Gateway."""
|
"""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)
|
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)
|
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)
|
cooling_active = status[gw_vars.BOILER].get(gw_vars.DATA_SLAVE_COOLING_ACTIVE)
|
||||||
|
@ -45,6 +45,7 @@ class OpenThermSensor(SensorEntity):
|
|||||||
|
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
_attr_entity_registry_enabled_default = False
|
_attr_entity_registry_enabled_default = False
|
||||||
|
_attr_available = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -94,14 +95,10 @@ class OpenThermSensor(SensorEntity):
|
|||||||
_LOGGER.debug("Removing OpenTherm Gateway sensor %s", self._attr_name)
|
_LOGGER.debug("Removing OpenTherm Gateway sensor %s", self._attr_name)
|
||||||
self._unsub_updates()
|
self._unsub_updates()
|
||||||
|
|
||||||
@property
|
|
||||||
def available(self):
|
|
||||||
"""Return availability of the sensor."""
|
|
||||||
return self._attr_native_value is not None
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def receive_report(self, status):
|
def receive_report(self, status):
|
||||||
"""Handle status updates from the component."""
|
"""Handle status updates from the component."""
|
||||||
|
self._attr_available = self._gateway.connected
|
||||||
value = status[self._source].get(self._var)
|
value = status[self._source].get(self._var)
|
||||||
self._attr_native_value = value
|
self._attr_native_value = value
|
||||||
self.async_write_ha_state()
|
self.async_write_ha_state()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user