Tibber Binding

I only have the electricity contract from tibber, but the binding shows a home id so I think you’re good. But of course i don’t know if it’s my “real” home Id

@Steinar_Gradal

Strange, regardless you should be able to provide personal token for initialization. From PaperUI, after trying to install new Thing (+), which of the below steps are not possible for you? Have you tried rebooting OpenHab?

  1. Choose binding to install new thing from

  2. Choose thing

  3. Configure thing

@kosken

Appreciate the testing and response you provide.

The fact that you get homeID means you are having one, and it is correct. Binding is set up to retrieve JsonObject “id”, and the fact that you get homeID as a channel means it is correctly retrieved.

The reason for the “Handler_Initializing_Error” could be a result of a bug within the binding. What I have realized myself: The binding is set up to set thing OFFLINE / handle exceptions (errors). I did however not prepare the binding to handle events where queries are timed out from Tibber. So I have seen my Thing become OFFLINE, although response/data have been retrieved still.

A couple ot things to try:

  1. Enable debug (from OH console, log:set debug org.openhab.binding.tibber)
    This will show you the actual response from Tibber every “refresh_time_interval” you have set. If response keeps coming in from log, your data is tracked even if Thing is defined as UNINITALIZED / OFFLINE. Will off course follow up this bug.
  2. Have you tried to delete Tibber Thing and reinstalled it in PaperUI?

My bad, restart openhab an i can create the Thing and everyting is working.

As a sidenote for other users, i am on Openhab 2.4 stable and i had to install a a newer version of gson.

bundle:install http://central.maven.org/maven2/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar

1 Like

I downloaded the latest .jar file and it started to work. I’ll keep an eye on it to see how it works. Will start to persist the hourly prices as well so it’s easy to see when things stopped working (if they do). Great binding!

1 Like

Then I have a new version of the binding, now also enabling live measurements (Tibber Pulse is required), and would appreciate if others also could test. Features:

  • Bug fix for initial contribution (price/consumption queries)
  • Added functionality for live measurements for Tibber Pulse users (websocket stream)

JAR file
https://github.com/kjoglum/openhab2-addons/releases/download/2.0.0/org.openhab.binding.tibber-2.5.0-SNAPSHOT.jar

README
Readme

NOTE:
To enable live measurements (Tibber Pulse users only), the user need to manually set “Pulse” as addon as part of configuration in PaperUI (shown below).

Users not having Tibber Pulse need to set Addon “None”, and will still retrieve query based price/consumption data.

Thank you so much for this great binding!
I’ve installed the latest jar, and linked all channels. Everything seems to update and play fine, but i see these warnings in my logs every 5-10sec:

2019-11-26 19:44:20.271 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel current_total although the handler was already disposed.

2019-11-26 19:44:20.272 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel current_startsAt although the handler was already disposed.

2019-11-26 19:44:20.391 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel daily_from although the handler was already disposed.

2019-11-26 19:44:20.392 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel daily_to although the handler was already disposed.

2019-11-26 19:44:20.392 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel daily_cost although the handler was already disposed.

2019-11-26 19:44:20.393 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel daily_consumption although the handler was already disposed.

2019-11-26 19:44:20.511 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel hourly_from although the handler was already disposed.

2019-11-26 19:44:20.511 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel hourly_to although the handler was already disposed.

2019-11-26 19:44:20.511 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel hourly_cost although the handler was already disposed.

2019-11-26 19:44:20.512 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel hourly_consumption although the handler was already disposed.

2019-11-26 19:44:20.512 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler tried updating the thing status although the handler was already disposed.
2019-11-26 19:49:54.476 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel live_power although the handler was already disposed.

2019-11-26 19:49:54.476 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel live_lastMeterConsumption although the handler was already disposed.

2019-11-26 19:49:54.477 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel live_accumulatedConsumption although the handler was already disposed.

2019-11-26 19:49:54.477 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel live_accumulatedCost although the handler was already disposed.

2019-11-26 19:49:54.478 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel live_currency although the handler was already disposed.

2019-11-26 19:49:54.478 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel live_minPower although the handler was already disposed.

2019-11-26 19:49:54.478 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel live_averagePower although the handler was already disposed.

2019-11-26 19:49:54.479 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler TibberHandler of thing tibber:tibberapi:9889a531 tried updating channel live_maxPower although the handler was already disposed.

I have pulse installed, and enabled in the binding config.

Appreciate the response.

I actually encountered the same issue, so maybe you did the same as me: Just replacing jar / rebooting OpenHab without deleting existing Tibber API Thing first…?

The sequence of events which seem to work (if already having the Tibber binding running):

  • Delete existing Tibber API from PaperUI Things to get a correct close / disposal.
  • Reboot OpenHab (with the new jar file in the addons folder)
  • Create new Tibber API Thing in PaperUI (now a new/fresh connection should be made, without the "handler disposed" warnings)
  • Link all channels (probably needed to link again as a new Thing ID is generated)
1 Like

Seems to be getting along quite nicely (besides a couple of shut downs on my own behalf):

@Ontrackx @Danonym1

And for information, I have created a pull request towards OpenHab master:

Holy crap, it has been so long time since Ive looked into this. Haha is the bounty still up?

Apparently.

Regardless, the main intention was to generate a working Tibber binding for OpenHab.

Wow, Great!
I Will be testing this at the first available time :blush:

Then you are entiteled for reciveing the bounty, will look into this later

Error while starting bundle: file:/C:/openhab-2.4.0/addons/org.openhab.binding.tibber.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.tibber [292]
Unresolved requirement: Import-Package: com.google.gson; version="[2.8.0,3.0.0)"

    at org.eclipse.osgi.container.Module.start(Module.java:444) ~[?:?]
    at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[?:?]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [10:org.apache.felix.fileinstall:3.6.4]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [10:org.apache.felix.fileinstall:3.6.4]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [10:org.apache.felix.fileinstall:3.6.4]
    at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(

From post above: Link, there is a link to the README file which explains what has to be done if error related to gson is occurring during initialization.

From openhab/karaf console, run:
bundle:install http://central.maven.org/maven2/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar

Then you should be able to initialize the binding.

19:57:04.664 [INFO ] [tibber.internal.handler.TibberHandler] - Connecting to: wss://api.tibber.com/v1-beta/gql/subscriptions
19:57:05.026 [INFO ] [tibber.internal.handler.TibberHandler] - Connected to Server
19:57:05.175 [WARN ] [tibber.internal.handler.TibberHandler] - WebSocket Connection closed due to Connection error
19:57:05.238 [WARN ] [tibber.internal.handler.TibberHandler] - Closing a WebSocket due to Disconnected
19:57:13.256 [INFO ] [tibber.internal.handler.TibberHandler] - Connecting to: wss://api.tibber.com/v1-beta/gql/subscriptions
19:57:13.534 [INFO ] [tibber.internal.handler.TibberHandler] - Connected to Server
19:57:13.672 [WARN ] [tibber.internal.handler.TibberHandler] - WebSocket Connection closed due to Connection error
19:57:13.737 [WARN ] [tibber.internal.handler.TibberHandler] - Closing a WebSocket due to Disconnected

Hmm can there be a problem when the user has multiple homes in tibber?

Based on your log, you get connected, but as part of connection_init request to actually start data stream, Tibber API responds with error in its first response message. This would point in the direction of incorrect token used in the setup.

However, the binding might not be set up to handle multiple homes, so for sure, this could be an issue.

From https://developer.tibber.com/explorer, if you log in and “load personal token”, how many id´s are listed if you try to run the query below?

{
  viewer {
    homes {
      id
    }
  }
}

Also, using “personal token”, choosing “Real time subscription” from dropdown menu, what is the result when running subscription (see my example below)?

Someting is probably screwy with multiple homes