Skip to main content.
There are multiple ways to crete geo-fence based events within home assistant. That is, trigger on entering or leaving an area.

Device Tracker

The easiest method is to have the Presence detection module log into your router to check the status of devices. Using this method you can determine if an indivdual is presnet at a particular location by watching how their phone is interacting with the local wifi router. Below you can see the code to enable presense detection on a verizon fios quantam gateway router. The issue here, is the detection speed. First, the router must be polled for presense detection which will result in some lag between a change and the actual event. Second, some hysteresis is required in the algorithm in order to prevent false triggers from just a temporary loss of device wifi signal.

device_tracker:
  - platform: quantum_gateway
    host: 192.168.1.1
    password: your_router_password

We use router based presense detection for "exit area" automation and for simple "who is home" indicators on the home assistant dashboard. It does not, however, serve us well for automating arrival events such as "turn on the heat as I arrive close to the house

IFTTT Based Geo-Fencing

We find the home assistant IFTTT integration much more useful for more advanced geo-fence events. IFTTT can notify home assistant on entry or exit from an area defined by drawing a circle on a map. This is a much more precise method of triggering on location and the app is very easy to integrate with home assistant.

The following is required:

You can test sending the https post request created above in step 2 with this site: apirequest.io or using curl from a linux command line as follows:

 $ curl -s -X POST https://hostname.duckdns.org:443/api/webhook/stringcreatedinstep2 -H "Content-Type: application/json" -d '{ "data_key" : "data_value" }'

Your home assistant automation to turn a light on before you get home would then look something like this:


- id: 'garage_light_on'
  alias: turn_on_light_when_enter_area
  trigger:
  - event_data:
      action: entered_near_home
    event_type: ifttt_webhook_received
    platform: event
  condition: []
  action:
  - data:
      entity_id: light.garage
    service: light.turn_on