Automation through web or in files?

Hey

Now that we have a full editor for automation in Web interface, how should it be handled at best ? Make all automations through the web interface ? for ease of edit (as ones done in files can’t be edited through web !).
As of right now I have few simple automations done in file (as not possible in the past through web) and so was thinking to remake them through web and delete it from automation yaml file ! What do you think about it ?

Thanks

Vincèn

Were you able to put AND/OR conditions in? I set a few automation via the editor, but couldn’t find an option for AND/OR conditions. I just set the conditions I wanted and then edited the YAML file with the lines for AND/OR conditions.

I get the following error when I see the automation in the editor:

Unsported automation: condition or

The condition would be condition: or - note the colon. AFAIK the editor doesn’t currently support and or or.

Personal preference IMO.

I’ve looked at the editor, but it doesn’t (yet) support all the options and I’m entirely comfortable doing it by hand. The GUI editor however ensures you don’t mistype the entity name, or make other simple mistakes, and it’s only improving with each update.

Thanks for the quick reply @Tinkerer

I had used the ‘colon’ still get an error when I use AND/OR conditions in the YAML file. Below is the error I get:

Unsupported condition: and
{
  "condition": "and",
  "conditions": [
    {
      "condition": "state",
      "entity_id": "MY MOBILE ID",
      "state": "away"
    },
    {
      "condition": "state",
      "entity_id": "WIFES MOBILE ID",
      "state": "away"
    }
  ]
}

And this is the code in the yaml:

condition:
    condition: and
    conditions:
      - condition: state
        entity_id: MY MOBILE ID
        state: away
      - condition: state
        entity_id: WIFES MOBILE ID
        state: away

The same for when I’m using the OR condition:

{
  "condition": "or",
  "conditions": [
    {
      "condition": "state",
      "entity_id": "MY DEVICE ID",
      "state": "home"
    },
    {
      "condition": "state",
      "entity_id": "WIFE DEVICE ID",
      "state": "home"
    }
  ]
}

The code in the yaml for the OR condition is:

ondition:
    condition: or
    conditions:
      - condition: state
        entity_id: MY DEVICE ID
        state: home
      - condition: state
        entity_id: WIFE DEVICE ID
        state: home

Basically, what I want to do is, at sunset, if no one is home, switch on the SONOFF switch, if someone IS home, then that Sonoff switch should be turned on at 00:00.
Then there is a automation to switch it off at sunrise with no conditions…

I think the web editor is just holding me back. I got used doing them in YAML and I plan to stick with it.
I learned quite a bit.

Looks like you’ve got some extra spaces, the conditions are over-indented.

condition:
  condition: and
  conditions:
    - condition: state
      entity_id: MY MOBILE ID
      state: away
    - condition: state
      entity_id: WIFES MOBILE ID
      state: away

However, are you creating these by hand, or in the editor. I don’t believe the editor yet supports and or or.

I’m doing the automation via the editor with all the conditions and then edit the automation.yaml with the AND/OR part of the conditions

@Tinkerer thanks for the pick-up on condition indentations… Let me change and check

I noticed (ater whole 5 days of using Hass.io) that Web Based Automation editor also creates some kind of “id” for each “web created” automation. This number is visible in generated code in YAML file, and most likely stored somewhere alse as well, for indentification. After removing this id’s from the YAML file (and leaving there rest of the code, for tests) Automations page became blank, even if automations are still in the file, so looks like without id system cannot recognize them. After copying back the id’s into file automations are again visible on the web page.
So maybe best idea is to generate basic automation by Web - just to get and register new id, and then modify the file by adding not supported conditions, etc ?
Not tried that though, just an idea.

I can confirm that the AND/OR conditions work after your edit the YAML file after you configure them from the Automation Editor - Thanks @Tinkerer, those indentations did the trick!

Although, I am now facing a new problem, in the AND condition for both the devices to be ‘away’ the device status actually has to be a in the ‘Away’ status. I have setup geofences and zones with OwnTracks, and when we’re in the ‘work’ zone, the automation doesn’t work. Is there a way to set a negative condition check, like check if state not equal to home?

An alternative way I can think of is if i nestle an OR condition between the AND to check if the states are ‘work’ or ‘away’

You could probably simplify it by creating a group for both devices, and checking its state is either not_home or work. That’ll be clearer than checking the state of each device individually.

If I just use the condition
state: not_home
Will I need to also check for the ‘work’ state?

As I said, you need to check for both…

@sigreg thanks all for your feedback and inputs, I guess @sigreg solution is probably the best compromise for now :wink: Create automations in GUI (easy and fast) and if needed edit them in config files to add extra stuffs not yet handled by Web interface and little by little with enhancement of Web interface use less and less file editor !

Hi @psinide, can you please paste the part that you change (for the indentations) so that I can see what needs to be changed in mine?