Repository navigation
fix(teslamate_vehicle): read the location topic as well (0.2.2) - #280
Merged
Merged
Conversation
TeslaMate's MQTT page now marks latitude and longitude deprecated in
favour of location, JSON {"latitude": <float>, "longitude": <float>}.
Without a geofence the driver uses the car's position for its distance
from the site.
Read location with host.json_decode under pcall and keep reading the old
topics for older TeslaMate versions. The newest message sets the
position. A location that is not JSON, lacks a key, or holds a value that
is not a finite number in range leaves the last position untouched. The
position still does not make the charge level fresh.
Refs #278
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
TeslaMate's MQTT page now marks
teslamate/cars/{id}/latitudeand.../longitudeas deprecated in favour of.../location, a JSON object withlatitudeandlongitude. The page also says location is never published empty. When no geofence is set,teslamate_vehicleuses the car's position to work outsite_distance_m. Once TeslaMate stops sending the old topics, that distance goes away.Refs #278
What
locationwithhost.json_decode, wrapped inpcallas the repo's structure tests require. It fills the sameplug.lat/plug.lonstate.latitudeandlongitude, so older TeslaMate versions keep working.locationis taken only when both keys hold finite numbers in range (±90, ±180). Anything else leaves the last position as it was: text that is not JSON, JSON cut short,null, a list, a missing key, a string or boolean value, NaN, 1e999, or a payload that is not text. Both coordinates change together or neither does, so a bad message never pairs a new latitude with an old longitude and never puts the car at 0,0.at_site. An explicit 0 is still read as a real coordinate on both paths.location. It behaves the same as before for every stringtonumbercan parse.make bump-driver, with the generated catalog files and a CHANGELOG entry.FTW's bundled recovery snapshot keeps 0.2.1 until someone moves the pin in
srcfl/ftw.Tests
New harness file
drivers/tests/lua_harness/test_teslamate_vehicle_location.lua, run fromdrivers/tests/test_teslamate_vehicle.py:locationalone gives the distance, moves the car, and keeps the level not fresh.locationbefore any position gives no distance, not 0,0.I checked that the tests catch real faults by breaking the driver on purpose four ways: ignoring the topic, skipping the range check, allowing half updates or 0 defaults, and dropping
pcall. Each one fails the new test.Local runs:
make test-driver ID=teslamate_vehicle: 43 passed, 13 skippedmake check: 5435 passed, 927 skippedThis has not been run against a real TeslaMate broker. The manifest already says the driver has not been run against a car.
🤖 Generated with Claude Code