Commute automation when passing through zones

Hi all,

I just started using a train sensor and I was wondering how can I use to create an automation regarding my daily commuting.

I want to HA says to my wife which train I took and if it has delay or not.

There are 2 different ways that I can choose for coming back home.

  1. Taking train A from station A at time 1
  2. Taking train B from station B at time 2

I created 2 different zones for station A and station B and i have ZANZITO on my smartphone which send an update every 30min with battery + position.

My idea is to create an automation that: if i passed in station A (zone A) report at a planned time expected delay through TTS or, if i passed in station B report the delay from the 2nd train.

Can some one please help me to implement this (if possible)?

As your app only updates every 30 minutes it would be wise imho to use your mobile phone to decide when to trigger the action. You being in the correct zone within this 30 minutes time frame can not be guaranteed I guess. If you are an android user this would be fairly easy to do using tasker. If you are using an iPhone I can’t help you. But I would let my phone call a HA script and go from there.

~Cheers

I can choose the update time and reduce it to 15 min for example. (but I think this will drain my battery faster).

I’m an android user, how can I use tasker (which I have but never used - too noob)?

You should install the AutoLocation plugin https://play.google.com/store/apps/details?hl=en_GB&id=com.joaomgcd.autolocation to handle the event of entering the two stations. And for the action (task) you should either choose a REST call or do a MQTT publish…there a multiple ways to go here. Is your HA installation reachable from the outside?

~Cheers

Yes. I have a public IP.

But at the moment I use to connect using VPN.

This shouldn’t be too difficult to automate. Fine tuning everything so it always reports accurately might be the big challenge.

I’d start with two automations. For one, the trigger would be you entering a zone: that corresponds to Station A. You’d probably want a condition on the automation, that corresponds to a timeframe around your usually commute time. (e.g. weekday afternoons).

The action for the automation would be a tts.google_say (or your tts engine of choice) that specifies a data_template: for the message: that references your train delay sensor. The last example in this section in the docs is similar, just with a temperature.

The second automation would be very similar, but the trigger would be you entering station b, and your tts message would have to refer to a different sensor.

When you take train A, do you travel through station B at all? And vice versa? That will make things more difficult, but not too difficult! Also, how close are the stations to each other?

EDIT: Also, if google maps is accurate enough, you might be able to ditch the individual train sensors, and once your device tracker enters the station zone, just report the google maps travel time to home with mode: transit specified. https://home-assistant.io/components/sensor.google_travel_time/

1 Like

You ispired me!

I will try to set up 2 automation that triggers when I enter in the railway station (that are no so close to overlap)

I let you know the results for historic purpose !