I’m trying to create an automation that sets the friontend theme if sensor.next_holiday is Christmas Day (Observed) or Christmas Day.
The automation sets the theme correctly when there is only one condition Christmas Day (Observed)but as soon as I add the second condition Christmas Day the automation fails, saying that none of the conditions were met. In the automation logs its almost like its not even seeing the sensor as its coming back as ‘unknown’. I don’t understand what I’m doing wrong here.
- id: 'Set Theme'
alias: 'Set Theme for Christmas'
trigger:
- platform: homeassistant
event: start
condition:
condition: or
conditions:
- condition: state
entity_id: "sensor.next_holiday"
state: "Christmas Day (Observed)"
- condition: state
entity_id: "sensor.next_holiday"
state: "Christmas Day"
action:
- service: frontend.set_theme
data:
name: uglychristmas
Info from the automation debugger:
Executed: December 6, 2021, 2:53:51 PM
Result:
result: false
conditions/0
Executed: December 6, 2021, 2:53:51 PM
Result:
result: false
conditions/0/entity_id/0
Executed: December 6, 2021, 2:53:51 PM
Result:
result: false
state: unknown
wanted_state: Christmas Day (Observed)
conditions/1
Executed: December 6, 2021, 2:53:51 PM
Result:
result: false
conditions/1/entity_id/0
Executed: December 6, 2021, 2:53:51 PM
Result:
result: false
state: unknown
wanted_state: Christmas Day
hmm…and now that state condition automation is working.
I wonder if the sensor is just not ready at the time the automation is firing, hints why it returns an unknown state.
I tried your exact automation with the original indentation (because that shouldn’t have been an issue) except that I didn’t trigger it from HA start but instead an input boolean and it worked fine.
So I think you are correct that it is because the entity hasn’t yet initialized completely when HA has started.
Ah, thank you. I had to modify the action slightly as it didn’t like the condition format but that does seem to be working. Thank you for your expertise.
- id: 'Set Theme'
alias: 'Set Theme for Christmas'
trigger:
- platform: homeassistant
event: start
action:
- delay: '00:00:05'
- condition: or
conditions:
- condition: state
entity_id: "sensor.next_holiday"
state: "Christmas Day (Observed)"
- condition: state
entity_id: "sensor.next_holiday"
state: "Christmas Day"
- service: frontend.set_theme
data:
name: uglychristmas