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:
@@ -149,9 +149,10 @@ async function handleStateChange(newState) {
|
||||
|
||||
log.debug(`State: ${state.previousState} → ${newState}`);
|
||||
|
||||
// Detect arrival: was driving/moving, now parked or charging
|
||||
const wasMoving = ['driving', 'online'].includes(state.previousState);
|
||||
const nowStopped = ['parked', 'charging'].includes(newState);
|
||||
// Detect arrival: was driving, now stationary
|
||||
// TeslaMate states: driving, online, parked, charging, suspended, asleep, offline
|
||||
const wasMoving = state.previousState === 'driving';
|
||||
const nowStopped = ['online', 'parked', 'charging', 'suspended', 'asleep', 'offline'].includes(newState);
|
||||
|
||||
if (wasMoving && nowStopped) {
|
||||
log.info('Arrival detected!');
|
||||
|
||||
Reference in New Issue
Block a user