Tibber API communication

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
alphons
Posts: 27
Joined: 18 Dec 2015 21:26

Tibber API communication

Post by alphons » 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..:-)

alphons
Posts: 27
Joined: 18 Dec 2015 21:26

Re: Tibber API communication

Post by alphons » 14 Mar 2019 23:26

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?

User avatar
PoltoS
Posts: 4978
Joined: 26 Jan 2011 19:36

Re: Tibber API communication

Post by PoltoS » 16 Mar 2019 12:27

You can modify the UI. It is the UI doing it

alphons
Posts: 27
Joined: 18 Dec 2015 21:26

Re: Tibber API communication

Post by alphons » 16 Mar 2019 19:37

Is it a setting in UI?
Or do you know which file I have to take a look into to modifie this code?

alphons
Posts: 27
Joined: 18 Dec 2015 21:26

Re: Tibber API communication

Post by alphons » 17 Mar 2019 15:56

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.

Post Reply