Tronity

#!/bin/bash
TOKEN=$( curl -s --connect-timeout 2 --location 'https://api.tronity.tech/authentication' --header 'Content-Type: application/json' --data '{ "client_id": "Client-ID", "client_secret": "Client-Secret", "grant_type": "app" }' | jq .access_token |sed s/"\""//g )
RESULT=echo "curl -s --connect-timeout 2 --location 'https://api.tronity.tech/tronity/vehicles/' --header 'Content-Type: application/json' --header 'Authorization: Bearer $TOKEN'"|bash
ID=echo $RESULT|jq .data[].id|sed s/"\""//g
echo $ID
RESULT=echo "curl -s --connect-timeout 2 --location 'https://api.tronity.tech/tronity/vehicles/$ID' --header 'Content-Type: application/json' --header 'Authorization: Bearer $TOKEN'"|bash
echo $RESULT|jq .
LAST_RESULT=echo "curl -s --connect-timeout 2 --location 'https://api.tronity.tech/tronity/vehicles/$ID/last_record' --header 'Content-Type: application/json' --header 'Authorization: Bearer $TOKEN'"|bash
ODOMETER=echo $LAST_RESULT|jq .odometer
RANGE=echo $LAST_RESULT|jq .range
LEVEL=echo $LAST_RESULT|jq .level
CHARGING=echo $LAST_RESULT|jq .charging
PLUGGED=echo $LAST_RESULT|jq .plugged
CHARGEPWR=echo $LAST_RESULT|jq .chargerPower
CHARGETIME=echo $LAST_RESULT|jq .chargeRemainingTime
LAT=echo $LAST_RESULT|jq .latitude
LON=echo $LAST_RESULT|jq .longitude
STATUS=echo $LAST_RESULT|jq .status
UTIME=echo $LAST_RESULT|jq .timestamp
UTIMETMP=${UTIME:0:10}
TIME=date -d @$UTIMETMP
ULAST=echo $LAST_RESULT|jq .lastUpdate
ULASTTMP=${ULAST:0:10}
LAST=date -d @$ULASTTMP
echo "Kilometerstand $ODOMETER km"
echo "Reichweite $RANGE km"
echo "Fuellstand $LEVEL %"
echo "Laedt $CHARGING"
echo "Angschlossen $PLUGGED"
echo "Ladestrom $CHARGEPWR"
echo "restliche Ladedauer $CHARGETIME"
echo "Breite $LAT"
echo "Laenge $LON"
echo "Status $STATUS"
echo "Zeitstempel $TIME"
echo "letztes Update $LAST"
LAST_CHARGES=echo "curl -s --connect-timeout 2 --location 'https://api.tronity.tech/tronity/vehicles/$ID/charges' --header 'Content-Type: application/json' --header 'Authorization: Bearer $TOKEN'"|bash
echo $LAST_CHARGES|jq .


Beitrag veröffentlicht

in

von

Schlagwörter: