From 134445f62244c4b85395be1c381d60cbdb1fd20e Mon Sep 17 00:00:00 2001 From: David K Date: Sat, 10 Feb 2018 10:45:00 +0100 Subject: [PATCH] Fix some rfxtrx devices with multiple sensors (#12264) * Fix some rfxtrx devices with multiple sensors Some combined temperature/humidity sensors send one packet for each of their sensors. Without this fix one of the home assistant sensors would always display an unknown value. * Add comment --- homeassistant/components/sensor/rfxtrx.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/sensor/rfxtrx.py b/homeassistant/components/sensor/rfxtrx.py index 1696e8e3770..4a555905d50 100644 --- a/homeassistant/components/sensor/rfxtrx.py +++ b/homeassistant/components/sensor/rfxtrx.py @@ -71,14 +71,19 @@ def setup_platform(hass, config, add_devices, discovery_info=None): if device_id in rfxtrx.RFX_DEVICES: sensors = rfxtrx.RFX_DEVICES[device_id] - for key in sensors: - sensor = sensors[key] + for data_type in sensors: + # Some multi-sensor devices send individual messages for each + # of their sensors. Update only if event contains the + # right data_type for the sensor. + if data_type not in event.values: + continue + sensor = sensors[data_type] sensor.event = event # Fire event - if sensors[key].should_fire_event: + if sensor.should_fire_event: sensor.hass.bus.fire( "signal_received", { - ATTR_ENTITY_ID: sensors[key].entity_id, + ATTR_ENTITY_ID: sensor.entity_id, } ) return