-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update awake_start #928
Update awake_start #928
Conversation
This is for using TeslaFi to keep your car awake with sentry mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be combined into a single PR with #927 and include a change to the sample config file that explains the new TESLAFI_WAKE_MODE setting
http_response=$(curl -s -w "%{http_code}" \ | ||
-H "Authorization: Bearer $TESSIE_API_TOKEN" \ | ||
-H "Accept: application/json" \ | ||
-H "User-Agent: github.com/marcone/teslausb" \ | ||
"https://api.tessie.com/$TESSIE_VIN/wake") | ||
|
||
# Extract HTTP status code | ||
http_status="${http_response: -3}" | ||
|
||
# Extract response body (excluding status code) | ||
response_body="${http_response:0:${#http_response}-3}" | ||
|
||
# Check if HTTP status code is not 200 (OK) | ||
if [ "$http_status" != "200" ] | ||
then | ||
# Log an error | ||
log "Failed to wake car with Tessie API. Check your TESSIE_API_TOKEN and TESSIE_VIN are set correctly. If they are, your car may not have a good connection. Retrying in 1 minute..." | ||
sleep 60 | ||
else | ||
# Check if the response is in JSON format | ||
if ! jq -e . >/dev/null 2>&1 <<<"$response_body" | ||
then | ||
# Log an error | ||
log "Failed to wake car with Tessie API. Check your TESSIE_API_TOKEN and TESSIE_VIN are set correctly. If they are, your car may not have a good connection. Retrying in 1 minute..." | ||
sleep 60 | ||
log "Failed to wake car with Tessie API. Retrying in 1 minute. Response data: $response_body" | ||
sleep 60 | ||
else | ||
# Check if the response is in JSON format | ||
if ! jq -e . >/dev/null 2>&1 <<<"$response_body" | ||
then | ||
log "Failed to wake car with Tessie API. Retrying in 1 minute. Response data: $response_body" | ||
sleep 60 | ||
else | ||
# Parse JSON and check if "result" is true | ||
result=$(jq -r '.result' <<<"$response_body") | ||
if [[ "$result" != "true" ]] | ||
then | ||
log "Failed to wake car with Tessie API. Retrying in 1 minute. Response data: $response_body" | ||
sleep 60 | ||
else | ||
# Sleep for 5 minutes on successful wake-up call | ||
sleep 300 | ||
fi | ||
fi | ||
# Parse JSON and check if "result" is true | ||
result=$(jq -r '.result' <<<"$response_body") | ||
if [[ "$result" != "true" ]] | ||
then | ||
log "Failed to wake car with Tessie API. Retrying in 1 minute. Response data: $response_body" | ||
sleep 60 | ||
else | ||
# Sleep for 5 minutes on successful wake-up call | ||
sleep 300 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
large whitespace changes should go in a separate PR.
touch /tmp/disable_sentry_after_archiving | ||
/root/bin/tesla_api.py enable_sentry_mode &>> "${LOG_FILE}" | ||
# Check if TESLAFI_WAKE_MODE is set to sentry | ||
if [ "$TESLAFI_WAKE_MODE" == "sentry" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TeslaUSB coding style is to put "then" on the next line.
# Check if TESLAFI_WAKE_MODE is set to sentry | ||
if [ "$TESLAFI_WAKE_MODE" == "sentry" ]; then | ||
log "Turning on Sentry Mode to keep car awake (via TeslaFI)." | ||
set_sentry_mode true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will only be called if TESLA_WAKE_MODE is also set to "sentry", and the condition on line 85 is true, which makes no sense because:
- it will always be true because the API that that uses no longer works
- even if it did, it would then require configuring the Tesla API variables in the config file, and the config specifically says to only use one of the APIs
This new TeslaFi code should be separate, and should use the TeslaFi API to determine whether sentry mode is already on.
fi | ||
;; | ||
stream) | ||
log "Starting background task to keep car awake." | ||
log "Starting background tasks to keep TeslaUSB powered on during archiving." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change this log message, and specifically why did you pluralize "task" to "tasks" when there's only one background task?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There does need to be some changes. I do hope that people more knowledgeable like yourself can incorporate those changes. I do appreciate you looking further at this.
superseded by #936 |
You can use my repo in the config file. I believe you just change it to "jjermany/teslausb-1". It's towards the bottom of the teslausb_setup_variables.conf file. Once you change it to my fork of the repo you can run the upgrade command and it should update it to my awake scripts. |
@miles267 nevermind. I tried using my own repo and it failed every single time. I do not think that functionality works. |
It should work, what exactly did you set the |
Is there a reason not to merge this PR into the main branch? I’m glad to help test it. |
Got it to work by just using jjermany |
I may end up having to ditch this project. My Tesla Dashcam keeps switching to unavailable and is just not reliable. 2020 Model 3. Driving me nuts not being able to even rely on it. So I suppose ill fork some cash and just buy a decent 3rd party dash cam. No fault to the project, just my tesla sucks. Can drive itself but cannot mount storage properly, crazy stuff.. My repo should be good for people who want to utilize TeslaFi to keep the car awake. Ill keep it there for those want to go that route. |
This is for using TeslaFi to keep your car awake with sentry mode.