Skip to content

Commit d5784c9

Browse files
committed
Fix car never reverting back from 'charging' re-plugged
1 parent 56bf2be commit d5784c9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

custom_components/tesla_custom/teslamate.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232

3333
CHARGING_STATE_CHARGING = "Charging"
34+
CHARGING_STATE_STOPPED = "Stopped"
3435

3536

3637
def is_car_state_charging(car_state: str) -> bool:
@@ -95,7 +96,9 @@ def cast_plugged_in(val: str, car: TeslaCar) -> str:
9596

9697
if plugged_in:
9798
return (
98-
CHARGING_STATE_CHARGING if is_car_state_charging(car.state) else "Stopped"
99+
CHARGING_STATE_CHARGING
100+
if is_car_state_charging(car.state)
101+
else CHARGING_STATE_STOPPED
99102
)
100103

101104
return "Disconnected"
@@ -366,6 +369,8 @@ async def async_handle_new_data(self, msg: ReceiveMessage):
366369

367370
if is_car_state_charging(state):
368371
self.update_charging_state(car, CHARGING_STATE_CHARGING)
372+
else:
373+
self.update_charging_state(car, CHARGING_STATE_STOPPED)
369374

370375
self.update_car_state(car, None, "state", state)
371376

0 commit comments

Comments
 (0)