Page 1 of 1

Tibber API communication

Posted: 13 Mar 2019 01:29
by alphons

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.

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:


I want that 0.5734 to be my sensorvalue..:-)

Re: Tibber API communication

Posted: 14 Mar 2019 23:26
by alphons
Found a workaround to make a device showing live price with the JSON vdev Creator.
The only problem now is that the z-way interface is showing only one decimal precison for the value.
I would like to have 2 decimals for this virtual device. Is it possible to change this somehow?

Re: Tibber API communication

Posted: 16 Mar 2019 12:27
by PoltoS
You can modify the UI. It is the UI doing it

Re: Tibber API communication

Posted: 16 Mar 2019 19:37
by alphons
Is it a setting in UI?
Or do you know which file I have to take a look into to modifie this code?

Re: Tibber API communication

Posted: 17 Mar 2019 15:56
by alphons
Found another solution parsing the value of interest with jq from the json to another file multiplying it with 100 before collecting it into zway.