When any sensor in the template sensors reports a value ‘unavaliable’, the template sensor seems to become unavailable. Some sensors in my home report unavailable when device is off or when no power is consumed.
Q1: How can I make the template sensor to sum power consumption while ignoring sensor states that are unavailable?
Q2: Is there a way to do this sum in the template sensor without having to list each individual sensor one by one? Could I for example use wildcards (*power) ? Any other smart(er) suggestions?
Hi, I’m having a similar problem and this sums all the power sensors correctly but if you have solar panels it will also sum the power you are generating which defeats the purpose.
the select('is_number') filter all non numerical states, including unavailable and unknown, and even allows the map('float') to be used as is, no need for a default
on my energy sensors that sometimes erratically reset to 0 mysteriously… I filter those out with an additional reject:
I’ve tried to incorporate that option when it was added to our toolkit (as I always try to do with new features, now where could I use that…).
First I had some availability templates use it, and then figured it could be used in the state. I like the verbiage, which makes more sense to me than the |map('float',0) at first glance.
the reject was from another template where I only wanted to list the correct entities, and not the temporary flawed ones. in that template it actually was very much required.
consider it a c&p pollution in these examples…