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
554 stars 99 forks source link

binary_sensor.[my-car]_charger not accurately reflecting charger connection state #478

Open gourdo1 opened 1 year ago

gourdo1 commented 1 year ago

Version of the custom_component

3.9.1

Configuration

There is nothing Tesla-related in my config yaml.

Describe the bug

Charger state does not appear to reflect physical reality... Assuming I should be relying on binary_sensor.[my-car]_charger for whether the charging cable is plugged in, it's showing randomly plugged in and out all day... See history screenshot.

Debug log

2023-01-07 23:43:23.223 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 10 Interval 60
2023-01-07 23:43:23.224 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79651. Since last wake up: 14903. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None
2023-01-07 23:43:23.224 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for 101 seconds
2023-01-07 23:43:23.224 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Skipping update with state online. Polling: True. Last update: 559 ago. Last parked: 79651 ago. Last wake up 14903 ago.
2023-01-07 23:43:33.211 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 20 Interval 60
2023-01-07 23:43:33.212 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79661. Since last wake up: 14913. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None
2023-01-07 23:43:33.212 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for 91 seconds
2023-01-07 23:43:33.212 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Skipping update with state online. Polling: True. Last update: 569 ago. Last parked: 79661 ago. Last wake up 14913 ago.
2023-01-07 23:43:43.211 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 30 Interval 60
2023-01-07 23:43:43.212 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79671. Since last wake up: 14923. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None 
2023-01-07 23:43:43.212 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for 81 seconds
2023-01-07 23:43:43.213 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Skipping update with state online. Polling: True. Last update: 579 ago. Last parked: 79671 ago. Last wake up 14923 ago.
2023-01-07 23:43:53.222 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 40 Interval 60
2023-01-07 23:43:53.222 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79681. Since last wake up: 14933. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None
2023-01-07 23:43:53.222 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for 71 seconds
2023-01-07 23:43:53.222 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Skipping update with state online. Polling: True. Last update: 589 ago. Last parked: 79681 ago. Last wake up 14933 ago.
2023-01-07 23:44:03.211 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 50 Interval 60
2023-01-07 23:44:03.211 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79691. Since last wake up: 14943. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None
2023-01-07 23:44:03.211 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for 61 seconds
2023-01-07 23:44:03.211 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Skipping update with state online. Polling: True. Last update: 599 ago. Last parked: 79691 ago. Last wake up 14943 ago.
2023-01-07 23:44:13.211 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 60 Interval 60
2023-01-07 23:44:13.212 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 1:02:22
2023-01-07 23:44:13.213 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles {}
2023-01-07 23:44:13.406 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":[{"id":149293064624XXXX,"vehicle_id":168243XXXX,"vin":"5YJSA1H2XFFP7XXXX","display_name":"My Tesla","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":["de28b3dc76e19379","898902618096cf34"],"state":"online","in_service":false,"id_s":"149293064624XXXX","calendar_enabled":true,"api_version":36,"backseat_token":null,"backseat_token_updated_at":null}],"count":1}
2023-01-07 23:44:13.407 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79701. Since last wake up: 14953. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None
2023-01-07 23:44:13.407 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for 51 seconds
2023-01-07 23:44:13.407 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Skipping update with state online. Polling: True. Last update: 609 ago. Last parked: 79701 ago. Last wake up 14953 ago.
2023-01-07 23:44:23.214 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 10 Interval 60
2023-01-07 23:44:23.215 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79711. Since last wake up: 14963. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None
2023-01-07 23:44:23.215 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for 41 seconds
2023-01-07 23:44:23.215 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Skipping update with state online. Polling: True. Last update: 619 ago. Last parked: 79711 ago. Last wake up 14963 ago.
2023-01-07 23:44:33.212 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 20 Interval 60
2023-01-07 23:44:33.212 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79721. Since last wake up: 14973. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None
2023-01-07 23:44:33.213 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for 31 seconds
2023-01-07 23:44:33.213 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Skipping update with state online. Polling: True. Last update: 629 ago. Last parked: 79721 ago. Last wake up 14973 ago.
2023-01-07 23:44:43.211 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 30 Interval 60
2023-01-07 23:44:43.212 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79731. Since last wake up: 14983. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None
2023-01-07 23:44:43.213 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for 21 seconds
2023-01-07 23:44:43.213 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Skipping update with state online. Polling: True. Last update: 639 ago. Last parked: 79731 ago. Last wake up 14983 ago.
2023-01-07 23:44:53.221 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 40 Interval 60
2023-01-07 23:44:53.221 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79741. Since last wake up: 14993. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None
2023-01-07 23:44:53.221 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for 11 seconds
2023-01-07 23:44:53.221 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Skipping update with state online. Polling: True. Last update: 649 ago. Last parked: 79741 ago. Last wake up 14993 ago.
2023-01-07 23:45:03.212 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 50 Interval 60
2023-01-07 23:45:03.213 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79751. Since last wake up: 15003. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None
2023-01-07 23:45:03.213 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for 1 seconds
2023-01-07 23:45:03.214 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Skipping update with state online. Polling: True. Last update: 659 ago. Last parked: 79751 ago. Last wake up 15003 ago.
2023-01-07 23:45:13.211 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 60 Interval 60
2023-01-07 23:45:13.212 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 1:01:22
2023-01-07 23:45:13.213 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles {}
2023-01-07 23:45:13.464 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":[{"id":149293064624XXXX,"vehicle_id":168243XXXX,"vin":"5YJSA1H2XFFP7XXXX","display_name":"My Tesla","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":["3c6d92f139976e13","de28b3dc76e19379"],"state":"online","in_service":false,"id_s":"149293064624XXXX","calendar_enabled":true,"api_version":36,"backseat_token":null,"backseat_token_updated_at":null}],"count":1}
2023-01-07 23:45:13.465 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79761. Since last wake up: 15013. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None
2023-01-07 23:45:13.465 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for -9 seconds
2023-01-07 23:45:13.465 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Updating VEHICLE_DATA
2023-01-07 23:45:13.466 DEBUG (MainThread) [teslajsonpy.connection] Token expiration in 1:01:22
2023-01-07 23:45:13.466 DEBUG (MainThread) [teslajsonpy.connection] get: https://owner-api.teslamotors.com/api/1/vehicles/149293064624XXXX/vehicle_data {}
2023-01-07 23:45:17.029 DEBUG (MainThread) [teslajsonpy.connection] 200: {"response":{"id":149293064624XXXX,"user_id":50789,"vehicle_id":168243XXXX,"vin":"5YJSA1H2XFFP7XXXX","display_name":"My Tesla","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":["3c6d92f139976e13","de28b3dc76e19379"],"state":"online","in_service":false,"id_s":"149293064624XXXX","calendar_enabled":true,"api_version":36,"backseat_token":null,"backseat_token_updated_at":null,"charge_state":{"battery_heater_on":false,"battery_level":46,"battery_range":108.54,"charge_amps":64,"charge_current_request":64,"charge_current_request_max":64,"charge_enable_request":false,"charge_energy_added":0.0,"charge_limit_soc":75,"charge_limit_soc_max":100,"charge_limit_soc_min":50,"charge_limit_soc_std":90,"charge_miles_added_ideal":0.0,"charge_miles_added_rated":0.0,"charge_port_cold_weather_mode":null,"charge_port_color":"<invalid>","charge_port_door_open":null,"charge_port_latch":"<invalid>","charge_rate":0.0,"charge_to_max_range":false,"charger_actual_current":null,"charger_phases":null,"charger_pilot_current":null,"charger_power":null,"charger_voltage":null,"charging_state":null,"conn_charge_cable":"<invalid>","est_battery_range":88.56,"fast_charger_brand":"<invalid>","fast_charger_present":null,"fast_charger_type":"<invalid>","ideal_battery_range":140.2,"managed_charging_active":false,"managed_charging_start_time":null,"managed_charging_user_canceled":false,"max_range_charge_counter":0,"minutes_to_full_charge":0,"not_enough_power_to_heat":null,"off_peak_charging_enabled":true,"off_peak_charging_times":"all_week","off_peak_hours_end_time":420,"preconditioning_enabled":false,"preconditioning_times":"weekdays","scheduled_charging_mode":"DepartBy","scheduled_charging_pending":false,"scheduled_charging_start_time":1673182800,"scheduled_charging_start_time_app":240,"scheduled_charging_start_time_minutes":300,"scheduled_departure_time":1673190000,"scheduled_departure_time_minutes":420,"supercharger_session_trip_planner":false,"time_to_full_charge":0.0,"timestamp":1673163916345,"trip_charging":null,"usable_battery_level":46,"user_charge_enable_request":null},"climate_state":{"allow_cabin_overheat_protection":true,"battery_heater":false,"battery_heater_no_power":null,"cabin_overheat_protection":"On","climate_keeper_mode":"off","defrost_mode":0,"driver_temp_setting":18.9,"fan_status":0,"hvac_auto_request":"On","inside_temp":17.2,"is_auto_conditioning_on":null,"is_climate_on":false,"is_front_defroster_on":false,"is_preconditioning":false,"is_rear_defroster_on":false,"left_temp_direction":null,"max_avail_temp":28.0,"min_avail_temp":15.0,"outside_temp":null,"passenger_temp_setting":22.2,"remote_heater_control_enabled":false,"right_temp_direction":null,"seat_heater_left":0,"seat_heater_right":0,"side_mirror_heaters":false,"supports_fan_only_cabin_overheat_protection":false,"timestamp":1673163916344,"wiper_blade_heater":false},"drive_state":{"gps_as_of":1673163599,"heading":137,"latitude":37.55323,"longitude":-122.325874,"native_latitude":37.55323,"native_location_supported":1,"native_longitude":-122.325874,"native_type":"wgs","power":0,"shift_state":null,"speed":null,"timestamp":1673163916345},"gui_settings":{"gui_24_hour_time":false,"gui_charge_rate_units":"kW","gui_distance_units":"mi/hr","gui_range_display":"Rated","gui_temperature_units":"F","show_range_units":true,"timestamp":1673163916345},"vehicle_config":{"can_accept_navigation_requests":true,"can_actuate_trunks":true,"car_special_type":"base","car_type":"models","charge_port_type":"US","dashcam_clip_save_supported":false,"default_charge_to_max":false,"driver_assist":"MonoCam","ece_restrictions":false,"efficiency_package":"Default","eu_vehicle":false,"exterior_color":"SteelGrey","front_drive_unit":"NoneOrSmall","has_air_suspension":true,"has_ludicrous_mode":true,"has_seat_cooling":false,"headlamp_type":"Hid","interior_trim_type":"AllBlack","motorized_charge_port":true,"plg":true,"pws":false,"rear_drive_unit":"Large","rear_seat_heaters":0,"rear_seat_type":1,"rhd":false,"roof_color":"None","seat_type":1,"spoiler_type":"None","sun_roof_installed":1,"third_row_seats":"None","timestamp":1673163916345,"trim_badging":"p85d","use_range_badging":false,"utc_offset":-28800,"wheel_type":"Base19"},"vehicle_state":{"api_version":36,"autopark_state_v2":"ready","autopark_style":"standard","calendar_supported":true,"car_version":"2022.8.10.8 18ef855e49fe","center_display_state":0,"dashcam_clip_save_available":false,"dashcam_state":"<invalid>","df":0,"dr":0,"fd_window":0,"feature_bitmask":"5,0","fp_window":0,"ft":0,"homelink_device_count":2,"homelink_nearby":true,"is_user_present":false,"last_autopark_error":"no_error","locked":true,"media_state":{"remote_control_enabled":true},"notifications_supported":true,"odometer":80514.239922,"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,"smart_summon_available":false,"software_update":{"download_perc":0,"expected_duration_sec":2700,"install_perc":1,"status":"","version":" "},"speed_limit_mode":{"active":false,"current_limit_mph":80.0,"max_limit_mph":90,"min_limit_mph":50.0,"pin_code_set":true},"summon_standby_mode_enabled":false,"sun_roof_percent_open":0,"sun_roof_state":"closed","timestamp":1673163916344,"tpms_pressure_fl":null,"tpms_pressure_fr":null,"tpms_pressure_rl":null,"tpms_pressure_rr":null,"valet_mode":false,"vehicle_name":"My Tesla"}}}
2023-01-07 23:45:27.211 DEBUG (MainThread) [teslajsonpy.controller] Get vehicles. Force: False Time: 14 Interval 60
2023-01-07 23:45:27.211 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online. Polling policy: normal. Update state: trying_to_sleep. Since last park: 79775. Since last wake up: 15027. Idle interval: 600. shift_state: None sentry: None climate: False, charging: None
2023-01-07 23:45:27.211 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: online; Polling policy set to 'normal', trying to sleep; scan throttled to 660 seconds and will ignore updates for 650 seconds
2023-01-07 23:45:27.212 DEBUG (MainThread) [teslajsonpy.controller] 7XXXX: Skipping update with state online. Polling: True. Last update: 10 ago. Last parked: 79775 ago. Last wake up 15027 ago. 
Screenshot 2023-01-07 235913
agehall commented 1 year ago

Noticed the same thing on the latest release - my car is plugged in and currently charging but the integration does not reflect that the car is charging. It is showing that the charger is connected though.

t112013 commented 1 year ago

Hello i experience the same issue. takes lots of time of hassio to get new value while other values do get updated. Doing the force update butten updates it on the second so it gotta be someting else.