skydoy
(Skydoy)
March 9, 2024, 12:24pm
1
Hello can anyone help me:
I want to create a sensor group that:
State = ON when 2 sensors on the group are on
State = OFF when all sensors on the group are off
The group Contains 11 Sensor
Now works:
State = ON when 1 sensors on the group are on
State = OFF when all sensors on the group are off
Thanks
Hellis81
(Hellis81)
March 9, 2024, 12:47pm
2
There is an option for that
Hellis81
(Hellis81)
March 9, 2024, 6:52pm
4
all: true
I assume you must create the sensor in yaml
i think he’s not asking for all. but for “any 2 of the 11”
i think if you create a binary sensor template with this template, it will do what you want
{{ expand (state_attr('sensor.group_name', 'entity_id')) | selectattr('state', 'eq', 'on') | list | count >= 2}}
so you have your existing sensor group.
then you have this new one that uses the first and counts how many are on.
if you don’t want to have 2 sensors, you could manually enumerate all of them instead of doing the expand that i did above.
3 Likes
I know this reply is a year late for the OP; but in case anyone else reads it - an option to investigate is set up a Bayesian group.
You could set a threshold and then set the probability if true for each sensor as 51% of the threshold value so that it evaluates as true if any 2 of the 11 sensors are on