Maybe by using “Groups” , i.e a group for your binary-Door sensors ( so you don’t “call” every single binary sensors in your system, as you do ! )
Your template should then call the group
Wouldn’t that also “call” every binary sensor | then check if it has the state “on” | then check whether it has “device_class” “door” ?
When one instead can call the group for the for the state “on”
You could go for Troon’s code , i just feel it’s creating unnecessary usage.(specially if you have tons of binary-sensors)
There is another code example to extracts from group below, i think it has to follow the guideline/format for the “old*” group-format , also look at petro’s post 2 step above, howto add “entity_id field”, so the group is updated when entities changes
Beside there are many other benefits with i.e various sensors/devices in a groups
haha, i didn’t even noticed, and didn’t try it, … but it can come in handy in many “situations” (so i copied it) (EDIT: And i didn’t knew one could use tilde like that, it makes me “confused” )
PS: should it be “else if” when one has 3 or more “states” ?
@boheme61 I added the sensors in a group and noticed much faster response, will this also have a positive impact on battery life?
I’ve noticed some of my temperature sensors have drained their batteries to 50% in just a couple of weeks. Trying to improve signal strength with routed products and extenders, so it seems a bit better, for now at least
No. The sensors communicate with HA in exactly the same way. The group just makes it easier / faster for HA to filter and count them — it’s hard-coding the result of your two selectattr filters.