Alert when person leaves work zone and is 10 minutes from home

I am wanting to set up some sort of alert (lights flash) when my wife leaves work and is 10 minutes from home. This way I can put her dinner in the oven just before she gets home. We work shift and get home at different times.

I already have presence detection setup via life360 so I can tell where we are at all times and zones for work and home. I was thinking of setting up a new zone around home that is large enough that it takes 15 minutes to drive to the edge of it.

So I need help setting up an alert that goes off only after she has left work location and enters the 10 minute drive location.

Any ideas?

Maybe some how with a template. I am just not sure how to program that…

automation:
  trigger:
    # enters 15 minutes drive away zone
    platform: zone
    entity_id: device_tracker.clairelife360
    zone: zone.home15mindrive
    event: enter
  condition:
    # has been in work zone the in last hour.
    condition: template
    value_template: '{{ states.device_tracker.clairelife360.##### left work in last hour ########### }}'

Just to Just to clarify My problem isn’t that I need to work out when she is 15 minutes away, it is that I only want it to trigger when she has left work in the last hour. So if she pops to the shops I dont get notifications etc

Use the Google maps travel time component. It looks easy to set up and it’s in my to do list.

Check it out here : https://home-assistant.io/components/sensor.google_travel_time/

1 Like

looks good and I will look into that in the future but My problem isn’t that I need to work out when she is 15 minutes away, it is that I only want it to trigger when she has left work in the last hour. So if she pops to the shops I dont get notifications etc

Use the Proximity Component

You will be limited to distance instead of time, but that would depend on traffic issues on the route.

Example from my configuration (trimmed down):

proximity:
  home:
    zone: home
    devices:
      - device_tracker.phone
    tolerance: 65
    unit_of_measurement: ft

automation old:
  # Proximity Testing Arriving at Home
  - alias: "Zone - Home Arriving"
    trigger:
      - platform: numeric_state
        entity_id: proximity.home
        below: 250
      - platform: template
        value_template: "{%- if state_attr('proximity.home', 'dir_of_travel') in ['towards', 'arrived'] -%} True {%- else -%} False {%- endif %}"
    condition:
      - condition: template
        value_template: "{%- if state_attr('proximity.home', 'dir_of_travel') in ['towards', 'arrived'] -%} True {%- else -%} False {%- endif %}"
      - condition: numeric_state
        entity_id: proximity.home
        below: 250
    action:
      - service: script.notification_alert
        data:
          title: "Zone Proximity"
          message: "Arriving at Home"
1 Like

I now do it with a node-red flow. which is alot cleaner. I dont need three automation and a input Boolean to achieve the same thing like I did before.

My flow looks like this…

Trigger node: Triggers when a chosen device tracker current state is “not_home” and previous state was “Work”

Wait Until Node: Wait until “Proximity” of chosen node is below 4. using the proximity component in HA.

Change Node: Sets payload to Message for notification “Dad is nearly home”

Throttle node: Only passes one payload per hour.

Call service: Send notification using your chosen notification service

Node red export

[{"id":"1ab301c8.f9ecfe","type":"ha-wait-until","z":"ea42b334.b6a77","name":"","server":"56e35aef.6eb604","outputs":2,"entityId":"proximity.chris_home","property":"state","comparator":"lte","value":"4","valueType":"num","timeout":"60","timeoutUnits":"minutes","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":580,"y":1260,"wires":[["e0039921.a373f8"],[]]},{"id":"5aa1c4cc.b0429c","type":"trigger-state","z":"ea42b334.b6a77","name":"","server":"56e35aef.6eb604","entityid":"device_tracker.life360_#####","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"5eqz1fqjnbx","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"not_home"},{"id":"7fz9nv21srs","targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"Work"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"str","x":230,"y":1260,"wires":[["1ab301c8.f9ecfe"],[]]},{"id":"e0039921.a373f8","type":"change","z":"ea42b334.b6a77","name":"Set Notification Text","rules":[{"t":"set","p":"payload","pt":"msg","to":"Daddies Nearly Home","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":1260,"wires":[["85a59aaf.35d278","1c137b24.5e9485"]]},{"id":"1c137b24.5e9485","type":"throttle","z":"ea42b334.b6a77","name":"","throttleType":"time","timeLimit":"60","timeLimitType":"minutes","countLimit":0,"blockSize":0,"locked":false,"x":1010,"y":1260,"wires":[["8a92e9b9.362ba8"]]},{"id":"8a92e9b9.362ba8","type":"link out","z":"ea42b334.b6a77","name":"Chris Leaving Work Notification","links":["15794538.fcc0ab","f80e3d97.622d9"],"x":1115,"y":1260,"wires":[]},{"id":"56e35aef.6eb604","type":"server","z":"","name":"Home Assistant (####)","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}]
3 Likes