Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HecktorX opened this issue Nov 24, 2024 · 2 comments

Comments

@HecktorX
Copy link

HecktorX commented Nov 24, 2024

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):

  • Pointer goes to Travelling when:
    • If you are at a station that is named as a trainstation in the zones
    • If the speed is more than 0.5, then the pointer goes to traveling (see this.travelingState && stateVelo > 0.5 in the file “weasley-card.js”)
  • Another parameter Speed was introduced

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):

  • Zeiger geht auf Travelling wenn:
    • Wenn man an einem Bahnhof ist, der in den Zonen als trainstation benannt ist
    • Wenn die geschwindigekt mehr als 0,5 ist, dann geht der Zeiger auf Travelling (siehe this.travellingState && stateVelo > 0.5 in der datei "weasley-card.js")
  • Es wurde ein weiterer Parameter Speed eingeführt

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
Copy link
Owner

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

@HecktorX
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants