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

Integration fails to setup if site or car fails to respond during setup #315

Closed
Jonesnetwork opened this issue Oct 28, 2022 · 12 comments
Closed
Labels
bug Something isn't working

Comments

@Jonesnetwork
Copy link

Integration doesn't load - looks to be due to having 2 Gateways registered on the Tesla Account - (One working, and one thats failed and been replace)

-->

Version of the custom_component

3.0.1

-->

Configuration

Standard install - with Auth token - was working fine, until the failed gateway reappeared. (Is there a way to to set it to ignore anything thats failed?)

Describe the bug

Screenshot 2022-10-28 at 15 16 40

Wont log with the below debug output.

Debug log

2022-10-28 14:42:08.611 DEBUG (MainThread) [teslajsonpy.connection] Connecting with existing access token
2022-10-28 14:42:08.622 DEBUG (MainThread) [teslajsonpy.controller] 399 endpoints loaded
2022-10-28 14:42:08.622 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 4:11:40
2022-10-28 14:42:08.623 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/products {}
2022-10-28 14:42:08.891 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":[{"id":<removed>,"user_id":<userid>,"vehicle_id":<id>,"vin":"<vin>","display_name":"Teresita","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":"DRIVER","tokens":["36410ab4585a291e","c138f73f2bb8c2e8"],"state":"online","in_service":false,"id_s":"1492931233743874","calendar_enabled":true,"api_version":48,"backseat_token":null,"backseat_token_updated_at":null,"vehicle_config":{"aux_park_lamps":"Eu","badge_version":0,"can_accept_navigation_requests":true,"can_actuate_trunks":true,"car_special_type":"base","car_type":"model3","charge_port_type":"CCS","cop_user_set_temp_supported":true,"dashcam_clip_save_supported":true,"default_charge_to_max":false,"driver_assist":"TeslaAP3","ece_restrictions":true,"efficiency_package":"Default","eu_vehicle":true,"exterior_color":"MidnightSilver","exterior_trim":"Chrome","exterior_trim_override":"","has_air_suspension":false,"has_ludicrous_mode":false,"has_seat_cooling":false,"headlamp_type":"Premium","interior_trim_type":"Black","key_version":2,"motorized_charge_port":true,"paint_color_override":"19,20,22,0.8,0.04","performance_package":"Performance","plg":false,"pws":false,"rear_drive_unit":"PM216MOSFET","rear_seat_heaters":1,"rear_seat_type":0,"rhd":true,"roof_color":"RoofColorGlass","seat_type":null,"spoiler_type":"Passive","sun_roof_installed":null,"supports_qr_pairing":false,"third_row_seats":"None","timestamp":1666963820090,"trim_badging":"p74d","use_range_badging":true,"utc_offset":3600,"webcam_supported":true,"wheel_type":"Stiletto20DarkSquare"},"command_signing":"allowed"},{"energy_site_id":1689201426503170,"resource_type":"battery","site_name":"REMOVE ME","id":"STExxx20509-00082","gateway_id":"1152100-13-J--CNxxx024G3J04I","asset_site_id":"0ec3445c-c026-470f-b0ad-b45dc8aa8198","energy_left":0,"total_pack_energy":0,"percentage_charged":0,"battery_type":"ac_powerwall","backup_capable":true,"battery_power":0,"storm_mode_enabled":true,"powerwall_onboarding_settings_set":true,"sync_grid_alert_enabled":true,"breaker_alert_enabled":false,"components":{"battery":false,"battery_type":"ac_powerwall","solar":true,"solar_type":"pv_panel","grid":true,"load_meter":true,"market_type":"residential"}},{"energy_site_id":1689204023389203,"resource_type":"battery","site_name":"My Home","id":"STExxx20921-00213","gateway_id":"1152100-13-J--CNxxx164G3J012","asset_site_id":"95a17427-d88a-491e-a777-75d38cde78a4","energy_left":11352.736842105263,"total_pack_energy":14918,"percentage_charged":76.10093070187199,"battery_type":"ac_powerwall","backup_capable":true,"battery_power":380,"storm_mode_enabled":true,"powerwall_onboarding_settings_set":true,"sync_grid_alert_enabled":true,"breaker_alert_enabled":false,"components":{"battery":true,"battery_type":"ac_powerwall","solar":true,"solar_type":"pv_panel","grid":true,"load_meter":true,"market_type":"residential"}}],"count":3}
2022-10-28 14:42:08.893 DEBUG (MainThread) [teslajsonpy.controller] 94876: Changing car_online from {} to True
2022-10-28 14:42:08.893 DEBUG (MainThread) [teslajsonpy.controller] 94876: Resetting last_wake_up_time to: 1666964529
2022-10-28 14:42:08.893 DEBUG (MainThread) [teslajsonpy.controller] 94876: Resetting last_parked_timestamp to: 1666964529 shift_state None
2022-10-28 14:42:08.894 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 4:11:40
2022-10-28 14:42:08.895 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles/1492931233743874/vehicle_data {}
2022-10-28 14:42:17.994 DEBUG (MainThread) [teslajsonpy.connection] 408: {"response":null,"error":"{\"error\": \"timeout\"}","error_description":""}
2022-10-28 14:42:17.994 DEBUG (MainThread) [teslajsonpy.controller] Exception: vehicle_unavailable
api(('VEHICLE_DATA',) {'path_vars': {'vehicle_id': '1492931233743874'}, 'wake_if_asleep': False})
2022-10-28 14:42:17.995 DEBUG (MainThread) [teslajsonpy.controller] 94876: Changing car_online from True to False
2022-10-28 14:42:17.995 DEBUG (MainThread) [teslajsonpy.controller] Vehicle asleep - data unavailable.
2022-10-28 14:42:17.995 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 4:11:31
2022-10-28 14:42:17.996 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/energy_sites/1689201426503170/site_info {}
2022-10-28 14:42:18.827 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"id":"1152100-13-J--CN322024G3J04I","site_name":"REMOVE ME","backup_reserve_percent":30,"default_real_mode":"self_consumption","installation_date":"2022-05-09T11:29:29+01:00","user_settings":{"storm_mode_enabled":true,"powerwall_onboarding_settings_set":true,"sync_grid_alert_enabled":true,"breaker_alert_enabled":false},"components":{"solar":true,"solar_type":"pv_panel","battery":true,"grid":true,"backup":true,"gateway":"teg","load_meter":true,"tou_capable":true,"storm_mode_capable":true,"flex_energy_request_capable":false,"car_charging_data_supported":false,"off_grid_vehicle_charging_reserve_supported":false,"vehicle_charging_performance_view_enabled":false,"vehicle_charging_solar_offset_view_enabled":false,"battery_solar_offset_view_enabled":true,"solar_value_enabled":true,"energy_value_header":"Energy Value","energy_value_subheader":"Estimated Value","energy_service_self_scheduling_enabled":true,"show_grid_import_battery_source_cards":true,"backup_time_remaining_enabled":true,"battery_type":"ac_powerwall","configurable":true,"grid_services_enabled":false},"battery_count":1,"tou_settings":{"optimization_strategy":"economics","schedule":[{"target":"off_peak","week_days":[1,0],"start_seconds":84600,"end_seconds":19800},{"target":"peak","week_days":[1,0],"start_seconds":19800,"end_seconds":84600}]},"installation_time_zone":"Europe/London","max_site_meter_power_ac":1000000000,"min_site_meter_power_ac":-1000000000,"geolocation <geo location removed>
2022-10-28 14:42:18.828 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 4:11:30
2022-10-28 14:42:18.829 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/powerwalls/STE20220509-00082 {}
2022-10-28 14:42:19.744 DEBUG (MainThread) [teslajsonpy.connection] 408: {"response":null,"error":https://powergate.prd.sn.tesla.services:443/api/powerwalls/1152100-13-J--CNxxx024G3J04I/fullstatus => Can't get recent status from the battery,"error_description":""}
2022-10-28 14:42:19.744 DEBUG (MainThread) [teslajsonpy.controller] Exception: vehicle_unavailable
api(('BATTERY_DATA',) {'path_vars': {'battery_id': 'STE20220509-00082'}})
@shred86
Copy link
Collaborator

shred86 commented Oct 28, 2022

I don’t see any keys we could filter to ignore the failed gateway. Is Tesla not able to remove that failed gateway from your account?

@alandtse
Copy link
Owner

The integration just needs to gracefully handle something reporting a 408 and proceed with what information it has. It can reschedule future checks, but the 408 shouldn't cause the integration to completely fail to setup or run.

@Jonesnetwork
Copy link
Author

Apparently Tesla are having issues an unable to - they have removed it 3 times already but then it comes back, this time they havnt been able to make it disappear at all (and since then this issue has come back) - So we know it’s a Tesla API issue, but will be good if we could find a work around

@Jonesnetwork
Copy link
Author

The integration just needs to gracefully handle something reporting a 408 and proceed with what information it has. It can reschedule future checks, but the 408 shouldn't cause the integration to completely fail to setup or run.

Unfortunatly though - when it detects the failed gateway it does fail to load as soon above (you can see it detects both gateways in the logs) - when it happened last time, and tesla removed the failed gatrway, it loads fine with no issues. Now its appeared back again (and tesla cant seem to remove it) its failing to load.

If i can give you any more info, let me know, or if you need any more debug info etc :)

Thanks for your efforts, the integration works great when it works (which is Tesla's fault for not removing the failed gateway not the integration :))

@kjetilpp
Copy link

Have a car in my account, that is offline. Is this the same reason to why it failing at setup`?

@Jonesnetwork
Copy link
Author

So tesla has finally removed the failed gateway from my account (until the next time it just re-appears) - but i can confirm since its been removed, the integration now loads as expected.

@alandtse
Copy link
Owner

alandtse commented Nov 2, 2022

So tesla has finally removed the failed gateway from my account (until the next time it just re-appears) - but i can confirm since its been removed, the integration now loads as expected.

Glad it worked for you after tesla fixed it. I want to keep this open though because this type of thing shouldn't break the integration. It's definitely a bug.

@alandtse alandtse added the bug Something isn't working label Nov 2, 2022
@alandtse alandtse changed the title Failed to Setup Integration - (When theres a second failed gateway) Integration fails to setup if site or car fails to respond during setup Nov 2, 2022
@Jonesnetwork
Copy link
Author

Completely agree - if anything the findings above confirm the bug (if theres a failed component on the tesla side)

@kjetilpp
Copy link

kjetilpp commented Nov 2, 2022

Have a car in my account, that is offline. Is this the same reason to why it failing at setup`?

This is my error log, tested another Tesla account, without the car that is offline, and it works.

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/tesla_custom/__init__.py", line 216, in async_setup_entry cars = await controller.generate_car_objects(wake_if_asleep=wake_if_asleep) File "/usr/local/lib/python3.10/site-packages/teslajsonpy/controller.py", line 567, in generate_car_objects self._vehicle_data[vin] = await self.get_vehicle_data( File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 133, in retry ret = await target(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/teslajsonpy/controller.py", line 512, in get_vehicle_data return response UnboundLocalError: local variable 'response' referenced before assignment

@Jonesnetwork
Copy link
Author

Have a car in my account, that is offline. Is this the same reason to why it failing at setup`?

This is my error log, tested another Tesla account, without the car that is offline, and it works.

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 365, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/tesla_custom/__init__.py", line 216, in async_setup_entry cars = await controller.generate_car_objects(wake_if_asleep=wake_if_asleep) File "/usr/local/lib/python3.10/site-packages/teslajsonpy/controller.py", line 567, in generate_car_objects self._vehicle_data[vin] = await self.get_vehicle_data( File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 133, in retry ret = await target(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/teslajsonpy/controller.py", line 512, in get_vehicle_data return response UnboundLocalError: local variable 'response' referenced before assignment

Yes - its the same error. If theres a device thats offline on the tesla app (car or gateway) - you get the above error.

@denisjoshua
Copy link

I have same error like... and now I understand that probably is because Tesla change my Powerwall2 with another new one.
But now in my Tesla APP I have 2 battery... the old one that is not work obviously and the new one that it's work.

The issue is that If I install the components with only "Included Vehicles" the component is work...
But if I install the component with also "Include Energy Sites" it give me error.

Is there possibility to have a list of Powerwall before start to install the component ?
Maybe I can give it someware some parameters.

Thanks in advance
Denis

@elijah286
Copy link

elijah286 commented Nov 14, 2022

I'm having this error now too. I think it's because Tesla added a loaner to my app which is no longer there. Any fixes?

2022-11-14 12:39:18.586 ERROR (MainThread) [custom_components.tesla_custom] Unable to communicate with Tesla API: VEHICLE_UNAVAILABLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants