PS this is used to set the backgroud colour in my picture element card (conditional on server_temp_0_warning – if OK then green, if warning then red which all works, just need to find a better way of doing this
If I understand correctly, you have 30 temperature sensors. You want a warning message when a sensor’s state value exceeds 30.
The easiest route is a single Template Sensor that shows a count of the number of sensors that exceed the threshold. Optionally, it can have an attribute that lists the names of all the sensor’s that are running hot.
So unfortunately it’s not quite as simple as that. Each temp sensors has its own threshold that is different.
What I have at the moment works but I have only done or for two sensors because of the large amount of code it will take.
The sensors are also in a group if that helps.
I also tried creating an automation to detect when the temp sensors value goes above a threshold then change the status of the warning but you can’t change the status of a sensor from within an automation so that didn’t work.
I am parsing the original values from CSV to JSON in python so I might make another JSON with warning values in it at that point of I can’t find a simpler solution.
It seems crazy!
The fact each one has a unique threshold is what forces your hand to create a separate Template Sensor for each one. In this case, having them in a group adds little flexibility.
What I can offer is a streamlined way to define the sensors. It makes it easier to create additional sensors, via copy-paste, then just tweak the index and threshold values.
However, if this was just ‘demo code’ and the sensor names have little in common and aren’t sequential, then you’re still facing the tedium of renaming each one.