Hi! First of all this my first attempt to do something advanced on HASS! I’m totally newby, so please forgive my ignorance.
I’m trying to configure multiple tariffs in energy metering using “Utility Meter”.
First I created some helpers to enter the data.
Then I created a template to find if this time, peak or off-peak charges are used:
{{ state_attr('input_datetime.winter_off_peak_period_start', 'month') <= now().month <= state_attr('input_datetime.winter_off_peak_period_end', 'month') }}
It seems to working fine.
Then I created an automation to set the tariff:
alias: HEDNO Winter tariff
description: Winter Tariff Selection
trigger:
- platform: time
at: input_datetime.winter_off_peak_noon_start
variables:
tariff: offpeak
enabled: is_state('binary_sensor.hedno_winter_season', 'on')
- platform: time
at: input_datetime.winter_off_peak_noon_end
variables:
tariff: peak
enabled: is_state('binary_sensor.hedno_winter_season', 'on')
- platform: time
at: input_datetime.winter_off_peak_morning_start
variables:
tariff: offpeak
enabled: is_state('binary_sensor.hedno_winter_season', 'on')
- platform: time
at: input_datetime.winter_off_peak_morning_end
variables:
tariff: peak
enabled: is_state('binary_sensor.hedno_winter_season', 'on')
- platform: time
at: input_datetime.summer_off_peak_start
variables:
tariff: offpeak
enabled: is_state('binary_sensor.hedno_winter_season', 'off')
- platform: time
at: input_datetime.summer_off_peak_end
variables:
tariff: peak
enabled: is_state('binary_sensor.hedno_winter_season', 'off')
action:
- service: notify.notify
metadata: {}
data:
message: Tariff changed to {{ tariff }}
mode: single
The problem is that all of the above are like they have the value True on "enabled: " which is wrong.
is_state(‘binary_sensor.hedno_winter_season’, ‘on’) is returning False in Developer Tools / Template.
I have also used:
enabled: "{{ is_state('binary_sensor.hedno_winter_season', 'off') }}"
with the same result.
What am I missing? And how can we debug automation triggers in general?
Thank you
3 posts - 3 participants