malcolmrigg / wizard-clock-card

A wizarding clock Lovelace component for Home Assistant
53 stars 13 forks source link

Better support for "speed" attributes, including for person entities looking up the speed from their current device tracker source #21

Open HecktorX opened 5 days ago

HecktorX commented 5 days ago

Hey there,

I hope my code help you to solve this point from your bucket list: Better support for "speed" attributes, including for person entities looking up the speed from their current device tracker source (all files in Zip-Attachment)

Changes (Based on V1 from 06.2024):

The problem was that the “velocity” attribute is read from the mobile phone. However, this parameter only appears when the navigation is on (e.g. Google Maps route guidance). However, the location is updated automatically without the need to run other apps. Therefore, the python script “update_custom_sensor_attribute.py” adds another attribute “Speed” to the cell phone entity. The speed parameter is calculated in the “Geotracking_updateVel” automation. It compares the coordinates of the last known location with the current location. The speed is calculated using the elapsed time.

1) Install HACS: pyscript 2) Store “update_custom_sensor_attribute.py” under /homeassistant/python_scripts/update_custom_sensor_attribute.py 3) Create a new automation. Code as a template in “Geotracking_updateVel.txt” 4) Upload the file “weasley-card.js” under /homeassistant/www/custom-lovelace/weasley-card.js 5) Under Settings/Areas, Labels & Zones/Zones, mark the stations that you may visit frequently as train stations 6) Activate all settings in connection with the location in the mobile app

Translated with DeepL.com (free version)


Erstellung Card mit zwei Zeigern

Änderungen (Basierend auf V1 vom 06.2024):

Das Problem war, dass das Attribut "velocity" vom Handy ausgelesen wird. Allerings erscheint dieser Parameter erst, wenn die Navigation an ist (bspw. Google Maps Routenführung). Allerdings aktualisiert sich der Standort automatisch, ohne das weitere Apps laufen müssen. Daher fügt das Pythonsyript "update_custom_sensor_attribute.py" einen weiteres Attribut "Speed" der Handy Entität hinzu. Der Parameter Speed wird in der Autmatisierung "Geotracking_updateVel" berechnet. Es vergleicht die Kooardinaten vom letzten bekannten Standort mit dem Aktuellen. Über die vergangene Zeit wird der Speed berechnet.

1) HACS: pyscript installieren 2) "update_custom_sensor_attribute.py" unter /homeassistant/python_scripts/update_custom_sensor_attribute.py ablegen 3) Neue Automatisierung erstellen. Code als Vorlage in "Geotracking_updateVel.txt" 4) Die Datei "weasley-card.js" unter /homeassistant/www/custom-lovelace/weasley-card.js hochladen 5) Unter Einstellungen/Bereiche, Labels & Zonen/Zonen die Bahnhöfe die man möglicherweise häufig besucht als trainstation markieren 6) In der Handy App sämtliche Einstellungen in Zusammenhand mit dem Standort aktivireren Wizard-clock-speed-support.zip

malcolmrigg commented 3 days ago

Sounds like a good solution, I'll have a look, thanks!

HecktorX commented 3 days ago

great, I hope you can include this in your standard code. The traveling status works very well for me now. However, it is of course a bit more complicated to add more people ;) Just a quick note, it was a bit tricky with the train station. When you are there, the speed goes to zero and the pointer would normally go to lost. Which is wrong. Therefore, the zone must be set to trainstation and then transferred to the traveling status of the clock. I'm curious to see what you make of it XD

Translated with DeepL.com (free version)