Tibber API communication
Posted: 13 Mar 2019 01:29
Hello
I`m trying to figure out if it is possible to integrate a "code device" in zway, from the Tibber API to tell real time power prices.
https://developer.tibber.com/docs/guides/calling-api
I first tried out the "HTTP device", but I couldn`t figure out if it is possible to authorize with a Token instead of basic autorization, so I tried out the "code device" app.
So far I have not managed to get it working because of lakk of programming skills.
I have tested the API with the demo-token in the program "Postman", and get out the numbers I want as a JSON-object. Postman can convert code to a lot of languages, and I have been trying different versions of javascript in the app.
I can see that the "Code device" app specifies the returning value to be a number. Since the Tibber server-response is an JSON object I maybe have to extract the number of interest from the code in a sort of way???
Anyone with programming skills that could help me out with this code?
This is the query of interest:
{ "query": "{viewer {homes {currentSubscription {priceInfo {current {total }}}}}}" }
And this is the return:
{"data":{"viewer":{"homes":[{"currentSubscription":null},{"currentSubscription":{"priceInfo":{"current":{"total":0.5734}}}}]}}}
I want that 0.5734 to be my sensorvalue..
I`m trying to figure out if it is possible to integrate a "code device" in zway, from the Tibber API to tell real time power prices.
https://developer.tibber.com/docs/guides/calling-api
I first tried out the "HTTP device", but I couldn`t figure out if it is possible to authorize with a Token instead of basic autorization, so I tried out the "code device" app.
So far I have not managed to get it working because of lakk of programming skills.
I have tested the API with the demo-token in the program "Postman", and get out the numbers I want as a JSON-object. Postman can convert code to a lot of languages, and I have been trying different versions of javascript in the app.
I can see that the "Code device" app specifies the returning value to be a number. Since the Tibber server-response is an JSON object I maybe have to extract the number of interest from the code in a sort of way???
Anyone with programming skills that could help me out with this code?
This is the query of interest:
{ "query": "{viewer {homes {currentSubscription {priceInfo {current {total }}}}}}" }
And this is the return:
{"data":{"viewer":{"homes":[{"currentSubscription":null},{"currentSubscription":{"priceInfo":{"current":{"total":0.5734}}}}]}}}
I want that 0.5734 to be my sensorvalue..