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

Unavailable battery sensor #996

Closed
2 tasks done
Chacsam opened this issue Jun 10, 2024 · 12 comments
Closed
2 tasks done

Unavailable battery sensor #996

Chacsam opened this issue Jun 10, 2024 · 12 comments
Labels
bug Something isn't working car For items that relate to Tesla vehicles help wanted Extra attention is needed triage New issues raised that need initial attention

Comments

@Chacsam
Copy link

Chacsam commented Jun 10, 2024

Is there an existing issue for this?

  • I have searched both the existing open issues & recently closed issues and did not find a duplicate of this issue.

I have read about the Fleet API and understand I may need to use it

  • I understand issues relating to read only commands will be auto closed if not using the Fleet API.

Version of the Tesla component

3.23.0

Version of the Tesla car software

2024.14.9

Model

Model 3

Current Behavior

Since several days the battery sensor is only occasionaly available.
I cannot say if it's linked to a version update.

Gaps found in history:

  • 08/06/2024 from 09.21 to 14.06 CET
  • since 09/06/2024 10.35, but reappeard between 15.00.00 and 15.36.42

Expected Behavior

Battery sensor to appear and remain there.

Debug logs

2024-06-10 17:50:31.743 DEBUG (MainThread) [custom_components.tesla_custom.teslamate] Got car ID. VIN:LRW3XXXXXXXXXXXX7 TeslamateID: None
2024-06-10 17:50:31.998 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"id":XXXXXXXXXXXX,"user_id":XXXXXXXXXXXX,"vehicle_id":16XXXXXXXXXXXX42,"vin":"LRW3XXXXXXXXXXXX7","color":null,"access_type":"OWNER","granular_access":{"hide_private":false},"tokens":["XXXXXXXXXXXX","XXXXXXXXXXXX"],"state":"online","in_service":false,"id_s":"XXXXXXXXXXXX","calendar_enabled":true,"api_version":76,"backseat_token":null,"backseat_token_updated_at":null,"ble_autopair_enrolled":false,"charge_state":{"battery_heater_on":false,"battery_level":64,"battery_range":216.57,"charge_amps":9,"charge_current_request":9,"charge_current_request_max":28,"charge_enable_request":false,"charge_energy_added":0.39,"charge_limit_soc":80,"charge_limit_soc_max":100,"charge_limit_soc_min":50,"charge_limit_soc_std":80,"charge_miles_added_ideal":1.5,"charge_miles_added_rated":1.5,"charge_port_cold_weather_mode":false,"charge_port_color":"\u003cinvalid\u003e","charge_port_door_open":true,"charge_port_latch":"Engaged","charge_rate":0.0,"charger_actual_current":0,"charger_phases":3,"charger_pilot_current":28,"charger_power":0,"charger_voltage":3,"charging_state":"Stopped","conn_charge_cable":"IEC","est_battery_range":228.9,"fast_charger_brand":"\u003cinvalid\u003e","fast_charger_present":false,"fast_charger_type":"ACSingleWireCAN","ideal_battery_range":216.57,"max_range_charge_counter":0,"minutes_to_full_charge":0,"not_enough_power_to_heat":null,"off_peak_charging_enabled":false,"off_peak_charging_times":"all_week","off_peak_hours_end_time":360,"preconditioning_enabled":false,"preconditioning_times":"all_week","scheduled_charging_mode":"Off","scheduled_charging_pending":false,"scheduled_charging_start_time":null,"scheduled_charging_start_time_app":0,"scheduled_departure_time":1714540500,"scheduled_departure_time_minutes":435,"supercharger_session_trip_planner":false,"time_to_full_charge":0.0,"timestamp":1718034631944,"trip_charging":false,"usable_battery_level":63,"user_charge_enable_request":false},"climate_state":{"allow_cabin_overheat_protection":true,"auto_seat_climate_left":true,"auto_seat_climate_right":true,"auto_steering_wheel_heat":true,"battery_heater":false,"battery_heater_no_power":null,"cabin_overheat_protection":"FanOnly","cabin_overheat_protection_actively_cooling":false,"climate_keeper_mode":"off","cop_activation_temperature":"High","defrost_mode":0,"driver_temp_setting":20.0,"fan_status":0,"hvac_auto_request":"On","inside_temp":19.8,"is_auto_conditioning_on":false,"is_climate_on":false,"is_front_defroster_on":false,"is_preconditioning":false,"is_rear_defroster_on":false,"left_temp_direction":0,"max_avail_temp":28.0,"min_avail_temp":15.0,"outside_temp":13.0,"passenger_temp_setting":20.0,"remote_heater_control_enabled":false,"right_temp_direction":0,"seat_fan_front_left":0,"seat_fan_front_right":0,"seat_heater_left":0,"seat_heater_rear_left":0,"seat_heater_rear_right":0,"seat_heater_right":0,"side_mirror_heaters":false,"steering_wheel_heat_level":0,"steering_wheel_heater":false,"supports_fan_only_cabin_overheat_protection":true,"timestamp":1718034631944,"wiper_blade_heater":false},"drive_state":{"gps_as_of":1718034101,"heading":184,"latitude":XXXXXXXXXXXX.032789,"longitude":XXXXXXXXXXXX.805321,"native_latitude":XXXXXXXXXXXX.032789,"native_location_supported":1,"native_longitude":XXXXXXXXXXXX.805321,"native_type":"wgs","power":0,"shift_state":"P","speed":0,"timestamp":1718034631944},"gui_settings":{"gui_24_hour_time":true,"gui_charge_rate_units":"km/hr","gui_distance_units":"km/hr","gui_range_display":"Rated","gui_temperature_units":"C","gui_tirepressure_units":"Bar","show_range_units":false,"timestamp":1718034631944},"vehicle_config":{"aux_park_lamps":"None","badge_version":1,"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":"TeslaAP4","ece_restrictions":true,"efficiency_package":"XXXXXXXXXXXX","eu_vehicle":true,"exterior_color":"XXXXXXXXXXXX","exterior_trim":"Black","exterior_trim_override":"","has_air_suspension":false,"has_ludicrous_mode":false,"has_seat_cooling":true,"headlamp_type":"Global","interior_trim_type":"Black2","key_version":2,"motorized_charge_port":true,"paint_color_override":"0,3,80,0.9,0.01","performance_package":"Base","plg":true,"pws":true,"rear_drive_unit":"XXXXXXXXXXXX","rear_seat_heaters":1,"rear_seat_type":0,"rhd":false,"roof_color":"RoofColorGlass","seat_type":null,"sentry_preview_supported":false,"spoiler_type":"None","sun_roof_installed":null,"supports_qr_pairing":false,"third_row_seats":"None","timestamp":1718034631944,"trim_badging":"74d","use_range_badging":true,"utc_offset":7200,"webcam_selfie_supported":true,"webcam_supported":true,"wheel_type":"Glider18"},"vehicle_state":{"api_version":76,"autopark_state_v2":"unavailable","calendar_supported":true,"car_version":"2024.14.9 0b82f700aebe","center_display_state":0,"dashcam_clip_save_available":true,"dashcam_state":"Recording","df":0,"dr":0,"fd_window":0,"feature_bitmask":"XXXXXXXXXXXX,XXXXXXXXXXXX","fp_window":0,"ft":0,"is_user_present":false,"locked":true,"media_info":{"audio_volume":1.3333,"audio_volume_increment":0.333333,"audio_volume_max":10.333333,"media_playback_status":"Playing","now_playing_album":"","now_playing_artist":"","now_playing_duration":196000,"now_playing_elapsed":140000,"now_playing_source":"Spotify","now_playing_station":"","now_playing_title":""},"media_state":{"remote_control_enabled":true},"notifications_supported":true,"odometer":XXXXXXXXXXXX.441443,"parsed_calendar_supported":true,"pf":0,"pr":0,"rd_window":0,"remote_start":false,"remote_start_enabled":true,"remote_start_supported":true,"rp_window":0,"rt":0,"santa_mode":0,"sentry_mode":false,"sentry_mode_available":true,"service_mode":false,"service_mode_plus":false,"software_update":{"download_perc":0,"expected_duration_sec":2700,"install_perc":1,"status":"","version":" "},"speed_limit_mode":{"active":false,"current_limit_mph":85.0,"max_limit_mph":120,"min_limit_mph":50.0,"pin_code_set":false},"timestamp":1718034631944,"tpms_hard_warning_fl":false,"tpms_hard_warning_fr":false,"tpms_hard_warning_rl":false,"tpms_hard_warning_rr":false,"tpms_last_seen_pressure_time_fl":1717998007,"tpms_last_seen_pressure_time_fr":1717998007,"tpms_last_seen_pressure_time_rl":1717998006,"tpms_last_seen_pressure_time_rr":1717998006,"tpms_pressure_fl":2.85,"tpms_pressure_fr":2.85,"tpms_pressure_rl":2.9,"tpms_pressure_rr":2.875,"tpms_rcp_front_value":2.9,"tpms_rcp_rear_value":2.9,"tpms_soft_warning_fl":false,"tpms_soft_warning_fr":false,"tpms_soft_warning_rl":false,"tpms_soft_warning_rr":false,"valet_mode":false,"valet_pin_needed":false,"vehicle_name":"M3 Fred","vehicle_self_test_progress":0,"vehicle_self_test_requested":false,"webcam_available":false}}}
2024-06-10 17:50:31.999 DEBUG (MainThread) [custom_components.tesla_custom] Finished fetching tesla_custom data in 0.277 seconds (success: True)
2024-06-10 17:50:32.003 ERROR (MainThread) [homeassistant.components.sensor] tesla_custom: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 729, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1289, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 529, in async_update
    await self.coordinator.async_request_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 262, in async_request_refresh
    await self._debounced_refresh.async_call()
  File "/usr/src/homeassistant/homeassistant/helpers/debounce.py", line 114, in async_call
    await task
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 288, in async_refresh
    await self._async_refresh(log_failures=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 411, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 165, in async_update_listeners
    update_callback()
  File "/config/custom_components/tesla_custom/base.py", line 79, in _handle_coordinator_update
    super()._handle_coordinator_update()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 491, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1000, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1126, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1061, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/select/__init__.py", line 148, in state
    current_option = self.current_option
                     ^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/tesla_custom/select.py", line 243, in current_option
    AUTO_SEAT_ID_MAP[self._seat_name]
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'rear center'

Anything else?

The "battery_level":64 is the accurate value at that moment
The KeyError: 'rear center' sounds appropriate as the M3 has no heating in center rear seat.

Range still works during same period
image

@Chacsam Chacsam added car For items that relate to Tesla vehicles triage New issues raised that need initial attention labels Jun 10, 2024
@alandtse
Copy link
Owner

@dandelionclock can you see if you can check for this too please? It may be handled by your new PR. Probably need a .get instead of an array access.

@alandtse alandtse added bug Something isn't working help wanted Extra attention is needed labels Jun 10, 2024
@Sebazzz
Copy link

Sebazzz commented Jun 10, 2024

I thought it was related to the Fleet API, so I went through all the trouble of setting up the Fleet API proxy and connecting to it from the integration but unfortunately this didn't work. It is therefore probably not API related.

@Sebazzz
Copy link

Sebazzz commented Jun 10, 2024

Rollback to v3.22.2 confirms this issue is new in v3.23.0.

@dandelionclock
Copy link
Contributor

Thanks for the bug report. I'll issue a PR soon to fix the KeyError. I forgot that rear seats don't have seat coolers. It was trying to pull cooling seats settings on the rear seat hence the error.

I'm not sure if it will fix the battery sensor though. The error occurred at on June 10 but your graph only go up to 2pm June 9. Do you see a time correlation between the error and the sensor becoming unavailable?

@Chacsam
Copy link
Author

Chacsam commented Jun 11, 2024

Thanks for the bug report. I'll issue a PR soon to fix the KeyError. I forgot that rear seats don't have seat coolers. It was trying to pull cooling seats settings on the rear seat hence the error.

I'm not sure if it will fix the battery sensor though. The error occurred at on June 10 but your graph only go up to 2pm June 9. Do you see a time correlation between the error and the sensor becoming unavailable?

The error started on June 8 and was still on-going since June 9, The rest of the graph just shows missing battery.
As @Sebazzz rolling back to v3.22.2 solved the issue: the sensor came back.
It was still active after re-updating to v3.23.0
I have kept debug on, will let you know when I notice it's back to unavailable

@Sebazzz
Copy link

Sebazzz commented Jun 11, 2024 via email

@zefixx1
Copy link

zefixx1 commented Jun 11, 2024

Same problem here. Model 3 2024 (Software 2024.20.1). No battery SoC since version 3.23.0

@JShoota
Copy link

JShoota commented Jun 11, 2024

Just updated to 3.23.0 this morning and lost battery as well. Happy to help with troubleshooting/testing.

@mfarad
Copy link

mfarad commented Jun 13, 2024

Same problem. Battery entity is no longer being provided by the tesla_custom integration version 3.23.0

@Chacsam
Copy link
Author

Chacsam commented Jun 13, 2024

Thanks for the bug report. I'll issue a PR soon to fix the KeyError. I forgot that rear seats don't have seat coolers. It was trying to pull cooling seats settings on the rear seat hence the error.
I'm not sure if it will fix the battery sensor though. The error occurred at on June 10 but your graph only go up to 2pm June 9. Do you see a time correlation between the error and the sensor becoming unavailable?

The error started on June 8 and was still on-going since June 9, The rest of the graph just shows missing battery. As @Sebazzz rolling back to v3.22.2 solved the issue: the sensor came back. It was still active after re-updating to v3.23.0 I have kept debug on, will let you know when I notice it's back to unavailable

not sure it does help anyhow, but giving the promised update: I even though I re-updated to v3.23 three days ago, my battery sensor has constantly been available so far, no new log to share

@zefixx1
Copy link

zefixx1 commented Jun 13, 2024

I removed the integration completely and reinstalled it (ver 3.23.0). Battery sensor still missing.
Model 3 2024 („Highland“ with Software 2024.20.1). Maybe only „Highland“ is affected ?

@zefixx1
Copy link

zefixx1 commented Jun 14, 2024

Sensor is working again. :)
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working car For items that relate to Tesla vehicles help wanted Extra attention is needed triage New issues raised that need initial attention
Projects
None yet
Development

No branches or pull requests

7 participants