Hello Guys, I’m pretty new in HA and templating. I have a sensor created by HASC integration, which gives me multiple attributes with time “time_on_1” “time_off_1”, “time_on_2” “time_off_2”, “time_on_3” “time_off_3” - its Peak and off-peak times for electricity
I want to use this times to send me notification X minutes before each “on” time. I was able to read this time with template, but just one by one, and I don’t know how to use it in automations.
I´m trying to sent notification, with end of the off peak time period. I dont want to do multiple automations, I want after every automation run to inrease counter (1-3) to use it as variable in CAS_VYP (time_off) attribute, as there are 3 time period during a day.
service: notify.janyshomebot
data:
message: >-
Nízký tarif začíná za 10 minut. Končí ve {{state_attr('binary_sensor.nizky_tarif', 'data')[0].CAS_VYP_3}}
FWIW, the triple Template Triggers can be reduced to one:
trigger:
- platform: template
value_template: >
{% set t = (now().timestamp() - 600)|timestamp_custom('%-H:%M) %}
{% set nt = state_attr('binary_sensor.nizky_tarif', 'data')[0] %}
{{ t in [nt.CAS_VYP_1, nt.CAS_VYP_2, nt.CAS_VYP_3] }}
I’m having difficulty understanding the OP’s additional requirement.
data is a list containing two items (or at least there are only two in the example). The trigger is using the zeroth item. Each item contains a dictionary. The dictionary contains several keys, beginning with the letters CAS, containing time values.
Depending on whether the trigger matched the time in CAS_VYP_1, or CAS_VYP_2, or CAS_VYP_3, the goal is to use CAS_ZAP_n+1 in the notification?
There are 3 time period during a day with off-peak electricity prices. Each period start at CAS_ZAP_1-3 and ends at CAS_VYP_1-3. The periods are not subsequent. (CAS_ZAP means in czech TIME_ON, CAS_VYP means TIME_OFF)
I’m trying to achieve one automation which send me notification 10 minutes before off-peak period start and in the text is end of this period.
I can make it easily with 3 automations but I just want to know if is it possible to do it in just one
Then we are using the wrong attributes for the trigger. VYP is off time not on time. At the moment you will be notified ten minutes before off peak finishes, not before it starts, as per your original request.