Tibber.com API call - help with authorization.

Avatar
  • updated

Hi.

I'm trying to reach my electricity company through their public API.

I'm able to use the POST field in the command to get a response but a layer of authorization is required.


Is anyone able to point me in the right direction on how to incorporate the authorization token in my call?

This call gives me a response (from their examples)

call:

{
"query": "{ viewer { name }}"
}

response:

{"data":null,"errors":[{"message":"No valid access token in request","locations":[{"line":1,"column":3}],"path":["viewer"],"extensions":{"code":"INTERNAL_SERVER_ERROR"}}]}


Documentation:

https://developer.tibber.com/docs/guides/calling-api


Any help is appreciated

Avatar
Joachim O
Quote from Geir Hardt

Hi Joachim

I am struggling with the same issue. 

Have you found a way to set up bOS to receive the power datastream from Tibber?


Until now I have worked around this by using a Raspberry PI to read and convert HAN Data, before writing a subset of the data to bOS with RPC. However, more information is available from Tibber (accumulated cost, hourly price etc) than through the HAN ports, which makes me prefer the Tibber subscription stream data,  (could of course set up the PI to read the datastream, and forward to bOS using RPC, but I would like to get rid of the extra components).

Anyone have had some success with the Tibber live measurement through WSS (Web Socket Subscription)?


@Geir? @Comfortclick?


With the current electricity prices this is more relevant than ever.🤯

Avatar
Joachim O

Hi. Sorry for my late answer. I'm not any closer to resolve this issue. I was hoping that the dev team would pick up on this post and get WSS to work.

The data not received from the HAN port i was able to get from their API. Hourly price etc was OK. Stopped working after a while for some reason and I haven't done anything more with it.

Avatar
Geir Hardt

Hi Joachim

I am struggling with the same issue. 

Have you found a way to set up bOS to receive the power datastream from Tibber?


Until now I have worked around this by using a Raspberry PI to read and convert HAN Data, before writing a subset of the data to bOS with RPC. However, more information is available from Tibber (accumulated cost, hourly price etc) than through the HAN ports, which makes me prefer the Tibber subscription stream data,  (could of course set up the PI to read the datastream, and forward to bOS using RPC, but I would like to get rid of the extra components).

Avatar
Joachim O

Tanks for your effort @Fabien Fuster!

@bOS team: Please look into this or at least take the time to give an answer on your forum.

Avatar
Fabien Fuster

Hi Joachim

So far, I was not able to get it to wotk with wss connection. All data can be collected under normal http API, but not the subscription data. 

@ bOS team : can you let us know if wss connection are even possible ?

I will do further test through other way and see if I get it to work. Also, I didn't find a way through MQTT neither, except for the standard http API info.

Regards

Avatar
Fabien Fuster

Well, I didn't realize it is through wss. Not sure it is supported by bOS, but will make some tests....

Avatar
Joachim O

How do I shape the request in the "bOS command" as it's not supposed to poll every 300 sec but be connected to a web socket subscription address? 

wss://api.tibber.com/v1-beta/gql/subscriptions

demo token:

d1007ead2dc84a2b82f0de19451c5fb22112f7ae11d19bf2bedb224a003ff74a

demo subscription:

subscription{
liveMeasurement(homeId:"68e6938b-91a6-4199-a0d4-f24c22be87bb"){
timestamp
power
accumulatedConsumption
accumulatedCost
currency
minPower
averagePower
maxPower
}
}

Avatar
Fabien Fuster

Hi Joachim,


The easiest is to use the JSON answer token value directly in bOS.

I'm using http://jsoneditoronline.org/ to help me identifying the correct token "adress".

If you have difficulties, please copy/paste here the full above demo token in text format and I'll try to help you .

Regards,

Avatar
Joachim O

Following this topic. I have now installed my live consumption meter. Accessing its data requires me to subscribe to the data via web socket. 


from https://developer.tibber.com/docs/guides/calling-api:

wss://api.tibber.com/v1-beta/gql/subscriptions


Some demo values:

Another alternative is to use MQTT. Is any of this possible with bOS?

BR
Joachim

Avatar
Fabien Fuster

Happy to read it made the trick  ;-)