Or condition example from documentation is failing

Hello, all!

I am trying to create an automation that triggers when I arrive home at night. I directly copy/pasted the example given from HA’s documentation

EDITED… I copy/pasted it onto the site poorly

    condition:
    	condition: or 
    	conditions:
    	  - condition: sun
    		after: sunset
    		after_offset: 0:30
    	  - condition: sun
    		before: sunrise

Yet when I try to go to the visual automation page, it says that it can not parse the condition:

Unsupported condition: or
{
  "condition": "or",
  "conditions": [
	{
	  "after": "sunset",
	  "condition": "sun"
	},
	{
	  "before": "sunrise",
	  "condition": "sun"
	}
  ]
}

Does anyone have any clues as to why this occurs? I tried using the visual automation page to accomplish this task:
2018-05-03%2010_17_07-Home%20Assistant

but I have yet to see the automation get triggered. It produces the following code:

  condition:
  - after: sunset
    after_offset: 0:30
    before: sunrise
    condition: sun

Thanks for any help!

Indentation…

condition:
  condition: or  # 'when dark' condition: either after sunset or before sunrise
  conditions:
    - condition: sun
      after: sunset
    - condition: sun
      before: sunrise

You can’t do OR with the automation editor, you’ll have to do it manually.

1 Like

you code is not correctly indented.

condition:
  condition: or  # 'when dark' condition: either after sunset or before sunrise
  conditions:
    - condition: sun
      after: sunset
    - condition: sun
      before: sunrise

Also the automation editor cannot yet handle OR and AND condition blocks…

1 Like

Great minds. :smile:

LOL this is really funny :smiley:

1 Like

I’m sorry, copy and pasting from my editor caused the indentation to be off. The two sub conditions are indented.

I assumed that the visual editor showing that meant it was an error. Thanks!

Would be totally hilarious if we both posted the same thing at the same time and we were both wrong…

1 Like

I think the answer here is I misunderstood what the visual editor was telling me. Thank you both for your input.

1 Like

Sorry for this question in this old thread…

I’m wondering why we can’t use the Condition type “Sun” in the UI automation creator? If I create the condition with the UI Editor, it doesnt work correctly. I don’t understand why it is not fixed, yet??

1 Like