How to - logic/flow of an automation

Hey everyone, I placed this here, as it does not seem to fit anywhere else.

I have an automation that I am imagining, but am unsure how to express it in the gui.

This is what I would like:

When either myself, or my wife (triggered by the location update of our phones within our home zone) arrive home:

  1. Check if the other person has arrived home within the past 5 minutes (I want it to do this so that when we are together, the one phone will not trigger it, and then the second one trigger it again)
  2. Check if the garage door is closed (it has a sensor, so I check the sensor). If it is closed, open it, else, do nothing.
  3. Check if it is between 1 hour before sunset and one hour after sunrise. If it is, turn on the lights in the entrance hall, else do nothing.

So, I have two triggers (which I understand to be “or” triggers.) - my phone entering the home zone, and my wife’s phone entering the home zone.

Then I have a condition: if the garage door sensor says it is closed.

Then I have an action: open the garage door.

So, I would like to know:

  1. how I would add the check for the “opposite” phone that then one currently triggering.
  2. how I would add the condition and the action for the lights, based on sunset/sunrise
  3. how I would then add the actions in such a way that they are done only when their own related condition is met.

I would very much like to do this in the GUI, and not in YAML, but I am finding it hard setting out the logical sequence, and also struggling with which setting exactly does what, and how it relates to the other.

The attached image is a screenshot of what I have thus far.

I think that this will open the garage door, and turn on the lights (or not if still sunlight), BUT, I think that if the garage door is closed, the lights will be missed, as I believe in their present position, they are dependent upon the garage door being closed?

Any help appreciated.

Most things that can be done in YAML can be done in the UI, but posting dozens of screenshots is a very inefficient way of conveying how to set up an automation.

If you need a primer on how to transcribe YAML automation configurations that you find here on the forums using the UI Automation Editor, there is a (slightly dated) tutorial available on the Resin Chem Tech Youtube channel.

You may want to explore other available triggers. The state of a zone entity is the count of person entities that are currently in that zone. You can use a Numeric State trigger to fire when the state of the Home zone rises above 0. Another option would be to put your device trackers or person entities into a legacy group.

The condition block is checked once immediately after the trigger, then the actions proceed in order. In the automation provided, the door must have been closed for the action sequence to start. Once the actions start, the state of the door will not hinder the lights. If you wish to completely decouple the door and lights, you can use to If/Then action as follows:

trigger:
  - platform: numeric_state
    entity_id: zone.home
    above: 0
condition: []
action:
  - if:
      - alias: "If the garage is closed"
        condition: state
        entity_id: sensor.garage
        state: locked
    then:
      - alias: "Then turn on switch"
        service: switch.turn_on
        target:
          entity_id: switch.garage_door
  - if:
      - condition: sun
        before_offset: "01:00:00"
        before: sunrise
        after_offset: "-01:00:00"
        after: sunset
    then:
      - service: switch.turn_on
        target:
          entity_id:
            - light.EXAMPLE
1 Like

Hey there,

Thanks for this, much appreciated. Going through all the steps now. :slight_smile:
Cheers