thanks for the hint - i will look after the condition. The formular would be “sensor.dark_sky_temperature + 5 minutes” for all outside temperatures below 20…
What you’re trying to do is not possible. You cannot place a value template anywhere you want. It can only go into specific sections in automations. Those sections are:
Also, take a second and think about what you are trying to do. When it’s below 20 minutes, you want to send a message 20 + 5.
What happens when the temperature is dropping rapidly? I.E. 1 degree a minute? Does the trigger reset each time the temperature drops?
If you’re 1 minute away from trigger and the temp jumps up 5 but is still below 20. Do you add 5 or reset the timer?
If you’re 1 minute away from the trigger and the temp drops 5 degrees. Do you trigger immediately or reset?
This type of automation is very complicated and it would need something other than a normal automation. In the end, is this really what you want to do?
Are there any attributes of an entity (for example a binary sensor) that are accessible that gives a timestamp of the last time the entity changed state?
If so that could be used in the template trigger value_template.
Name of the entity. Based on friendly_name attribute with fall back to object ID. Example: Kitchen Ceiling .
state.last_updated
Time the state was written to the state machine. Note that writing the exact same state including attributes will not result in this field being updated. Example: 2017-10-28 08:13:36.715874+00:00 .
state.last_changed
Time the state changed. This is not updated when there are only updated attributes. Example: 2017-10-28 08:13:36.715874+00:00 .
state.attributes
Documented here:
EDIT:
They can’t be accessed using methods, they can only be access via the object. What do I mean by that?
These types of methods will not work because they only access the state.state property and the state.attributes property:
that should extract the number of minutes since the last change and add 5 minutes + the darksky temp to that number and then trigger.
Then you’ll have to add in a condition that only allows it to run if the state was changed to ‘on’ or it will also run when the state changes to ('off + temp + 5):
condition: state
entity_id: hmsecsco_oeq1555241
state: 'on'
That value template needs to return a true/false and it could work but a device that updates regularly will hard to work with. Also, there’s really no way to track the state before during and after, which is pretty much the problem. You’ll always be checking at the start and at the end or just at the end.
Yeah, but he’s trying to make sure it’s below 20 for x minutes. If the device updates, the value template gets re-evaluated and starts over. Plus, last_updated will be zero at that point in time (because it just updated).
You gotta be able to check last updated periodically. But if you do that and it’s always updating, then it’s essentially worthless because your last_updated vrs now will always be a static value.
Well his original goal was to make sure that the temperature was below x for x minutes, but he wants the minutes to be variable.
The combination of the 2 is a very difficult automation. Personally, I can’t think of a way to make the variable time work on the fly. Even with a more powerful automation tool, I can’t really think of a way.
I guess he could make a template sensor that monitors the temperature and use the sensor.time component
thanks very much for all input you’ve shared here, much appreciated. @finity is right, the delay for the trigger to start should be “sensor.dark_sky_temperature + 5 minutes” for all temperatures below 20°C.
To explain this: I want the rooms to be ventilated but avoid cooling down the flat too much in winter time. If it’s summer (everything above 20°C is fine), windows can stay open as long as anyone wants. But in winter time i would spend to much energy heating up the rooms to 18-20°C when the windows are open for a longer time than needed to ventilate them. The time needed to ventilate must be variable since the recommendation for ventilating rooms is that outside temperature +5mins rule… which isn’t very exact since it will fail for minus temperatures which occur sometimes in winter… but forget that, i would take care of that later when the basic automation works. Also what happens if someone closes the window again, the trigger should stop and not send any notifications…
Since i don’t expect outside temperature drops of more than 3-4°C within 30 minutes i wouldn’t say that iterating the changes of the outside temperature are nothing i have to look at. If temperature drops more than that, open windows should be my least problem
I’m going to experiment with the suggestions, many thanks so far - i will update the thread asap.
Ok, this automation should do it for you. It checks the window every minute when it’s open. When you’ve reached the temperature+5 minutes from the last time it changed, it will trigger.