Problem with OR condition

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

I think there is an indentation problem.
Try this:

- 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

Well I thought that was the issue but it’s not working.

I also tried using the state condition but in the automation debug it’s still coming back as unknown.

- id: 'Set Theme'         
  alias: 'Set Theme for Christmas'
  trigger: 
    - platform: homeassistant
      event: start   
  condition:
    condition: state
    entity_id: sensor.next_holiday
    state: 
      - Christmas Day (Observed)
      - Christmas Day      
  action:
    - service: frontend.set_theme  
      data:
        name: uglychristmas

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.

Is an input_boolean the best way to go about fixing this or is there a simple way to have the automation wait for the sensor to initialize?

I think it depends on how long it takes for your sensor to initialize.

if it’s short then you can trigger at startup and put a delay in the actions then move the conditions to the action section:

- id: 'Set Theme'         
  alias: 'Set Theme for Christmas'
  trigger: 
    - platform: homeassistant
      event: start   
  action:
    - delay: '00:05:00'
    - 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"
    - service: frontend.set_theme  
      data:
        name: uglychristmas

that will trigger at start up, wait 5 minutes then check the sensor state and then if satisfied run the service.

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

Hmm…I’m surprised it complained. maybe only because it didn’t have a mix of ‘and’ and ‘or’.

But I’m glad it worked! :slightly_smiling_face: