Closed BlueBenson closed 1 year ago
Please enable debug logs for tesla and teslajsonpy and check for any errors.
Please also confirm:
Yes I confirm. I deleted the old component and reinstalled. I used the china auth. Except the GPS other functions all good. Sent from my iPhoneOn Oct 22, 2022, at 18:51, Alan Tse @.***> wrote: Please also confirm:
You've removed and readded the component. You've used the Chinese auth server to login. Other features work.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
same problem
China server(tesla.cn)
2022-10-22 22:40:01.772 DEBUG (MainThread) [teslajsonpy.connection] Connecting with existing access token
2022-10-22 22:40:01.774 DEBUG (MainThread) [teslajsonpy.controller] 399 endpoints loaded
2022-10-22 22:40:01.776 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 6:55:13
2022-10-22 22:40:01.776 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/products {}
2022-10-22 22:40:04.884 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":[{"id":1492930982760013,"user_id":234431,"vehicle_id":1886836044,"vin":"5YJXCCE23HF037400","display_name":"Wendy's TeslaX","option_codes":"AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0","color":null,"access_type":"OWNER","tokens":["9b1895bb5ff1f09b","1e0a9fb7b838d667"],"state":"online","in_service":false,"id_s":"1492930982760013","calendar_enabled":true,"api_version":36,"backseat_token":null,"backseat_token_updated_at":null,"vehicle_config":{"can_accept_navigation_requests":true,"can_actuate_trunks":true,"car_special_type":"base","car_type":"modelx","charge_port_type":"EU","dashcam_clip_save_supported":true,"default_charge_to_max":false,"driver_assist":"TeslaAP3","ece_restrictions":false,"efficiency_package":"Default","eu_vehicle":true,"exterior_color":"Pearl","front_drive_unit":"NoneOrSmall","has_air_suspension":true,"has_ludicrous_mode":false,"has_seat_cooling":false,"headlamp_type":"Led","interior_trim_type":"AllBlack","motorized_charge_port":true,"plg":true,"pws":false,"rear_drive_unit":"Small","rear_seat_heaters":0,"rear_seat_type":3,"rhd":false,"roof_color":"None","seat_type":0,"spoiler_type":"Passive","sun_roof_installed":0,"third_row_seats":"FuturisFoldFlat","timestamp":1666449466021,"trim_badging":"90d","use_range_badging":false,"utc_offset":28800,"wheel_type":"AeroTurbine20"},"command_signing":"off"}],"count":1}
2022-10-22 22:40:04.884 DEBUG (MainThread) [teslajsonpy.controller] 37400: Changing car_online from {} to True
2022-10-22 22:40:04.884 DEBUG (MainThread) [teslajsonpy.controller] 37400: Resetting last_wake_up_time to: 1666449605
2022-10-22 22:40:04.884 DEBUG (MainThread) [teslajsonpy.controller] 37400: Resetting last_parked_timestamp to: 1666449602 shift_state None
2022-10-22 22:40:04.884 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 6:55:10
2022-10-22 22:40:04.884 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles/1492930982760013/vehicle_data {}
2022-10-22 22:40:06.169 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"id":1492930982760013,"user_id":234431,"vehicle_id":1886836044,"vin":"5YJXCCE23HF037400","display_name":"Wendy's TeslaX","option_codes":"AD15,MDL3,PBSB,RENA,BT37,ID3W,RF3G,S3PB,DRLH,DV2W,W39B,APF0,COUS,BC3B,CH07,PC30,FC3P,FG31,GLFR,HL31,HM31,IL31,LTPB,MR31,FM3B,RS3H,SA3P,STCP,SC04,SU3C,T3CA,TW00,TM00,UT3P,WR00,AU3P,APH3,AF00,ZCST,MI00,CDM0","color":null,"access_type":"OWNER","tokens":["9b1895bb5ff1f09b","1e0a9fb7b838d667"],"state":"online","in_service":false,"id_s":"1492930982760013","calendar_enabled":true,"api_version":36,"backseat_token":null,"backseat_token_updated_at":null,"charge_state":{"battery_heater_on":false,"battery_level":90,"battery_range":247.01,"charge_amps":24,"charge_current_request":24,"charge_current_request_max":24,"charge_enable_request":true,"charge_energy_added":45.83,"charge_limit_soc":90,"charge_limit_soc_max":100,"charge_limit_soc_min":50,"charge_limit_soc_std":90,"charge_miles_added_ideal":133.5,"charge_miles_added_rated":167.5,"charge_port_cold_weather_mode":null,"charge_port_color":"Off","charge_port_door_open":true,"charge_port_latch":"Engaged","charge_rate":0.0,"charge_to_max_range":false,"charger_actual_current":0,"charger_phases":null,"charger_pilot_current":24,"charger_power":0,"charger_voltage":0,"charging_state":"Complete","conn_charge_cable":"IEC","est_battery_range":150.79,"fast_charger_brand":"
Looking at the logs above, this is what's listed in the "drive_state" key:
"drive_state": {
"corrected_latitude": 24.980499,
"corrected_longitude": 102.666374,
"gps_as_of": 1666449682,
"heading": 5,
"latitude": 24.983561,
"longitude": 102.665039,
"native_latitude": 24.980501,
"native_location_supported": 1,
"native_longitude": 102.666374,
"native_type": "gcj",
"power": 0,
"shift_state": null,
"speed": null,
"timestamp": 1666449700353
}
I'm not too familiar with GCJ-02 but it appears to be based on WGS-84 and is adding offsets to the latitude and longitude.
Looking at what the Tesla API is returning, there's three different possible values, corrected_latitude
, latitude
and native_latitude
, none of which values match. It also passes the native_type
of gcj
.
Are we sure latitude
or corrected_latitude
isn't already the converted GCJ-02 coordinates to WGS-84? If so, this would greatly simplify our problem. Additionally, I think we could just check the native_type
field here instead of checking the auth_domain the user is using.
Edit: Looking at my "drive_state" key (I'm in the U.S.), native_latitude
and latitude
are identical (same with longitude) and native_type
is gps
, which makes sense. I'm pretty sure the Tesla API returns the GCJ-02 coordinates as native_latitude
and native_longitude
, and is doing the conversion which is then passed in WGS-84 as either latitude
or corrected_latitude
.
I just ran the native_latitude
and native_longitude
values above through the gcj02towgs84 function we're using to convert the values and these are the values I got:
This appears to almost match the values the Tesla API is passing for latitude
and longitude
.
This is in dev and can be tested there.
Hi @alandtse @shred86 ,thank you guys so much. I replace the const.py&device_tracker.py from https://github.com/shred86/tesla/tree/china-coords. it works now.
Should be fixed in v3.0.1.
Version of the custom_component
3.0
Configuration
Describe the bug
Upgrade 3.0 Tesla Location tracker not work (China Server) Wendy's TeslaX Location tracker was detected at unknown
Debug log