The template gets the value of sensor.temperature, converts it to a floating point number, then checks if it is greater than 50. If it is, the automation is triggered.
If we replace 50 with an input_number, we can adjust the value of the input_number (either via the UI or by an automation).
Here’s a simple automation to set the input_number to the sensor’s value at 01:00.
trigger:
platform: time
at: '01:00:00'
action:
service: input_number.set_value
data:
entity_id: input_number.threshold_temperature
value: "{{ states('sensor.temperature') | int }}"
Of course, the actual automation will need to be more sophisticated because at some point you will want it to set input_number.threshold_temperature back to the preferred values (30 or 50 or whatever it is you wish to use).
That’s not a good indicator. All Template Sensors are updated at startup. If they lack entities, they will never be updated again (until the next restart). This template lacks entities, which is why I suggested to include the line containing sensor.date. It changes state at the beginning of every new day, thereby causing the Template Sensor to be updated at that same moment.
The fact it failed to do that today implies something is wrong.
Did you add and configure the Time & Date integration (sensor.date) yesterday or was it already installed?
If you added it yesterday, did you restart Home Assistant afterwards?
After you added the suggested line to the template, did you execute Reload Template Entities (or restart Home Assistant)?
If you did all those things and the Template Sensor still failed to update automatically today, something somewhere isn’t working correctly.
Yes, it working fine. I will make one more sensor to open the covers when sun is gone.
Meanwhile I am looking for a reliable way to know if the weather is sunny or not.
In my experience, you need to try several sources of weather forecasting and then choose the one that provides the most reliable forecast for your location. In my case, the national weather office proved to be the best.
Alternatively, you can use an exterior light sensor and base your actions on its measurements. You may wish to use the Filter integration to shape the data (i.e. reject temporary deviations from the trend).
Hi
before a while I tried to change the start value of 21 Dec from 127 to 126 just to be a little more accurate.
I replaced the values in the sensor template and restarted HA.
Now the state of the sensor is unknown.
Do you know why?
The only difference from the original are the following two lines:
{% set dec21 = now().replace(day=21).replace(month=12).replace(hour=0).replace(minute=0).replace(second=0).replace(microsecond=0) %}
{% set jun21 = now().replace(day=21).replace(month=6).replace(hour=0).replace(minute=0).replace(second=0).replace(microsecond=0) %}
If you compare them to the original, you’ll notice they begin by replacing the dayfirst and then the month. The original version is opposite, it replaces the month first, then the day.
The problem is today (now()) is October 31. If I change the month first, to June, it produces June 31 which is an invalid date. That’s the bug.
Yes, now it is fixed. To be honest I still trying to understand how you do the calculations and I can’t.
I will try tomorrow to reproduce these formulas in a excel but I am not sure I can make it.
Please tell me that your job is a programmer or something relative…
Hi, although it is working ok, the number format is lije 141.200000003 so I tried to add round(2) in the formulas. It can change the number format only in the below formula however the result is not corect.
I don’t mind to stay this way, but something seems strange to me thats why I am asking.
So in the below formula why there is one parenthesis in —> previous_dec21). ?
If you have no additional questions concerning this topic, please consider marking my post (above) with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. In addition, it will place a link below your first post that leads to the solution post. This helps other users find answers to similar questions.