I’m a refugee from Stringify and am loving what HA can do for me. I’ve already made good progress and have three phones reporting location, accepting push notifications and a whole bunch of home devices connected.
I’m currently working on replicating my Stringify flows before moving on to more interesting things (Alexa, for example), and wondered if someone could let me know if the below looks okay? It’s hard for me to test as we’d all need to leave the house to do it - and I’ve never created an automation with an OR clause before.
This first script should disarm my Arlo cameras at 6am, but ONLY if at least one of three phones is home. The in-built editor doesn’t like the OR bit, I had to manually edit the script to get it in there.
- id: '1554995899987'
alias: 'Arlo: Disarm at 6am (if home)'
trigger:
- at: 06:00
platform: time
condition:
- condition: or
conditions:
- condition: state
entity_id: device_tracker.phone1
state: home
- condition: state
entity_id: device_tracker.phone2
state: home
- condition: state
entity_id: device_tracker.phone3
state: home
action:
- data:
entity_id: alarm_control_panel.aarlo_office_camera
service: alarm_control_panel.alarm_disarm
- data:
entity_id: alarm_control_panel.aarlo_kitchen_camera
service: alarm_control_panel.alarm_disarm
- data:
entity_id: alarm_control_panel.aarlo_lounge_camera
service: alarm_control_panel.alarm_disarm
- data:
message: Cameras disarmed at 6am
service: notify.ios_phone1
This second script should arm my Arlo cameras ONLY when all three phones are away from the house.
- id: '1554996646777'
alias: 'Arlo: Arm when away'
trigger:
- entity_id: device_tracker.phone1
from: home
platform: state
to: not_home
- entity_id: device_tracker.phone2
from: home
platform: state
to: not_home
- entity_id: device_tracker.phone3
from: home
platform: state
to: not_home
condition:
- condition: state
entity_id: device_tracker.phone1
state: not_home
- condition: state
entity_id: device_tracker.phone2
state: not_home
- condition: state
entity_id: device_tracker.phone3
state: not_home
action:
- data:
entity_id: alarm_control_panel.aarlo_office_camera
service: alarm_control_panel.alarm_arm_away
- data:
entity_id: alarm_control_panel.aarlo_kitchen_camera
service: alarm_control_panel.alarm_arm_away
- data:
entity_id: alarm_control_panel.aarlo_lounge_camera
service: alarm_control_panel.alarm_arm_away
- data:
message: Cameras armed - house empty
service: notify.ios_phone1
Do they look okay? I’m particularly keen to check the first script with the OR clause does what I think it does.
I dont notice any glaring issues but it might be easier if you use the hassio add on NodeRed to design these types of automation. The below image basically does the same thing you mention in your first script. It checks to see if my phone or my wife’s phone is home if not set an input boolean to off meaning not home, Else if at least 1 phone is present input boolean = on.
Yes it should work, install NodeRed in another container then once its up and running you would just need to install the HomeAssistant Pallet. Im sure in your search you came across this as well but here is a link: Setting up Node-red on Home Assistant in a Synology docker container
Thanks, got that installed and working. Will spend some time with Node-Red and see what I can come up with, certainly looks an easier (and more Stringify-like) way to set up the automations.
Your two automations (‘scripts’ are another concept in Home Assistant) appear to be fine (I assume the second one got it’s indentation corrupted during copy-paste).
I realize you’ve moved on to Node-red. However, for anyone still interested, the two automations can be simplified as follows:
- id: '1554995899987'
alias: 'Arlo: Disarm at 6am (if home)'
trigger:
- platform: time
at: '06:00:00'
condition:
- condition: or
conditions:
- condition: state
entity_id: device_tracker.phone1
state: home
- condition: state
entity_id: device_tracker.phone2
state: home
- condition: state
entity_id: device_tracker.phone3
state: home
action:
- service: alarm_control_panel.alarm_disarm
data:
entity_id: alarm_control_panel.aarlo_office_camera, alarm_control_panel.aarlo_kitchen_camera, alarm_control_panel.aarlo_lounge_camera
- service: notify.ios_phone1
data:
message: Cameras disarmed at 6am
- id: '1554996646777'
alias: 'Arlo: Arm when away'
trigger:
- platform: state
entity_id: device_tracker.phone1, device_tracker.phone2, device_tracker.phone3
from: home
to: not_home
condition:
- condition: state
entity_id: device_tracker.phone1
state: not_home
- condition: state
entity_id: device_tracker.phone2
state: not_home
- condition: state
entity_id: device_tracker.phone3
state: not_home
action:
- service: alarm_control_panel.alarm_arm_away
data:
entity_id: alarm_control_panel.aarlo_office_camera, alarm_control_panel.aarlo_kitchen_camera, alarm_control_panel.aarlo_lounge_camera
- service: notify.ios_phone1
data:
message: Cameras armed - house empty
Should you be interested, it’s also possible to simplify the condition section in both automations.
and to alleviate any confusion in the future you will almost never see the entity_id’s written out in a comma separated list like that. What you will usually see is like this:
List length. When there are only a few entities, JSON-style is compact. When there are many entities, YAML-style improves legibility.
Personal preference.
Anyway, a fine philosophical discussion to be sure (in the vein of ‘spaces or tabs?’) but the audience has moved from the House of YAML to the Temple of Node-Red (where lists are in JSON format).
Agreed, we’re here to help new users so it would be fair to say:
You will almost never see multiple entity_id’s listed in JSON or YAML format. Yet both forms are valid and help to create more compact triggers and actions.