fix: detect all stationary states for arrival notifications

TeslaMate uses multiple states for parked cars: online, parked, charging,
suspended, asleep, offline. Previously only 'parked' and 'charging' were
detected, causing missed arrival notifications when car went directly to
'online' or 'suspended' state.
This commit is contained in:
Clawd
2026-01-28 19:43:00 +00:00
parent 9b1d496e13
commit 97f8eee507

View File

@@ -149,9 +149,10 @@ async function handleStateChange(newState) {
log.debug(`State: ${state.previousState}${newState}`); log.debug(`State: ${state.previousState}${newState}`);
// Detect arrival: was driving/moving, now parked or charging // Detect arrival: was driving, now stationary
const wasMoving = ['driving', 'online'].includes(state.previousState); // TeslaMate states: driving, online, parked, charging, suspended, asleep, offline
const nowStopped = ['parked', 'charging'].includes(newState); const wasMoving = state.previousState === 'driving';
const nowStopped = ['online', 'parked', 'charging', 'suspended', 'asleep', 'offline'].includes(newState);
if (wasMoving && nowStopped) { if (wasMoving && nowStopped) {
log.info('Arrival detected!'); log.info('Arrival detected!');