How to ignore unavailable sensor in template sensor?

I created a template sensor “Indoor Temperature” which takes the max of all my indoor temp sensors. But often some become available and my log gets swamped with error messages like below:

How can I avoid this and just ignore any sensor which is unavailable?

Well for a start with that template you are taking the max value of strings not numbers. So 20 would be larger than 100. When converting your strings to numbers with the |float filter you can supply a default value of 0 to be used when the string can not be converted to an number, like this |float(0).

However, a far easier method is to use this helper:

It will find the max for you and ignore unknown and unavailable sensors.

In future please do not post pictures of text. Post the actual text formatted correctly for the forum with the </> button in the post toolbar.

1 Like