Alternative to HA's Min/Max sensor
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.
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
```
round_digits
to set resulting precision:```
friendly_name: composite temperature
type: min
round_digits: 1
multisource
sensor can be configured to enable/disable its sources (which might be
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
yaml```
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