Skip to content

Commit a260955

Browse files
author
Nick Sullivan
committed
🐛 Fix car driving check to allow zero speed
Update the speed check in both autovent.py and peakoff.py to consider a speed of 0 as stationary, not just when speed is None. This prevents false "car is driving" errors when the vehicle is stopped but reporting zero speed.
1 parent 9d0596c commit a260955

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

autovent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def autovent(vin, tessie_token, vent_temp, notify_phone):
4141

4242
### Conditional checks, all of these must pass to continue
4343
try:
44-
tessie.check_state("drive_state", "speed", lambda v: v is None, "Car is driving 🛞")
44+
tessie.check_state("drive_state", "speed", lambda v: v is None or v == 0, "Car is driving 🛞")
4545
tessie.check_state("vehicle_state", "is_user_present", lambda v: not v, "Someone is in the car 🙆")
4646
except ValueError as e:
4747
logger.warning(f"🛑 Halting: {e}")

peakoff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def peakoff(vin, tessie_token, peak_start, peak_end, notify_phone, low_battery_t
2929
lambda v: arrow.get(v) > arrow.utcnow().shift(hours=-3),
3030
"API data is stale, which means the car is either asleep or out of internet range",
3131
)
32-
tessie.check_state("drive_state", "speed", lambda v: v is None, "Car is driving 🛞")
32+
tessie.check_state("drive_state", "speed", lambda v: v is None or v == 0, "Car is driving 🛞")
3333
tessie.check_state("charge_state", "charge_port_door_open", lambda v: v, "Charge cable is not plugged in")
3434
tessie.check_state("charge_state", "charging_state", lambda v: v != "Complete", "Charging is complete ✅")
3535
tessie.check_state("charge_state", "charge_limit_soc", lambda v: v < 100, "User requested charging to 100%")

0 commit comments

Comments
 (0)