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}`);
|
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!');
|
||||||
|
|||||||
Reference in New Issue
Block a user