Folks, I got an automation to set my climate controll status like away, none and boost.
boost is preheating the office, away speaks for itself, and none is when beeing in.
there are two time triggers, and those work as intended. the flow chart indicates they are doing what I intend them to do.
then there is a template that should calculate the time needed to get the room to temp before I show up.
meaning, if its cold, start 2h early, if its freezing, start 8h early… thats primarily because of weekends as a preheat function after the romm is frozen solid for the better part of 3 days, because working on a cold floor and cold desk haunts me the rest of the day.
first i set the target to 21
then i set c at the current office temp
then i calculate how many hours early i need to start heating
then i check if that amount is bigger than the 8 hours that we have before we open office. if so start is at the day before, if not, it starts in the early hours of the workday.
So my calculation in case of beeing warm already would be:
0,33 x (21-23) ^2
factor of heating power times (target temp minus current temp) to the power of 2
Template triggers only trigger when the template itself resolves false, then starts resolving true. If you implemented the automation and the template was already resolving true, a trigger will not occur.
And any real number to the power of two, negative or positive, is positive. That may not matter to you if the thermostats are working fine — just thought it was worth noting.
What is not working how you want it to? You can paste your trigger template into the template editor (Developer Tools / Template) and see what it returns — remove the {% if %}, {% else %} and {% endif %} and you can see both outputs at once.
The trigger will only fire when the overall output from the template changes from false to true (docs). Does that tie in with your logic?
thanks for the short refresher, indeed your right, now that you said it, I clearly remember the math lesseon back in school .
and now, no I did not intend the trigger to switch from false to true, i wanted it to trigger the automation at the time when the condition in the template is matched
so how do i make my template switch from false to true at the very moment i want it to fire the boost? I dont know in advance when that will be, since the temp each day is different and therefore the preheating period.
Do i have to run a “every minute” trigger to evaluate my template 1440 times a day just to hit once a day the right moment?
i think i change it to other sources, sources that change say once a minute or so and have it make an obvious but meaning less change like switching a lamp. then when the trigger on itsself work, ill implement it into the heating.
I suggest you use your template to create a Template Binary Sensor so you can observe its history and gain a better understanding of its behavior. Its history will show when it turns on/off.
template:
- binary_sensor:
- name: Heating
state: >
{% set target = 21 %}
{% set c = states('sensor.office_temp')|float(0) %}
{% set hours = (0.33 * (target-c)**2) | round(2) %}
{% set t = today_at("8:00") + timedelta(days = iif(hours > 8, 1, 0)) - timedelta(hours=hours) %}
{{ now() >= t }}
Just to let you know that before I suggested you create a Template Binary Sensor, I experimented with your template. I tried different values of the variable c and observed the resulting behavior of the variable t.
Its behavior was somewhat unexpected (‘kind of working’ would be a fair assessment) and, rather than report my results, I thought it would be best if you observed them yourself (via the history of a Template Binary Sensor).
This temp curv is the result of the heating automation from a FritzBox… very sofisticated. Im totally impressed. In real live one does not notice the temp changes that much, and I think the heat inside the sensor is fooling the temp output from the current running throught that fritz dect Plug unit.
Since this does not do much in helping to figgur out the “sort of working”:
I will run a second binary sensor with same code and off a stable temp number, that should trigger it precicely once by switching from fals to true then…
I probably also need to set a timeframe for that template like only after 10 pm and before 8 am for realworld application.
I’ll be honest and admit that I’m not fully vested in this topic; my interest was limited to providing a means of checking if the algorithm you created meets your intended goal. I think it’s clear from the Template Binary Sensor’s history graph that the algorithm doesn’t meet your goal. You’ll need to revise the algorithm (and I have no suggestions on that matter).