Tibber Binding

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

Then I have prepared a new version of the binding to be able to handle multiple HomeIds / Pulse. Now the user has to define both Tibber token and Tibber HomeId as part of OpenHab setup. Desired HomeId to be used as input in OpenHab could be found from https://developer.tibber.com/explorer: Sign in with your account, load personal token, and run query as shown below:

{
  viewer {
    homes {
      id
    }
  }
}

Copy and paste HomeId (without quotation marks) into OpenHab setup. Choose desired HomeId/Pulse addon combination.

For users with multiple HomeIds: It would be of great interest to test creating multiple Things in OpenHab, i.e. one Thing per HomeId.

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

1 Like

I can confirm this works perfectly :slight_smile:

Only issue i see is selecting home id, i kinda had to guess they show in order when quiering
https://developer.tibber.com/explorer
{
viewer {
homes {
id
}
}
}

The correct query to be run from https://developer.tibber.com/explorer to identify your HomeId and to see which id has the Pulse associated (realTimeConsumptionEnabled will report true) would be:

{
  viewer {
    homes {
      id
      features {
        realTimeConsumptionEnabled
      }
    }
  }
}

Will update documentation accordingly.

1 Like

New version of the Tibber binding:
https://github.com/kjoglum/openhab2-addons/releases/download/2.0.1/org.openhab.binding.tibber-2.5.0-SNAPSHOT.jar

Improvements:

  • Documentation for pairing HomeId with Pulse (if having multiple HomeIds / Pulse)
  • Verification of valid HomeId before setting Thing ONLINE, and attempting to start live stream if user has defined Pulse as addon
  • Corrections to code to ensure data is retrieved for chosen HomeId only
  • Option for user to add multiple Tibber things, i.e. one Thing per HomeId
  • Updated Readme file explaining how to retrieve token and HomeId (also described in posts above), and example of demo.items to link items to Thing(s)

Note:
If you already are running a version of the Tibber binding, the following approach would be recommended for updating to new version:

  • Delete existing Tibber thing in PaperUI
  • Delete existing jar from addons folder
  • Reboot OpenHab
  • Install new jar file into addons folder (from link above)
  • Install new Tibber Thing(s) in PaperUI
  • Create/link items to Tibber Thing(s)
3 Likes

Outstanding work :slight_smile:

1 Like