I created three helpers for time of day to my peak energy hours from my electric company. I then added in a seasonal condition for my automation.
I created two input booleans that will get turned on if the conditions are met to indicate I am currently in peak hours for energy billing. I think my issue is that the If Then section of the my automation is treating these as AND statements and not OR statements. Basically if any of my two time of day sensors goes off, I want HA to check if the Season value matches “autumn”, “winter”, OR “spring” AND if one of my binary sensors is also “on”.
Here’s the YAML (note, I have the trigger set to “any state”; its shows as null in the YAML view though)
alias: Peak Winter Hours
description: ""
triggers:
- trigger: state
entity_id:
- binary_sensor.smeco_winter_peak_b_hours
from: null
- trigger: state
entity_id:
- binary_sensor.smeco_winter_peak_a_hours
to: null
conditions: []
actions:
- if:
- condition: state
entity_id: sensor.season
state: autumn
- condition: state
entity_id: sensor.season
state: winter
- condition: state
entity_id: sensor.season
state: spring
- condition: state
entity_id: binary_sensor.smeco_winter_peak_a_hours
state: "on"
- condition: state
entity_id: binary_sensor.smeco_winter_peak_b_hours
state: "on"
then:
- action: input_boolean.turn_on
target:
entity_id: input_boolean.smeco_peak_winter_active
data: {}
else:
- action: input_boolean.turn_off
target:
entity_id: input_boolean.smeco_peak_winter_active
data: {}
mode: single
@aceindy — putting to: null in the trigger means “trigger off any state change, but not attribute changes”. See here:
@avipullyoursocksup — there’s no way your YAML above will work like that. The conditions: block is AND by default, but your season sensor cannot be in three states at once. You might find this recent post of mine helpful:
For the case of a sensor with no attributes, yes. Binary sensors created with the Ping integration, for example, do have attributes that change frequently. Might be safer to add it than leave it out.