Garmin LiveTrack tracking package 🗺️

Hi, cool project, inspired me to write some alternative because I use HA in docker and have difficulties to make imap sensors works I created fork of project:
GitHub - t-soltysiak/garmin-livetrack-to-json: Automatic Garmin livetrack stats to JSON (e. g. for Home Assistant) which is simple http json server that can be used to create template rest sensors which will base on localhost port.

Thanks for sharing this! I’m just getting it setup now, and I think it’s close to working, but I am receiving the following error

2023-08-20 09:55:54.196 ERROR (MainThread) [homeassistant.helpers.template_entity] TemplateError('ZeroDivisionError: float division by zero') while processing template 'Template<template=({{ 16.666666667/(states.sensor.garmin_livetrack.attributes.speed) if 'speed' in states.sensor.garmin_livetrack.attributes }}) renders=26>' for attribute 'pace' in entity 'binary_sensor.garmin_livetrack'

any thoughts? I’m looking at the logic and I can’t quite grasp why this is happening, because it looks correct to me:

pace: "{{ 16.666666667/(states.sensor.garmin_livetrack.attributes.speed) if 'speed' in states.sensor.garmin_livetrack.attributes }}"

If
states.sensor.garmin_livetrack.attributes.speed is 0 you will get that ZeroDivisionError error. I didn’t though of that.
You could use:

pace: "{{ 16.666666667/(states.sensor.garmin_livetrack.attributes.speed) if 'speed' in states.sensor.garmin_livetrack.attributes and float(states.sensor.garmin_livetrack.attributes.speed) > 0 }}"

:man_facepalming: ahh yeah, didn’t think of that. thanks!

Just setting this up now: bit confused by this section of the code:

  - alias: "Turn on automations with actions depending on Livetrack"
    service: automation.turn_on
    entity_id: 
    - automation.garmin_livetrack_kilometer
------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I don’t see the referred automation within your package file — what is that referring to? Is it something that you originally wrote that wasn’t needed when trigger-based template sensors were released? Leaving it in gives:

image

Also:

- binary_sensor:
  - name: Garmin Livetrack
    state: "{{ is_state_attr('automation.garmin_livetrack', 'current',1) }}"
------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^

The automation, if pasted from your code, is called automation.garmin_livetrack_new_link.

With that fixed, it appears to work perfectly on first test: email to my own account gets detected, and pulls in the data. I then set up a conditional card when the binary sensor is on to show a vertical stack of the LiveTrack link and a map card feeding off the position in the binary sensor’s attributes.

Thanks for saving me a stack of work!

1 Like

You could remove that part:

- alias: "Turn on automations with actions depending on Livetrack"
    service: automation.turn_on
    entity_id: 
    - automation.garmin_livetrack_kilometer

That’s activating an other automation that trigger after some running distance.
It’s not included in the packade.

This is next on my list of integrations to attempt! :crossed_fingers:

Hi, do you know why the links are not extracted right way on my end?

It’s looks that the <a href in the mail misses the ".

Try to change to > insted of " in the regex:

token/+[a-z0-9-\n\r=][^"]+)'
token/+[a-z0-9-\n\r=][^>]+)'