alandtse / tesla

Tesla custom integration for Home Assistant. This requires a refresh token be generated by third-party apps to login.
Apache License 2.0
591 stars 100 forks source link

sensor.CARNAME_time_charge_complete does not continously update #497

Closed codedesperate closed 1 year ago

codedesperate commented 1 year ago

The entity sensor.CARNAME_time_charge_complete is only assigned a value as the car initially starts charging. As the car updates its estimated finish time in the app, this entity is not updated. If the cars charging limit is changed in the app, this entity still does not update. Even pressing the "force data update" button does not update this entity.

InTheDaylight14 commented 1 year ago

The next time you see this, can you add teslajsonpy to your logs and post the teslajsonpy api response (or errors)? The sensor is supposed to change when the complete time changes by more than 1 min. Any error will show up in those logs and that will help to narrow it down.

https://www.home-assistant.io/docs/configuration/troubleshooting/#enabling-debug-logging

codedesperate commented 1 year ago

@InTheDaylight14 Yes, I've just done this now. My car was charging at 3,7kw and it said it woudl be done in 12 hours.

I unplugged it, and drove home to a 11kw charger. I plugged the car in 1 hour ago, but it still says it is only done in 12 hours. (It is done in 1h 40min)

Here is an API response after a "Force update: 2023-02-05 17:37:39.643 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"id":censored,"user_id":censored,"vehicle_id":censored,"vin":"censored","display_name":"Catmobile","option_codes":"AD15,AF00,APFB,APH4,AU3D,BC3B,BT41,RNG0,CDM0,CH15,CODE,DRLH,DV2W,FC02,FG3B,FM3S,GLFR,HL32,HM30,ID3W,IL31,LTSB,MDL3,MR31,PMNG,PC30,REEU,RF3G,RS3H,S3PB,SA3P,SC04,STCP,SU3C,T3MS,TM00,TW01,UT3P,W40B,WR00,ZINV,MI02,PL30,SLR0,ST30,BG30,I36M,OSSB,AUF2,RSF0,ILF0,FGF0,CPF0,HP31,PT01,RL31,SWF0","color":null,"access_type":"OWNER","tokens":["censored","censored"],"state":"online","in_service":false,"id_s":"censored","calendar_enabled":true,"api_version":51,"backseat_token":null,"backseat_token_updated_at":null,"charge_state":{"battery_heater_on":false,"battery_level":51,"battery_range":124.93,"charge_amps":16,"charge_current_request":16,"charge_current_request_max":16,"charge_enable_request":true,"charge_energy_added":15.77,"charge_limit_soc":90,"charge_limit_soc_max":100,"charge_limit_soc_min":50,"charge_limit_soc_std":90,"charge_miles_added_ideal":77.0,"charge_miles_added_rated":77.0,"charge_port_cold_weather_mode":false,"charge_port_color":"<invalid>","charge_port_door_open":true,"charge_port_latch":"Engaged","charge_rate":51.7,"charger_actual_current":16,"charger_phases":2,"charger_pilot_current":16,"charger_power":11,"charger_voltage":232,"charging_state":"Charging","conn_charge_cable":"IEC","est_battery_range":103.11,"fast_charger_brand":"<invalid>","fast_charger_present":false,"fast_charger_type":"<invalid>","ideal_battery_range":124.93,"managed_charging_active":false,"managed_charging_start_time":null,"managed_charging_user_canceled":false,"max_range_charge_counter":0,"minutes_to_full_charge":110,"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":"weekdays","scheduled_charging_mode":"Off","scheduled_charging_pending":false,"scheduled_charging_start_time":null,"scheduled_charging_start_time_app":0,"scheduled_departure_time":1675664100,"scheduled_departure_time_minutes":435,"supercharger_session_trip_planner":false,"time_to_full_charge":1.83,"timestamp":1675615059545,"trip_charging":false,"usable_battery_level":50,"user_charge_enable_request":null},"climate_state":{"allow_cabin_overheat_protection":false,"auto_seat_climate_left":true,"auto_seat_climate_right":true,"battery_heater":false,"battery_heater_no_power":null,"cabin_overheat_protection":"On","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":12.1,"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":1.0,"passenger_temp_setting":20.0,"remote_heater_control_enabled":false,"right_temp_direction":0,"seat_heater_left":0,"seat_heater_right":0,"side_mirror_heaters":false,"supports_fan_only_cabin_overheat_protection":true,"timestamp":1675615059545,"wiper_blade_heater":false},"drive_state":{"active_route_latitude":censored,"active_route_longitude":censored,"active_route_traffic_minutes_delay":0.0,"gps_as_of":1675611722,"heading":282,"latitude":censored,"longitude":censored,"native_latitude":censored,"native_location_supported":1,"native_longitude":10.164676,"native_type":"wgs","power":-11,"shift_state":null,"speed":null,"timestamp":1675615059545},"gui_settings":{"gui_24_hour_time":true,"gui_charge_rate_units":"kW","gui_distance_units":"km/hr","gui_range_display":"Rated","gui_temperature_units":"C","gui_tirepressure_units":"Bar","show_range_units":false,"timestamp":1675615059545},"vehicle_config":{"aux_park_lamps":"None","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":"M32021","eu_vehicle":true,"exterior_color":"MidnightSilver","exterior_trim":"Black","exterior_trim_override":"","has_air_suspension":false,"has_ludicrous_mode":false,"has_seat_cooling":false,"headlamp_type":"Global","interior_trim_type":"Black2","key_version":2,"motorized_charge_port":true,"paint_color_override":"19,20,22,0.8,0.04","performance_package":"BasePlus","plg":true,"pws":false,"rear_drive_unit":"PM216MOSFET","rear_seat_heaters":0,"rear_seat_type":0,"rhd":false,"roof_color":"RoofColorGlass","seat_type":null,"spoiler_type":"None","sun_roof_installed":null,"supports_qr_pairing":false,"third_row_seats":"None","timestamp":1675615059545,"trim_badging":"50","use_range_badging":true,"utc_offset":3600,"webcam_selfie_supported":true,"webcam_supported":true,"wheel_type":"PinwheelRefresh18"},"vehicle_state":{"api_version":51,"autopark_state_v2":"unavailable","calendar_supported":true,"car_version":"2022.44.25.3 ff63b3ae90e2","center_display_state":0,"dashcam_clip_save_available":false,"dashcam_state":"Unavailable","df":0,"dr":0,"fd_window":0,"feature_bitmask":"dffbff,0","fp_window":0,"ft":0,"is_user_present":false,"locked":true,"media_info":{"a2dp_source_name":"Xperia 1 IV","audio_volume":1.0,"audio_volume_increment":0.333333,"audio_volume_max":10.333333,"media_playback_status":"Stopped","now_playing_album":"","now_playing_artist":"","now_playing_duration":0,"now_playing_elapsed":0,"now_playing_source":"12","now_playing_station":"","now_playing_title":""},"media_state":{"remote_control_enabled":true},"notifications_supported":true,"odometer":24143.458357,"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":50.0,"max_limit_mph":120,"min_limit_mph":50.0,"pin_code_set":false},"timestamp":1675615059545,"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":1675609907,"tpms_last_seen_pressure_time_fr":1675609907,"tpms_last_seen_pressure_time_rl":1675609907,"tpms_last_seen_pressure_time_rr":1675609907,"tpms_pressure_fl":2.825,"tpms_pressure_fr":2.825,"tpms_pressure_rl":2.825,"tpms_pressure_rr":2.8,"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":"Catmobile","vehicle_self_test_progress":0,"vehicle_self_test_requested":false,"webcam_available":true}}}

I see the API has this in the response: minutes_to_full_charge":110," It would be awesome to have a sensor with this value! :D It is exactely that value I would need. (So that I make an automation that tells me 10 minutes before I have to pick up the car from the public charger)

Thank you for your help.

InTheDaylight14 commented 1 year ago

Awesome, thanks for grabbing that info. Exactly what we need to debug. Just a heads up there is some personal info in there you might want to scrub. Like lat/long.

The time_charge_complete sensor is based off "time_to_full_charge":1.83 which syncs up nicely with minutes_to_full_charge":110. We can absolutely pass through minutes_to_full_charge as an attribute on the sensor. I'll get a PR together in the next few days.

I'm not really sure why the value is not updating, I need to read through the logic and think about it some more.

codedesperate commented 1 year ago

@InTheDaylight14 Ahh that would be perfect!