I have a number of statistics sensors called 1_week_lounge_temperature, 1_week_kitchen_temperature, etc.
I want to create two template sensors, one to contain the highest value from the max_value attribute of each of the statistics sensors and the other to contain the lowest value from the min_value attribute.
Problem is, I have pretty much no idea where to start
I could probably create a load of template sensors to where the state is the equal to the attributes and then use Min/Max sensors but there must be a more elegant way.
I ended up doing it like this - can’t help wondering if there’s not a better way. I don’t like having to manually list all of the sensors to check when there is a distinct pattern to the naming.
If you don’t list all the sensor entities somewhere (within the template like you’ve done and/or by listing them in the entity_id option) then Home Assistant won’t know which entities to monitor (for state-changes) and the Template Sensor won’t get updated.
So although it may be tempting to iterate through the entities using a loop that constructs each entity’s name (because they follow a naming pattern), that technique will prevent Home Assistant from discovering the entities it must monitor.