Hi there, It took me 4 days to make this work, and I think it does, but there are some questions I still have about how does this work
I have a robot lawn mower, Dolly.
one of her entities is blades_total_on_time
, which i want to take advance of in order to remind me they need cleaning/mainteinance.
As you can see, sensor.dolly_blades_total_on_time
is giving time in minutes, but it acummulates minutes since first start.
Well, I first tried a template, but someone in this forum gave the idea of an automation and I have cerated one, which I think would do the job, I am still waiting for Dolly to do her job
the automation looks like this
alias: NotificaciĆ³n de uso de cuchillas
description: ""
trigger:
- platform: template
value_template: >
{% set COT = states('sensor.dolly_blades_total_on_time') | float %} {% set
COT2 = states('input_number.cot2') | float %} {% set result = COT - COT2
%} {{ result >= 1440 and result < 1441 }}
condition: []
action:
- data:
message: Han pasado 24 horas de uso de las cuchillas. DeberĆas limpiarlas.
action: notify.mobile_app_mi14
- data:
entity_id: input_number.cot2
value: "{{ states('sensor.dolly_blades_total_on_time') | float }}"
action: input_number.set_value
- data:
title: "Tarea: Limpieza de cuchillas"
message: Se han registrado 24 horas de uso de las cuchillas. Recuerda limpiarlas.
action: persistent_notification.create
mode: single
{% set COT = states('sensor.dolly_blades_total_on_time') | float %}
This sets a variable named COT which will contain the total on time for the blades
{% set
COT2 = states('input_number.cot2') | float %}
Well, for this one, have to say that in the firs place I set COT2 = to a number, the same number sensor.dolly_blades_total_on_time
was showing at that moment, but HA automatically changed this to the actual code and created a input number entity , the point was to make COT and COT2 equal so that when COT kept increasing, and the COT-COT2 op reached a fixed number (1440, that is 24 hours)({{ result >= 1440 and result < 1441 }}
) The automation will send a notification.
Besides the notification, when the 1440 difference occur COT2 is equaled to COT again.
and here comes my questions.
1- how often is the system making the math?
2- I donĀ“t know, because I am not a coderā¦ The automation is read by the system as we read it?, I mean, the system starts in the upper side and left to right, and so on?
because if it does, then there is something I canĀ“t understand and it is that
1 creates COT
2 creates COT2
3 creates result
4 when 1440<=result<1441
5 then notifies and makes COT2 = COT
and then?, goes back to step 1?
if it does?
what happens with {% set COT2 = states('input_number.cot2') | float %}
step?