Add availability to opentherm_gw entities (#32408)

* Add availability to opentherm_gw entities

* Address PR comment
This commit is contained in:
mvn23 2020-04-02 11:28:39 +02:00 committed by GitHub
parent be3cf52613
commit 58ae117bb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 1 deletions

View file

@ -60,6 +60,11 @@ class OpenThermBinarySensor(BinarySensorDevice):
)
self._unsub_updates()
@property
def available(self):
"""Return availability of the sensor."""
return self._state is not None
@property
def entity_registry_enabled_default(self):
"""Disable binary_sensors by default."""
@ -68,7 +73,8 @@ class OpenThermBinarySensor(BinarySensorDevice):
@callback
def receive_report(self, status):
"""Handle status updates from the component."""
self._state = bool(status.get(self._var))
state = status.get(self._var)
self._state = None if state is None else bool(state)
self.async_write_ha_state()
@property

View file

@ -63,6 +63,7 @@ class OpenThermClimate(ClimateDevice):
self.friendly_name = gw_dev.name
self.floor_temp = options.get(CONF_FLOOR_TEMP, DEFAULT_FLOOR_TEMP)
self.temp_precision = options.get(CONF_PRECISION, DEFAULT_PRECISION)
self._available = False
self._current_operation = None
self._current_temperature = None
self._hvac_mode = HVAC_MODE_HEAT
@ -101,6 +102,7 @@ class OpenThermClimate(ClimateDevice):
@callback
def receive_report(self, status):
"""Receive and handle a new report from the Gateway."""
self._available = bool(status)
ch_active = status.get(gw_vars.DATA_SLAVE_CH_ACTIVE)
flame_on = status.get(gw_vars.DATA_SLAVE_FLAME_ON)
cooling_active = status.get(gw_vars.DATA_SLAVE_COOLING_ACTIVE)
@ -146,6 +148,11 @@ class OpenThermClimate(ClimateDevice):
)
self.async_write_ha_state()
@property
def available(self):
"""Return availability of the sensor."""
return self._available
@property
def name(self):
"""Return the friendly name."""

View file

@ -61,6 +61,11 @@ class OpenThermSensor(Entity):
_LOGGER.debug("Removing OpenTherm Gateway sensor %s", self._friendly_name)
self._unsub_updates()
@property
def available(self):
"""Return availability of the sensor."""
return self._value is not None
@property
def entity_registry_enabled_default(self):
"""Disable sensors by default."""