Rftrx force update (#37944)

* Make sure sensor and binary_sensor force update

This make sure it's possible to react to events on all updates.

* Correct addition of binary sensors
This commit is contained in:
Joakim Plate 2020-07-18 01:23:49 +02:00 committed by GitHub
parent cecdce07cc
commit d0040e60cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -56,7 +56,7 @@ async def async_setup_entry(
_LOGGER.error("Invalid device: %s", packet_id) _LOGGER.error("Invalid device: %s", packet_id)
continue continue
if not supported(event): if not supported(event):
return continue
device_id = get_device_id(event.device, data_bits=entity.get(CONF_DATA_BITS)) device_id = get_device_id(event.device, data_bits=entity.get(CONF_DATA_BITS))
if device_id in device_ids: if device_id in device_ids:
@ -188,6 +188,11 @@ class RfxtrxBinarySensor(BinarySensorEntity, RestoreEntity):
"""No polling needed.""" """No polling needed."""
return False return False
@property
def force_update(self) -> bool:
"""We should force updates. Repeated states have meaning."""
return True
@property @property
def device_class(self): def device_class(self):
"""Return the sensor class.""" """Return the sensor class."""

View File

@ -178,6 +178,16 @@ class RfxtrxSensor(RestoreEntity):
"""Return the unit this state is expressed in.""" """Return the unit this state is expressed in."""
return self._unit_of_measurement return self._unit_of_measurement
@property
def should_poll(self):
"""No polling needed."""
return False
@property
def force_update(self) -> bool:
"""We should force updates. Repeated states have meaning."""
return True
@property @property
def device_class(self): def device_class(self):
"""Return a device class for sensor.""" """Return a device class for sensor."""