This sensor is based on Min/Max
sensor,
which is very useful to compute one value based on a number of related values.
The main problem with the Min/Max sensor was that its state is always numerical as it keeps the
last numerical (i.e not unknown
/unavailable
) state of its entities according to the docs.
Therefore its state won't be unknown
even if all of its entities' states are unknown
and one needs
to take their own measures to react to such situation as per this discussion.
This can be done using automations and additional entities, but it won't be as flexible as
a custom component.
On the other hand, there is always a risk when using custom component as if something changes in
a way Home Assistant handles them, you're in troubles.
So you've been warned.
Definition of the sensor is similar to Min/Max
sensor.
It inherits its sources' icon
and unit_of_measurement
(which defaults to ERR
if they mismatch across sources).
sensors
(list) (Required)
Configurations for individual sensors.
name
(string) (Required)
Name of sensor.
type
(string) (Optional)
The type of sensor (same as for Min/Max sensor
). Supported values are min
, last
.
Default value:
last
sources
(list) (Required)
List of sensors to combine.
selectable_sources
(boolean) (Optional)
If true
, each source will be considered only if a corresponding selector
is on
.
Default value:
false
selectors
(list) (Optional)
List of input_boolean
s.
If present, number of items should be equal to sources
' one.
Otherwise you should have configured input_booleans
so
for each source_x
there is an input_boolean.source_x_selected
.
round_digits
(number) (Optional)
Number of digits to round the value of sensor.
If omitted, state of the sensor will be a copy of the source's state (i.e no change).
Default value:
-1
friendly_name
(string) (Optional)
Human friendly name of sensor.
Copy custom_components/multisource
folder into your <HA config>/custom_components/
folder.
You may need to restart Home Assistant.
- Simple case - one physical sensor and two receivers (RFLink and OMG Pilight).
Each of them has its own sensor in Home Assistant. Wwe combine them to get the last arrived reading:
# these sensors reflect appropriate protocol's values
# and behave like 'last' filter but change to 'unknown' if all of the entity_id are unknown
- platform: multisource
sensors:
ground_floor_reception_reliable_temperature:
friendly_name: !secret ground_floor_reception_name
sources:
- sensor.pilight_ground_floor_reception_temperature
- sensor.rflink_ground_floor_reception_temperature
ground_floor_lounge_reliable_temperature:
friendly_name: !secret ground_floor_lounge_name
sources:
- sensor.pilight_ground_floor_lounge_temperature
- sensor.rflink_ground_floor_lounge_temperature
- Using these sensors as sources, we can now create a combined sensor whose state represents
the minimal value of its sources. We also useround_digits
to set resulting precision:
- platform: multisource
sensors:
composite_temperature:
friendly_name: composite temperature
type: min
round_digits: 1
- Any
multisource
sensor can be configured to enable/disable its sources (which might be
useful to exclude some of them either manually or by an automation)
- platform: multisource
sensors:
composite_temperature:
friendly_name: composite temperature
type: min
round_digits: 1
selectable_sources: true
sources:
- sensor.ground_floor_reception_reliable_temperature
- sensor.ground_floor_lounge_reliable_temperature
or
- platform: multisource
sensors:
ground_floor_reception_reliable_temperature:
friendly_name: !secret ground_floor_reception_name
selectable_sources: true
sources:
- sensor.pilight_ground_floor_reception_temperature
- sensor.rflink_ground_floor_reception_temperature
selectors:
- input_boolean.pilight_ground_floor_reception
- input_boolean.rflink_ground_floor_reception