Share when you are on your way home

So me and my girlfriend are on different times home when coming from work. Almost everyday, we sent a message to each other how late we expect to be home. Although it works perfectly, you would think this could be automated.

So today I took the challenge and wanted to share the result with you. Maybe it gives you new ideas.

First thing that I did, was to make sure I have travel time sensors in place. I am mostly going by public transport or car, whereas my girlfriend goes by car or bicycle. For every person and transportation method, I added a sensor. I put the scan_interval to a higher number to avoid any costs from Google. Basically I don’t have to update it that often, because I just update it before sending a notification.

- platform: google_travel_time
  api_key: !secret google_travel_time_api_key
  origin: person.peter
  destination: zone.home
  name: travel_peter_bus
  scan_interval: 900
  options:
      language: nl
      mode: transit
      transit_mode: bus

- platform: google_travel_time
  api_key: !secret google_travel_time_api_key
  origin: person.peter
  destination: zone.home
  name: travel_peter_car
  scan_interval: 900
  options:
      language: nl
      mode: driving

- platform: google_travel_time
  api_key: !secret google_travel_time_api_key
  origin: person.marieke
  destination: zone.home
  name: travel_marieke_bicycle
  scan_interval: 900
  options:
      language: nl
      mode: bicycling

- platform: google_travel_time
  api_key: !secret google_travel_time_api_key
  origin: person.marieke
  destination: zone.home
  name: travel_marieke_car
  scan_interval: 900
  options:
      language: nl
      mode: driving

Next thing that I did, was creating a script, which would first update these travel times and finally send a notification to either one of us. To be sure, I added a small delay in case the travel time is not updated on time:

travel_peter_bus:
    sequence:
      - service: homeassistant.update_entity
        entity_id: sensor.travel_peter_bus
      - delay: '00:00:30' 
      - service: notify.telegram_marieke
        data:
          title: Peter is onderweg naar huis!
          message: Hij is over {{ states.sensor.travel_peter_bus.attributes.duration }} thuis!

travel_peter_car:
    sequence:
      - service: homeassistant.update_entity
        entity_id: sensor.travel_peter_car
      - delay: '00:00:30' 
      - service: notify.telegram_marieke
        data:
          title: Peter is onderweg naar huis!
          message: Hij is over {{ states.sensor.travel_peter_car.attributes.duration }} thuis!

travel_marieke_car:
    sequence:
      - service: homeassistant.update_entity
        entity_id: sensor.travel_marieke_car
      - delay: '00:00:30' 
      - service: notify.telegram_peter
        data:
          title: Marieke is onderweg naar huis!
          message: Zij is over {{ states.sensor.travel_marieke_car.attributes.duration }} thuis!

travel_marieke_bicycle:
    sequence:
      - service: homeassistant.update_entity
        entity_id: sensor.travel_marieke_bicycle
      - delay: '00:00:30' 
      - service: notify.telegram_peter
        data:
          title: Marieke is onderweg naar huis!
          message: Zij is over {{ states.sensor.travel_marieke_bicycle.attributes.duration }} thuis!

Finally I used the awesome button card to add buttons:

          - type: horizontal-stack
            cards:
              - type: "custom:button-card"
                entity: script.travel_peter_bus
                icon: mdi:bus
                show_name: false
              - type: "custom:button-card"
                entity: script.travel_peter_car
                icon: mdi:car
                show_name: false
              - type: "custom:button-card"
                entity: script.travel_marieke_bicycle
                icon: mdi:bike
                show_name: false
              - type: "custom:button-card"
                entity: script.travel_marieke_car
                icon: mdi:car
                show_name: false

Perhaps I could also add an automation, but when I am work, I am not interested when she is coming home and sometimes before she gets home, she will do some shopping.

So for now, we just press a button, to notify the other.

Hope this adds value for someone else!

9 Likes