Is it possible to determine whether a device tracker is on land or at sea? I’d like to use this to reduce car alarm sensitivity when commuting by ferry, since the devices often react to waves and movement.
You could create a zone, or series of zones, along the ferry route.
It’s the sort of thing polygon zones would be great for. Unfortunately we don’t have them.
Thanks. I will try with a rest sensor.
It has to be in the zone for a bit of time for it to register depending on the device updates and other things, so use big zones for moving detections.
I’ve tried doing similar to detect when someone crossed the state line in a car, for instance, and it didn’t work because the circle had to be too big to be useful.
Polygonal zones are a thing via a custom integration GitHub - MichelGerding/Homeassistant-polygonal-zones
You could try and find some API where you can search on lat/lon and get address.
Maybe they report name of sea or whatever…
Node red also has polygon support
So far this is working:
- platform: rest
name: "car at sea"
unique_id: "caratsea"
resource_template: >-
{%- set lat = state_attr('device_tracker.car', 'latitude') -%}
{%- set lon = state_attr('device_tracker.car', 'longitude') -%}
{%- set username = "#### Your username ####" -%}
http://api.geonames.org/oceanJSON?lat={{lat}}&lng={{lon}}&username={{username}}
value_template: >-
{% if value_json.ocean is defined %}
Offshore ({{ value_json.ocean.name }})
{% else %}
Onshore
{% endif %}
icon: >
{% if states('sensor.car_at_sea') == 'Onshore' %}
mdi:road
{% else %}
mdi:ferry
{% endif %}
scan_interval: 60