I have a project that is tracking car driving speed using GPS data on my iphone and checks if driving speed is over the speed limit. The challenge is getting reliable and relatively frequent GPS data (that does not hog the battery).
I have found a way but from time to time, I get very high frequency GPS data (15 second intervals over a few minutes). Each GPS data point has speed calculated and due to GPS accuracy this results in high jitter. The impact is that speed can be massively overestimated and these ‘false positives’ are screwing up my project.
I can’t change the GPS source so I am trying to come up with a solution. One solution is to ‘rate limit’ the GPS data from the high frequency source. I am trying to do this using a template sensor that is triggered every 2 minutes. Below is the yaml from templates.yaml.
Does this look correct and I thought I would see the event firing every 2 minutes in the logbook.
- trigger:
- platform: time_pattern
minutes: "/2"
sensor:
- name: "Jago iCloud Custom"
unique_id: jago_icloud_custom
icon: "mdi:map-marker"
state: "{{ states('device_tracker.jago_iphone') }}"
attributes:
latitude: "{{ state_attr('device_tracker.jago_iphone', 'latitude') }}"
longitude: "{{ state_attr('device_tracker.jago_iphone', 'longitude') }}"
gps_accuracy: "{{ state_attr('device_tracker.jago_iphone', 'gps_accuracy') }}"
last_timestamp: "{{ state_attr('device_tracker.jago_iphone', 'last_timestamp') }}"