Automations seem over complicated

Hi there,
I recently moved from Smarthings (using WebCoRE - a pretty handy Web based GUI for building advanced automations).

Apart from the GUI it was also easy to create nested AND / OR /NOR etc rules.

It may be only me, but the current method seems harder to create an automation based on the following (bedtime scene triggered when both sides of the bed present from eightsleep) - however it depends on who is actually home (wouldnt work it only one person is home)

In WebCoRE it was fairly simple

If [me home] AND [me bed presence] AND [wife home] AND [wife bed presence]
then [trigger bedtime]
else
IF [me home] AND [me bed presence] AND [wife not home]
OR
IF [wife home] AND [wife bed presence] AND [me not home]
then [trigger bedtime]

However if i have read the documentation correctly, i’d have to create 3 separate automations for the equivalent in hass?

  1. both home, both in bed = trigger
  2. me home, me in bed (wife not home, wife not in bed) = trigger
  3. wife home, wife in bed (me not home, me not in bed) = trigger

now this is just an example, but a lot of automations get more complicated the better they are at fitting their requirements.

Am i missing something?

Thanks

You’re missing two things:

  1. SmartThings is a commercial platform, with a huge development team
  2. Home Assistant is still a long way from release 1.0 (traditionally viewed as the first stable release)

This means that yes, HA is less polished, but it’s certainly possible to do what you’re after with some simple or conditions - exactly as you wrote:

automation:
  alias: Bed time
  trigger:
    - platform: state
      entity_id: group.my_people_bed
      state: "bed"
  condition:
    - condition: and
      conditions:
      - condition: or
        - condition: state
          entity_id: group.myself_bed
          state: "bed"
        - condition: state
          entity_id: device_tracker.myself
          state: 'not_home'
      - condition: or
        - condition: state
          entity_id: group.wife_bed
          state: "bed"
        - condition: state
          entity_id: device_tracker.wife
          state: 'not_home'
  action:
    - service: ...
2 Likes

ah ha - you CAN nest the queries, thanks - TOTALLY what i needed (i’m not a developer, and have to see someone else do it first, before i can adapt to my requirements)

Totally get that Smartthings is commerical, but interestingly WebCoRE (the best part) was a smartApp built by a community member.

appreciate the response

No worries. If you haven’t already found the Cookbook it’s worth a read, as are all the different people’s GitHubs linked from the bottom (and the GitHub search).

Also, when you read the docs on scripts (the actions parts of automations), the thing some people miss is that you can add conditions to scripts. That means you can have an automation that does some things, then checks a condition before it does (or doesn’t) do something else.

1 Like

thanks buddy - scripts are working better than scenes for me too as they can have multiple services/domains. not sure if its habbit, but i’m used to creating scenes and then triggering them based on rules. struggling to get everything in an automation.

will dig a little deeper in to scripts, great tip :slight_smile:

If you find yourself struggling at any point, do visit the Discord chat. There’s lots of folks there who know what they’re doing and can help you.

ok, so i think i’ve got most down except if and else ? tried discord but no luck

the most complicated automation i’m trying to run is to arm my house when the cleaners leave (as they often lock the door during the session)

So:

  1. when cleaner code used send message and start 5 minute timer
  2. if timer is up and no motion has been detected for the last 5 mins (main house areas) and door isnt already locked - trigger script goodbye - ELSE restart timer.
  3. wait 2 mins arm alarm

[or any other ideas for this]

I’m guessing your Discord handle is different, didn’t see jaburges there.

I’d probably do two automations.

  1. When the code is entered, delay for 5 minutes, then turn on the second automation
  2. Runs every 5 minutes (time trigger), and checks the state of the motion (off for 5 minutes) and the lock (locked). If those are true, delay two minutes, then lock the door, arm the alarm, and turn itself off.

Not real automations (I’ve not checked the actual service calls for the locks and alarm, or how they present as states), but close:

automation:
  - alias: "Cleaners have arrived"
    initial_state: "on"
    trigger:
      - platform: state
        entity_id: lock.front_door
        state: 'cleaner'
    action:
      - delay: '00:05:00'
      - service: automation.turn_on
        entity_id: automation.lock_up

  - alias: "Have the cleaners left"
    initial_state: "on"
    trigger:
      - platform: time
        minutes: '/5'
        seconds: 00
    condition:
      - condition: and
        conditions:
        - condition: state
          entity_id: binary_sensor.motion_1, binary_sensor.motion_2
          state: 'off'
          for:
            minutes: 5
        - condition: state
          entity_id: lock.front_door
          state: 'unlocked'
    action:
      - delay: '00:02:00'
      - service: lock.lock
        entity_id: lock.front_door
      - service: alarm.set
        entity_id: alarm.my_alarm
      - service: automation.turn_off
        entity_id: automation.lock_up
1 Like

thanks - i’m JB on discord - really appreciate the help!

ended up using this (so if the door has been locked and there was no motion inside, then thats them leaving) :slight_smile:

  - alias: "Have the cleaners left"
    initial_state: "on"
    trigger:
      - platform: state
        entity_id: lock.front_door
        to: 'locked'
        for:
          minutes: 2
    condition:
      - condition: and
        conditions:
        - condition: state
          entity_id: sensor.kitchen_motion_sensor_motion, sensor.living_room_sensor_motion
          state: 'off'
          for:
            minutes: 2
    action:
      - service: lock.lock
        entity_id: lock.front_door
      - service: script.turn_on
        entity_id: script.goodbye_script

And not to forget appdaemon https://home-assistant.io/docs/ecosystem/appdaemon/ I case you want to learn some python.

1 Like

:smiley: actually i do want to learn (like actually learn rather than my current copy and make edits) - any good resources to start with you’d recommend?

learn python you mean? Well I made one of the online tutorials. There are some where you have explanations and then little tasks to try out. Just google search and have a look what you might like.
At some point you should get yourself a “real” project though. In my case, it was homework for some experimental physics classes and so I made it using python. Maybe you have an idear for something useful you might want to have or could use.

i’ve been dabbling a lot - from robotics, to object vision, and now home automation - but each time i learn just enough to be dangerous, but not enough to understand whats going on. googling i have done, but there are thousands of options - just wondered if you recommend a good place to turn copy/paste to meaning :wink:

Sry can’t remember witch I actually did. Maybe someone else knows a good one?