I had an automation in webcore on smartthings that was triggered when i opened my garage door, if my or my wife’s phone “changed to” home, this would unlock our door.
“Changed to” essentially meant that my phone’s presence changed to the desired state within the last 30 seconds. This prevents the door from unlocking when i was already home (instead of just coming home) and opened my garage door
You are correct, I’m trying to make a more deliberate version in HA. What I’m trying to do is the following:
Garage Door is opening
If Brian or Butter’s iphone has “changed to” home ( i can make two separate automation for each phone if necessary)
then unlock garage entry door
I found the state called “geocoded location” and can do a from and to state for that, but only in a trigger, not in a condition. I do prefer having the trigger be the garage door opening because that will fire this less often and be a little more precise.
Problem is that I can’t do a from and to state in a condition and only in a trigger.
Changed to from WebCoRE is directly analogous to trigger in this case
Also in case you use NodeRed ‘events: state’ nodes are changes to while ‘current state’ nodes are ‘is’
If you want the ‘changed to’ behavior from your piston as-is. You’ll have to use that trigger THEN check the garage condition.
Also yes it’s a little more ‘triggery’ that way than garage door first but in the context of HA (happily hums along with hundreds of thousands of requests in the background) it’s not going to matter…
thanks for that insight. so you are saying just utilizing the state of geocoded location from and to will be sufficient? do we know what the time lapse for that is? i might need to tweak the location range based on how long that trigger can hold that state change.
My current automation in yaml, haven’t added my wife’s phone yet, but that’s trivial
alias: Unlock Garage Entry Upon Arrival (Brian)
description: ""
trigger:
- platform: state
entity_id:
- sensor.brians_iphone_geocoded_location
from: not_home
to: home
condition:
- condition: device
device_id: id9999999999999999
domain: cover
entity_id: cover.garage_door
type: is_opening
action:
- service: script.unlock_garage_entry_door
data: {}
- service: notify.mobile_app_brians_iphone
data:
message: Unlocked Garage Entry bc Brian's home
mode: single
Have you looked at zones? May be a better way to handle this.
The zone object will have an attribute for the total count of device trackers in a zone. You could use trigger zone x (home zone) > 0 (im more than positive I saw such an example on the site within the last two days.)
Also each device tracker object has home and not_home…
Short version, the way you were using changes to in webcore wasn’t exactly how it was designed - it was purely for an event notification when something happened. You were relying on an underlying idiosyncrasy of how webcore worked to interpret ‘in the last 30 seconds’
From my experience converting over 80 pistons in my own system last year I’d advise the following or it will drive you crazy trying to do 1:1 conversions…
first walk away from the logic in your piston and rewrite what each does in natural language. Write it as if your explaining to a layperson what the piston does. Do NOT fall in the trap of looking at HOW it does it.
Sit down in your automation tool of choice and work out how to do what you wrote down WITHOUT looking back at source (this forced me to think about it how HA or NR would do it… Not how SmartThings and WebCoRE did it) and this is the freeing bit. It’s so much more capable you will find new easier ways to do things.
Such as. In this case you don’t have to aggregate your own trackers. Ha does it for you if you know where to look. In your case Id trigger on trackers in home zone >0