Ausgelagertes Gedächtnis:
#!/bin/bash
# CURL zum Tibber API Abruf
CURL (){
QUERY_BODY="{ \"query\":\"{viewer {homes"
RESULT=$(curl \
-H "Authorization: Bearer ++++hier+++den+++bearer+++code+++einfuegen" \
-H "Content-Type: application/json" \
-X POST \
-d "${QUERY_BODY}${QUERY}" \
https://api.tibber.com/v1-beta/gql)
}
c_subscription() {
QUERY="{currentSubscription {priceInfo {current {total energy tax startsAt }}}}}}\" }"
CURL
echo $RESULT |jq '.data.viewer.homes|.[].currentSubscription."priceInfo".current.total'
}
cd_subscription() {
QUERY="{currentSubscription {priceInfo { today { \
total \
energy \
tax \
startsAt \
}}}}}}\" }"
CURL
echo $RESULT |jq '.data.viewer.homes|.[].currentSubscription."priceInfo"."today"|.[].total'
}
t_subscription() {
QUERY="{currentSubscription {priceInfo { tomorrow { \
total \
energy \
tax \
startsAt \
}}}}}}\" }"
CURL
echo $RESULT |jq '.data.viewer.homes|.[].currentSubscription."priceInfo"."tomorrow"|.[].total'
}
consumption(){
QUERY="{consumption(resolution: HOURLY, last: 100) { \
nodes {\
from\
to\
cost\
unitPrice\
unitPriceVAT\
consumption\
consumptionUnit\
}\
}\
}\
}\
}\" }"
CURL
echo $RESULT |jq '.data.viewer.homes|.[].consumption.nodes|.[]|"from: ", .from, "Aktuelle Kosten: ", .cost'
}
adress(){
QUERY="{address { \
address1\
address2\
address3\
postalCode\
city\
country\
latitude\
longitude\
}\
}\
}\
}\" }"
CURL
echo $RESULT |jq '.data.viewer.homes|.[]."address"|"Strasse: ",."address1", "PLZ: ", ."postalCode"'
}
###### Program Start ######
[ $# -eq 0 ] && usage
echo "$date $time Programm Aufruf $arg" >> $logfile
while getopts csatd arg; do
case $arg in
#-i: Last IP-Octet
#-s: Status
#-c: Connect
#-w: heat up
#-t: current temperature
#-r: automatic retract
#-h: Help
#-a: Target Head
#-l: list_files
#-p: pause program
s)
c_subscription
;;
d)
cd_subscription
;;
t)
t_subscription
;;
c)
consumption
;;
a)
# silent
adress
;;
esac
done
exit 0
An Tibber haben wir schon ziemlich intensiv gearbeitet, was dann hier zu finden ist. (https://forum.fhem.de/index.php?topic=130407.0)