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

TeslaMate provided location bounces to "unknown" #766

Closed
k-korn opened this issue Nov 9, 2023 · 2 comments
Closed

TeslaMate provided location bounces to "unknown" #766

k-korn opened this issue Nov 9, 2023 · 2 comments

Comments

@k-korn
Copy link

k-korn commented Nov 9, 2023

Version of the custom_component

latest, 3.19.1

Configuration

Configured via UI.

Describe the bug

Due to recent changes in Tesla API, they stopped providing car location. Instead, I've switched to TeslaMate MQTT approach with coordinates posted to teslamate/cars/1/latitude, etc.

In general, this approach works. However, every few minutes car location changes to "unknown" and then bounces back:
https://i.imgur.com/ykkws8F.png
Events at 17:05:51 and 17:06:12 from the screenshot are visible in the debug log below.

If I check HA/Developer Tools/Events and subscribe to "state_changed" event, the following can be seen:

event_type: state_changed
data:
  entity_id: device_tracker.model_3_location_tracker
  old_state:
    entity_id: device_tracker.model_3_location_tracker
    state: Parking
    attributes:
      source_type: gps
      latitude: 30.453672
      longitude: 23.238591
      gps_accuracy: 0
      heading: null
      speed: null
      attribution: Data provided by Tesla
      friendly_name: Model 3
      icon: mdi:car-electric
    last_changed: "2023-11-09T14:54:12.564300+00:00"
    last_updated: "2023-11-09T14:54:12.564300+00:00"
    context:
      id: 01HET9752MDXNFSTYNNAQHB7MG
      parent_id: null
      user_id: null
  new_state:
    entity_id: device_tracker.model_3_location_tracker
    state: unknown
    attributes:
      source_type: gps
      heading: null
      speed: null
      attribution: Data provided by Tesla
      friendly_name: Model 3
      icon: mdi:car-electric
    last_changed: "2023-11-09T14:56:53.098924+00:00"
    last_updated: "2023-11-09T14:56:53.098924+00:00"
    context:
      id: 01HET9C1VADAMNTG24D73SMHSN
      parent_id: null
      user_id: null
origin: LOCAL
time_fired: "2023-11-09T14:56:53.098924+00:00"
context:
  id: 01HET9C1VADAMNTG24D73SMHSN
  parent_id: null
  user_id: null

In the "new_state" the state itself is "unknown" and the coordinates are missing, probably causing the "unknown" state.
This issue is most likely related to #608, but I'm not sure if debounce is tunable.

Debug log

2023-11-09 17:04:42.589 DEBUG (MainThread) [custom_components.tesla_custom] Listeners updated
2023-11-09 17:04:50.418 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:04:50.418 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.001 seconds (success: True)
2023-11-09 17:04:51.426 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:04:51.426 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.001 seconds (success: True)
2023-11-09 17:05:00.418 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:05:00.418 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.001 seconds (success: True)
2023-11-09 17:05:01.427 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:05:01.427 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.001 seconds (success: True)
2023-11-09 17:05:10.418 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:05:10.419 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.001 seconds (success: True)
2023-11-09 17:05:11.426 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:05:11.426 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.001 seconds (success: True)
2023-11-09 17:05:42.487 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] MQTT Topic Recieved: teslamate/cars/1/latitude
2023-11-09 17:05:42.487 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Getting TeslaCar for teslaMateID:1
2023-11-09 17:05:42.487 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Got latitude from MQTT for VIN:5YJ3Exx | TeslsMateID:1
2023-11-09 17:05:42.488 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Updating state 'latitude' to value '30.453672' in sub_path 'drive_state' for VIN:5YJ[DATA EXPUNGED]
2023-11-09 17:05:42.488 DEBUG (MainThread) [custom_components.tesla_custom] Previous debounce task cancelled
2023-11-09 17:05:42.488 DEBUG (MainThread) [custom_components.tesla_custom] New debounce task scheduled
2023-11-09 17:05:42.495 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] MQTT Topic Recieved: teslamate/cars/1/longitude
2023-11-09 17:05:42.495 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Getting TeslaCar for teslaMateID:1
2023-11-09 17:05:42.495 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Got longitude from MQTT for VIN:5YJ[DATA EXPUNGED] | TeslsMateID:1
2023-11-09 17:05:42.495 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Updating state 'longitude' to value '23.238591' in sub_path 'drive_state' for VIN:5YJ[DATA EXPUNGED]
2023-11-09 17:05:42.496 DEBUG (MainThread) [custom_components.tesla_custom] Previous debounce task cancelled
2023-11-09 17:05:42.496 DEBUG (MainThread) [custom_components.tesla_custom] New debounce task scheduled
2023-11-09 17:05:42.606 DEBUG (MainThread) [custom_components.tesla_custom] Listeners updated
2023-11-09 17:05:50.418 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:05:50.418 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.001 seconds (success: True)
2023-11-09 17:05:51.426 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:05:51.915 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.488 seconds (success: True)
2023-11-09 17:06:00.418 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:06:00.418 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.001 seconds (success: True)
2023-11-09 17:06:01.426 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:06:01.426 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.001 seconds (success: True)
2023-11-09 17:06:10.417 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:06:10.417 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.000 seconds (success: True)
2023-11-09 17:06:11.427 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:06:11.427 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.001 seconds (success: True)
2023-11-09 17:06:12.469 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] MQTT Topic Recieved: teslamate/cars/1/longitude
2023-11-09 17:06:12.469 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Getting TeslaCar for teslaMateID:1
2023-11-09 17:06:12.469 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Got longitude from MQTT for VIN:5YJ[DATA EXPUNGED] | TeslsMateID:1
2023-11-09 17:06:12.469 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Updating state 'longitude' to value '23.238591' in sub_path 'drive_state' for VIN:5YJ[DATA EXPUNGED]
2023-11-09 17:06:12.469 DEBUG (MainThread) [custom_components.tesla_custom] Previous debounce task cancelled
2023-11-09 17:06:12.470 DEBUG (MainThread) [custom_components.tesla_custom] New debounce task scheduled
2023-11-09 17:06:12.481 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] MQTT Topic Recieved: teslamate/cars/1/latitude
2023-11-09 17:06:12.481 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Getting TeslaCar for teslaMateID:1
2023-11-09 17:06:12.481 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Got latitude from MQTT for VIN:5YJ[DATA EXPUNGED] | TeslsMateID:1
2023-11-09 17:06:12.481 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Updating state 'latitude' to value '30.453672' in sub_path 'drive_state' for VIN:5YJ[DATA EXPUNGED]
2023-11-09 17:06:12.482 DEBUG (MainThread) [custom_components.tesla_custom] Previous debounce task cancelled
2023-11-09 17:06:12.482 DEBUG (MainThread) [custom_components.tesla_custom] New debounce task scheduled
2023-11-09 17:06:12.591 DEBUG (MainThread) [custom_components.tesla_custom] Listeners updated
2023-11-09 17:06:20.417 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()
2023-11-09 17:06:20.418 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.001 seconds (success: True)
2023-11-09 17:06:21.426 DEBUG (MainThread) [custom_components.tesla_custom] Running controller.update()

@oakedcorn
Copy link

Same observation here.

@oakedcorn
Copy link

oakedcorn commented Nov 11, 2023

This is related to #756
I think that the valid location data received from TeslaMate (with a fix for the recent Tesla API location change) via MQTT is overwritten by the invalid location received from teslajsonpy, which still needs an update for the API change.
Issue logged in teslajsonpy zabuldon/teslajsonpy#434

alandtse pushed a commit that referenced this issue Nov 12, 2023
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