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
This commit is contained in:
David K 2018-02-10 10:45:00 +01:00 committed by Daniel Høyer Iversen
parent cad9e9a4cb
commit 134445f622

View File

@ -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