Hi there, I am trying to make my first template.
I have a robot mower, integrated into home assistant.
one of the entities tells how many hours the robot blades have been working, and I am interested in being notified when the blades work for a X time, lets say 24 hours / 1440min.
The entity is as follows
they have been on for 19905 min.
Well, let`s go, first I will try explain whats my idea
1- i have the Current On Time wich is 19905, so i think I have to “say” to the template, lets call it "declare" (is that correct?) that COT = 19905 (don
t know if you have to specify the number or you can otherwise equal COT to the sensor itself
COT = sensor.dolly_blades_total_on_time
I will declare a second COT, wich will be updating every time the specified time has been completed
COT2 = 19905
2- I want to be notified when the blades had been working for 24 hours from now , 1440 minutes
so when COT = 19905+1440, then notify me and add a to do list entry
3- now COT2 must be 19905+1440, how do I do that?
4- return to step 2
Now, I am going to the template section on developer tools, and using the default provided template, start, let`s call it “coding”
{## Imitate available variables: ##}
{% set my_test_json = {
"temperature": "25",
"unit": "°C"
} %}
{% set COT =
{{ states("sensor.dolly_blades_current_on_time", with_unit=True) }}
%}
The temperature is {{ my_test_json.temperature }} {{ my_test_json.unit }}.
{% if is_state("sun.sun", "above_horizon") -%}
The sun rose {{ relative_time(states.sun.sun.last_changed) }} ago.
{%- else -%}
The sun will rise at {{ as_timestamp(state_attr("sun.sun", "next_rising")) | timestamp_local }}.
{%- endif %}
For loop example getting entity values in the weather domain:
{% for state in states.weather -%}
{%- if loop.first %}The {% elif loop.last %} and the {% else %}, the {% endif -%}
{{ state.name | lower }} is {{state.state_with_unit}}
{%- endfor %}.
this results in the following error
TemplateSyntaxError: expected token ‘:’, got ‘}’
note for the admins
by the way, don`t know if this is the correct place for this kind of question.