From d0040e60cc80fedcf9b7d7f97d034881935bf420 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Sat, 18 Jul 2020 01:23:49 +0200 Subject: [PATCH] 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 --- homeassistant/components/rfxtrx/binary_sensor.py | 7 ++++++- homeassistant/components/rfxtrx/sensor.py | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/rfxtrx/binary_sensor.py b/homeassistant/components/rfxtrx/binary_sensor.py index 33ef6893c52..5f6e32437c4 100644 --- a/homeassistant/components/rfxtrx/binary_sensor.py +++ b/homeassistant/components/rfxtrx/binary_sensor.py @@ -56,7 +56,7 @@ async def async_setup_entry( _LOGGER.error("Invalid device: %s", packet_id) continue if not supported(event): - return + continue device_id = get_device_id(event.device, data_bits=entity.get(CONF_DATA_BITS)) if device_id in device_ids: @@ -188,6 +188,11 @@ class RfxtrxBinarySensor(BinarySensorEntity, RestoreEntity): """No polling needed.""" return False + @property + def force_update(self) -> bool: + """We should force updates. Repeated states have meaning.""" + return True + @property def device_class(self): """Return the sensor class.""" diff --git a/homeassistant/components/rfxtrx/sensor.py b/homeassistant/components/rfxtrx/sensor.py index e105c463b3b..de341307551 100644 --- a/homeassistant/components/rfxtrx/sensor.py +++ b/homeassistant/components/rfxtrx/sensor.py @@ -178,6 +178,16 @@ class RfxtrxSensor(RestoreEntity): """Return the unit this state is expressed in.""" 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 def device_class(self): """Return a device class for sensor."""