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 }}"
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:
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!
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!
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=][^>]+)'
Hi,
I tried to add the package but somehow I have various sensors āunavailableā or āoffā. I set up the Imap-integration as well and that works so far.
Any help would be much appreciated. Enclosed two screenshots of the not working sensors in developer tools.
Edit: forgot to fetch the first 9200 bytes from the mailā¦ now itās working
Hi, now facing a problem when trying to use the attribute ālinkā of the Garmin Live Track id sensor. Somehow various CSS/HTML attributes are being attached to the link which makes it hard to useā¦
Anyone know how to solve this?
Thanks for your help
Try to change the regex sensor to:
https://livetrack.garmin.com/session/([a-z0-9-\n\r=]+)/token/([a-z0-9-\n\r=][^"]+)
Updated yaml in the top post.
Thanks for coming back to me. When I recall correctly the regex-part looked like this:
regex_findall(find='(https://livetrack.garmin.com/session/+[a-z0-9-]+/token/+[a-z0-9-]+)
I changed it to:
regex_findall(find='(https://livetrack.garmin.com/session/[a-z0-9-]+/token/[a-z0-9-]+)
Took out the ā+ā right after session/ and token/. that worked as wellā¦
Hi there
can someone explain how i can use the imap integration and grab the url. i only get the number of unread emails.
i tried to follow the documentation but im a little bit confuesd.
Dennis
As written in: IMAP - Home Assistant
the integration will trigger events that you could fetch info from email.
Ex lock at the code in top post.
If the imap integration has been set up the entity just shows the no. of email. So that part should be fine. Did you correctly set up the package? Do you see the various garmin sensors?
Hi there
no I do not see them.
when i try to test the configuration is says:
-
Setup of package āinput_textā failed: Integration āgarmin_livetrack_linkā not found.
-
Setup of package āsensorā failed: Invalid package definition āsensorā: expected a dictionary. Package will not be initialized
-
Setup of package ātemplateā failed: Invalid package definition ātemplateā: expected a dictionary. Package will not be initialized
-
Setup of package āautomationā failed: Invalid package definition āautomationā: expected a dictionary. Package will not be initialized
i made the folder package, added the package as a yaml file.
i also added to my configuration file :
homeassistant:
packages: !include_dir_merge_named packages
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
homeassistant:
packages: !include_dir_merge_named packages
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
Try:
packages: !include_dir_named packages
If you keep Garmin packade in separate file.