Skip to content

Instantly share code, notes, and snippets.

@rfvgyhn
Last active August 7, 2019 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfvgyhn/55c146dcc2615261e004c28cc987a425 to your computer and use it in GitHub Desktop.
Save rfvgyhn/55c146dcc2615261e004c28cc987a425 to your computer and use it in GitHub Desktop.
#!/bin/bash
action=${1:-resume}
case "$action" in
resume) action_past_tense="resumed" ;;
suspend) action_past_tense="suspended" ;;
*) echo "Invalid argument. Specify resume (default) or suspend" ; exit 2
esac
echo "Enter db password:"
readarray -t lines <<< $(keepassxc-cli show /path/to/db.kdbx teslamate-web -q -a UserName -a Password)
status=$(curl -X PUT -s -o /dev/null -w "%{http_code}" --url "https://yourdomain.com/api/car/1/logging/resume" -K- <<< "user = ${lines[0]}:${lines[1]}")
[[ $status -eq 204 ]] && echo "Logging $action_past_tense" || echo "Error: HTTP $status"
try
{
$domain = "https://yourdomain.com"
$vehicleId = 1
$args = @{
#Credential = Get-Credential -Message $domain # Uncomment if your server uses basic auth
Uri = "$domain/api/car/$vehicleId/logging/resume"
Method = "PUT"
ErrorAction = "Stop"
}
Invoke-WebRequest @args *>$null
"Success: Logging resumed"
}
catch
{
$statusCode = $_.Exception.Response.StatusCode.value__
$statusReason = $_.Exception.Response.StatusDescription
"Error: $statusCode - $statusReason"
"Press any key to continue..."
[void][System.Console]::ReadKey($true)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment