Automation condition based on speed

Hi,

I am trying to work out how I can apply a condition on an automation based on speed. I have a Shelly 1 connected to my electric gates, I would like to create an automation that when I am driving and I get close to my house the gates will be triggered to open (so if I am walking the gates will not be triggered)

My trigger is when I enter my ‘Home Zone’

How can I apply a condition that my speed needs to be great than 10mph?

Regards
James

Perhaps determine “driving vs walking” via other sensors, such as phone connection type, SSID, or focus? But not sure if those reliably update frequently enough to give the precision you need.

What are you using for person/device tracking?

IIRC, the HA companion app’s device tracker entity should have a speed attribute when it is using GPS.

I have the HA app on my phone which I use to track, the car is also able to connect to WIFI so I use that to track when the car is home.
The problem I have is that we live on a busy fast road (the speed limit is 60mph) the HA app will track when I am in the Home Zone but that will also pick up when I am walking to the house (When I walk the dogs/walk to the pub). Due to the speed WIFI won’t pick up the car until I am on the drive.

My aim is to trigger the gates to open earlier enough that when I arrive at the house they are open for me to drive through.

Regards

A couple ideas that will hopefully trigger something that you find helpful….

Use Developer Tools → States → “filter” to look through the various values of your phone and car integrations to see what’s available. My iPhone exposes an “iphone steps” sensor… perhaps make a determination of “walking” if that value is increasing, “driving” if not? Maybe create a threshold sensor on the steps sensor?

Alternatively, what about creating one or more additional Zones farther away from Home, and look at the time difference between when you were in them? E.g., if you enter Home Zone and were just in “a mile from home” a minute ago you’re driving, but if it was several minutes ago you’re walking.

Or, least satisfying but most reliable, the manual approach. Create a button that you push to set a helper something like “I’m walking so don’t open the gate next time I arrive at Home Zone”.

You might want to consider using the Proximity integration to trigger the automation instead of relying on connecting to WiFi. A rough-draft would be something like the following:

alias: Open Gates when Approaching Home at speed
description: ''
trigger:
  - platform: numeric_state
    entity_id: proximity.james
    below: "1"
condition:
  - condition: state
    entity_id: proximity.james
    attribute: dir_of_travel
    state: towards
  - condition: numeric_state
    entity_id: device_tracker.james_phone
    attribute: speed
    above: 20
action:
  - #Action to Open the Gate
mode: single

What kind of device do you have? Android has an activity sensor that I use for precisely this type of scenario: if I arrive home and am biking, prompt me to open the garage.

Thank you I’ve just read up about this integrate and I will try it later, but there is two issues I can see with it. The first is that if more than one person is tracked with proximity, the state remains ‘0’ so if I am at home and my wife is in the car the gates won’t open as the state is still ‘0’. The second is there is no attribute to speed (surely I am not the only person who has raised the need to have speed under attributes??)

My wife and I have iPhones, the cars are tracked via WIFI connection. Interesting Android has this build in what’s it called so I can google the equivalent?

Regards

As alluded to by my use of proximity.james in my example, you can setup individual sensors for each user. Then you add a trigger for each in the automation.

There is… Mobile app device tracker attributes. Perhaps you have not set the necessary location permissions or enabled the sensor. I don’t have an iPhone, so it’s possible that the iOS version doesn’t have this attribute, but that doesn’t seem to be the case according to the docs.

You might also consider using the companion app’s Activity sensor.

Many thanks for your replies, I have tested a number of variables over the last week, a bit hit or miss! Sometimes it works, other times you end up waiting. I have checked the speed attribute, annoyingly its not included on iOS!

Regards