Very new to this, so apologies if I use the wrong terminology. I thought I’d cracked it, but it’s quite hard for me to test.
I’m trying to send a notification to two phones when (and only when) they are both away from the “home” zone and the garage door is left open. Happens frequently around these parts, and I thought this might be a good practice for something other than the really basic “click here to switch on the light” things I’ve been dealing with before.
I struggle sometimes with logic sadly and my brain goes into shutdown when I try to think it through.
I had set up an automation that said:
when phone 1 leaves home zone
and/if phone 2 leaves home zone
and/if garage door is open
send a notification
Is that the right way to do this?
When I tested it by deliberately leaving the garage door open, the data signal was poor and I needed to go into the automation remotely and run it - I’m using Tailscale to connect. HA home screen knew both devices were “away” from home but nothing had come through automatically. I then closed the garage door remotely.
Whilst I was out, and now I’m back home again, if I run the automation, it rather unhelpfully still notifies me the garage door was left open - but then I guess it’s dealing with the past tense
Was going to try this one as it seemed more elegant (will try both) but I had to wrap the 0 in “” to get past an error - seems a little odd that I’d have to do that, as it’s no longer a number?
alias: Workshop door test 2
description: Garage Door open whilst away from home warning
triggers:
- triggers:
- trigger: state
entity_id: zone.home
to: "0"
conditions:
- condition: device
device_id: ee12f6235155f1401aa7834d1431fd78
domain: cover
entity_id: 7532f235fdf5c829deb27b5269399177
type: is_open
actions:
- device_id: 456a4788923f9cebc139e21135279344
domain: mobile_app
type: notify
message: Workshop door was left open
- device_id: cb731f908f22eb26682a1b57166d48d0
domain: mobile_app
type: notify
message: Workshop door was left open
alias: New automation
description: Garage Door open whilst away from home warning
triggers:
- triggers:
- trigger: state
entity_id: zone.home
to: "0"
conditions:
- condition: state
entity_id: cover.smart_garage_door_2006047904931836100248e1e91e3918_garage
state: open
actions:
- device_id: 456a4788923f9cebc139e21135279344
domain: mobile_app
type: notify
message: Workshop door was left open
- device_id: cb731f908f22eb26682a1b57166d48d0
domain: mobile_app
type: notify
message: Workshop door was left open
mode: single
And while you are at it change the actions to … Actions (previously known as service calls).
If you named the phone to say “Wuffls” then when you replace the phone, and you delete the old one and add the new one with the same name, it will just work.
Having it bound to a device id will be lots of work.
The other method some people use is to create a script with the notify phones actions.
That way you can pass the message to the script and run the script.
And when it’s time to replace it, you just change in one place.
I actually just did a similar thing with a Christmas Lights automation I’ve done - I created a (forget the word) “group”? for the wifi plugs and called the group name from the automation, so I can add in the correct wifi switches to the group as and when I find them in the attic without changing the script itself.
Would you mind providing a link to what you mean by “Actions” please? It seems to throw up various vagueries referring to action when I try and search. Eager to learn. I assume this is just trying to keep things more object oriented, which clearly means I’m showing my age with my actionscript flashbacks.
It is indeed a bit all over the place. There is a mention of actions under the automations docs which is basically just an anchor, but then also under the script syntax docs here and here, plus every integration has information on its actions in its docs. Mobile notifications via the companion app are even more special, with its docs under the companion app docs.
In this case though, just go to the actions page under the dev tools on your HA instance and start to type notify. Select the one you want (each mobile device using the companion app has its own notify action). Then look at the YAML generated.
Its a bad decision to say the least from HA developers to call both the automation yaml action and the service calls actions.
Previously they were called call service, which may not make sense to people, but having the same name twice is not great.
Its kind of like naming all your kids the same name. It may seem cute and all but it won’t be great.
About to go out, so will test it - I had this earlier.
alias: New automation
description: Garage Door open whilst away from home warning
triggers:
- triggers:
- trigger: state
entity_id: zone.home
to: "0"
conditions:
- condition: state
entity_id: cover.smart_garage_door_2006047904931836100248e1e91e3918_garage
state: open
actions:
- action: notify.mobile_app_nameofphone_iphone
data:
message: Workshop door is open
- action: notify.mobile_app_otherphone_iphone
data:
message: Workshop door is open
mode: single