diff --git a/run/awake_start b/run/awake_start index 4beb9c00..3fbb502a 100644 --- a/run/awake_start +++ b/run/awake_start @@ -22,16 +22,11 @@ function ping { fi if [[ ( -n "${TESLAFI_API_TOKEN:+x}" ) ]] - # Use TeslaFi API to keep car awake + # Use TeslaFi API to keep car awake. then - if [[ $(curl -s -H "Authorization: Bearer $TESLAFI_API_TOKEN" "https://www.teslafi.com/feed.php?command=wake") = "Wake command received" ]] - then - # TeslaFi's default sleep timer is 15min (900s). No need to contact too often to prevent API lockout (max 3 calls/min). - sleep 600 - else - log "Failed to contact car using TeslaFi API, retrying in 90s..." - sleep 90 - fi + curl -s -H "Authorization: Bearer $TESLAFI_API_TOKEN" "https://www.teslafi.com/feed.php?command=wake_up" + # No need to contact TeslaFi too often to prevent API lockout (max 3 calls/min). + sleep 600 fi done } diff --git a/run/awake_stop b/run/awake_stop index 369aec85..557ef0cc 100644 --- a/run/awake_stop +++ b/run/awake_stop @@ -18,4 +18,11 @@ then log "Stopping wake car background task." kill "$(cat /tmp/keep_awake_task_pid)" || true rm -f /tmp/keep_awake_task_pid + + if [[ ( -n "${TESLAFI_API_TOKEN:+x}" ) ]] + # TeslaFi Sleep command suspends its polling for the next 15 minutes (by default) to faciliate car's sleep. + then + curl -H "Authorization: Bearer $TESLAFI_API_TOKEN" "https://www.teslafi.com/feed.php?command=sleep" + log "also initiated TeslaFi Sleep Mode to give the car a chance to fall asleep." + fi fi