Tibber Binding

I agree if I’m the only one having these problems, this may be locally related. However, out of my 337 things in total, the Tibber live items are the only ‘troublemakers’ right now. Please be ensured that I am very very thankful for your effort and everyone else making OH to what it is today and all the functionalities that it provides.
I’ll be on vacation next week and need the Pulse data to be rock solid feeding my rules during the absence. Therefore I switched to IO Broker and MQTT for acquiring the data. Happy to investigate further after my vacation.

EDIT: in the future it may also help to have some more debug-information to solve situations like this.

Actual status of my configuration:
As far as I can see, everything went well with aquiring data via IO Broker / MQTT for the week of my absence. No interruptions.
I stopped my OH installation last Sunday, deleted tmp / cache directory, switched to the Tibber API binding, deactivated the IO Broker instance and started OH again.

After one week, the results are 5 outages where all outages could have been recovered by automatically restarting the Tibber API thing.

Until now, the “thing-restart-workaround” is still needed for my configuration.

Not directly connected with this binding but maybe of interest for other users:

As the Tibber Pulse is using the optical interface to my energy meter, I had to migrate away from the current DSMR solution to a local Pulse-querying solution.

I came up with https://github.com/cribskip/pulse2mqtt/blob/main/pulse2mqtt.py

After setting the pulse up for the webserver to be always enabled, not just for setup, it is possible to query the data the pulse sends to tibber. This python script polls this data, transforms it and publishes it to a local MQTT broker.

Have fun,
Sascha

2 Likes

I keep getting warnings like this every few seconds

2024-04-01 16:01:08.255 [WARN ] [org.openhab.core.thing.binding.BaseThingHandler ] - Handler TibberHandler of thing tibber:tibberapi:tibberAPI tried updating channel live_accumulatedProduction although the handler was already disposed.

and it seems I’m not the only one.

@kjoglums have you seen [tibber] Handler TibberHandler of thing tibber:tibberapi:tibberAPI tried updating channel live_accumulatedProduction although the handler was already disposed · Issue #16560 · openhab/openhab-addons · GitHub ?

@kjoglums Stian sorry for bothering, but did you read this one ?

Hello, I have two points.

  1. Is it possible to query the current total monthly costs?

  2. from time to time the binding hangs so that no current data is retrieved. After disabling/enabling the bridge, the data is retrieved again.

OH: 4.1.2
Binding: 4.1.2
Persist: InfluxDB + MapDB

at night

2024-05-14 00:10:05.675 [WARN ] [ibber.internal.handler.TibberHandler] - IO Exception: java.util.concurrent.TimeoutException: Total timeout 20000 ms elapsed
2024-05-14 00:28:57.997 [WARN ] [ibber.internal.handler.TibberHandler] - IO Exception: java.util.concurrent.ExecutionException: java.io.EOFException: HttpConnectionOverHTTP@18c12cf1::DecryptedEndPoint@5ee0c315{l=/172.28.10.2:58856,r=api.tibber.com/52.48.54.122:443,OPEN,fill=-,flush=-,to=360038/0}

after disable/enable

2024-05-14 07:01:00.682 [WARN ] [core.thing.internal.ThingManagerImpl] - Initializing handler for thing 'tibber:tibberapi:Tibber' takes more than 5000ms.

Edit:

2 Likes

@kjoglums haven’t read from you since mid of April, I hope you’re alive and well ?

Could you please have a look after the messages in post #285 ? Thank you.

1 Like

since switching to OH4.2 I’ll get timeseries log entries, even though the value of the “current price”-item did not change. Every minute that is. It’s filling up my log, so is it possible to change that in the binding to only log timeseries information, if the value received changed?
see the parallel thread here:

Also using the Tibber binding and got these log messages every minute. I agree it should only update the (forecast) item in case of a changed value. You can reduce the logging however by setting the update interval in the item configuration to a higher value so it will only log at the requested interval. Energy prices get update once a day anyway.

I am very happy actually that the binding supports forecasting now so I can display future values in graphs and make calculations based upon look-ahead energy prices :slight_smile: ! Works great with in memory persistence.

i just filed a feature request/improvement on github:

to add more context:
this was the origin, that I got too many events.log entries:

and then I changed the “refresh interval” to 25 minutes, which led to the behaviour, that all non-live channels refreshed “randomly”, but not “on the hour”:

So my suggestion is to change all the hour-related channels “on the hour” as described in the github-issue.

Hi there,
I have a problem with the Tibber Binding for the last few months. I have not found a solution to it yet. The problem is that the binding freezes and the current energy usage is not updated. This happens almost every 24 hours, although sometimes it takes a little longer. My current refresh interval in the binding is now 25 minutes. At first, I thought the Tibber API was hanging up. However, this should not happen with 100 requests every five minutes per IP address. Restarting the binding manually once a day makes it work again for a while. Can somebody help me? A work around would be that I restarted the binding every 12 hours to make sure it also will work. But I did not figure out how it will be done from a openhab rule. Thank you for your help.

1 Like

I also have that problem since a few months, and there’s no solution to this in the binding yet:

What I do is checking every hour at 20sec past the hour, if the lastUpdate was successful, otherwise restart the binding:

var interval25sec = time.toZDT('PT-25s');
var tibberLastUpdate = items.getItem("TIB_Current_StartsAt").persistence.lastUpdate('jdbc');

if (tibberLastUpdate.isBeforeDateTime(interval25sec)) {
  // no current Tibber information => restart binding
  console.warn("WARN: Tibber binding to be restarted! No new prices available");
  things.getThing('tibber:tibberapi:pl12').setEnabled(false);
  java.lang.Thread.sleep(250);
  things.getThing('tibber:tibberapi:pl12').setEnabled(true);
  console.info("INFO Tibber: Tibber Binding was restarted.");
}

Usually it is sufficient to disable/reenable the tibber API Thing in OH.
You can do that from a rule if the price didn’t change with the hour.

@binderth Thank you! I had a similar idea before. But what language do you use there? Do I need to import any additional packages before applying the rule? Could you send me the full rule? I don’t know OH that well.

That’s JS Scripting with “ECMAScript 262 Edition 11”. My rule does some more than that, but I just drilled it down to restarting the thing.
Bear in mind, you have to change the ID to your thing and the name of one of Tibber bindings items, i choose the one connected to the current_startsAt (DateTime) channel:

  • TIB_Current_StartsAt => name of my item
  • tibber:tibberapi:pl12 => ID of the tibber-thing
  • also: I’m using both jdbc and rrd4j as persistence and found out, that jdbc is more reliable even if you’re checking for >10secs. rrd4j is sometimes a few secs behind. If you’re not using jdbc, just leave the argument blank as in: var tibberLastUpdate = items.getItem("TIB_Current_StartsAt").persistence.lastUpdate();
configuration: {}
triggers:
  - id: "1"
    configuration:
      cronExpression: 20 0 * * * ? *
    type: timer.GenericCronTrigger
  - id: "3"
    configuration:
      startlevel: 100
    type: core.SystemStartlevelTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      type: application/javascript
      script: >
        // chech, if Current-Price is really current?
		var interval25sec = time.toZDT('PT-25s');
		var tibberLastUpdate = items.getItem("TIB_Current_StartsAt").persistence.lastUpdate('jdbc');

		if (tibberLastUpdate.isBeforeDateTime(interval25sec)) {
		  // no current Tibber information => restart binding
		  console.warn("WARN: Tibber binding to be restarted! No new prices available");
		  things.getThing('tibber:tibberapi:pl12').setEnabled(false);
		  java.lang.Thread.sleep(250);
		  things.getThing('tibber:tibberapi:pl12').setEnabled(true);
		  console.info("INFO Tibber: Tibber Binding was restarted.");
		}

If you don’t want to switch to JS Scripting, but use DSL als rule engine, there’s a pretty recent post for this: Disable/Enable Thing with Rule (The name 'Java' cannot be resolved to an item or type)

Thank you @binderth. I just learn how to setup JS scripts. And I changed your code to

console.warn(WARN: Tibber binding to be restarted! No new prices available);
things.getThing(‘tibber:tibberapi:pl12’).setEnabled(false);
java.lang.Thread.sleep(250);
things.getThing(‘tibber:tibberapi:pl12’).setEnabled(true);
console.info(INFO Tibber: Tibber Binding was restarted.);

I run this every hour without the if function. But what is that:

var interval25sec = time.toZDT(‘PT-25s’);

I always get a failure in the log file

2025-05-14 21:49:37.980 [ERROR] [.handler.AbstractScriptModuleHandler] - Script execution of rule with UID ‘Restart_Tibber’ failed: org.graalvm.polyglot.PolyglotException: TypeError: null has no such function “isBeforeDateTime”

please change the names/IDs of the item, you’d like to monitor and the thing, you copied at least the ID of my tibber-thing, which I named “pl12”, you sure have another name for it:

Tipp: please play around with the documentation of how the basic principles of openHAB work, this is one of the very basic things you should be aware of!

The stability issue is bothering me and I try to resolve it without presenting some rules. See this thread in order to resolve it plus providing some useful hints for the next OH5 Tibber binding!

1 Like

I solved it now. Now it is a combination from a normal rules:

rule "08-Tibber Watchdog Stromzahler Aktualisierung"
when
    Time cron "0 * * * * ?" // jede Minute prüfen
then
    val aktualisierungItem = Stromzahler_Aktualisierung.state           // Auslesen vom Wert vom Stromzahler Aktualisierung
    if (aktualisierungItem == NULL || aktualisierungItem == UNDEF) {
        logWarn("Watchdog", "Stromzahler_Aktualisierung hat keinen gültigen Wert!")
        return
    }

    val lastUpdate = (aktualisierungItem as DateTimeType).zonedDateTime.toInstant.toEpochMilli 
    val nowTime = now.toInstant.toEpochMilli                                                     //Aktuelle Zeit
    val diffMillis = nowTime - lastUpdate                                                        //Berechnung Differenz

    if (diffMillis > 3 * 60 * 1000) {                                  
  
        Stromeingang_Tibber_STOP_Restart.sendCommand(ON)

    }

end

//#################################################################################################

rule "09-Tibber Binding überwachen"
when
    Thing "tibber:tibberapi:Tibber_API" changed
then
    val status = getThingStatusInfo("tibber:tibberapi:Tibber_API").getStatus().toString()
    if (status == "OFFLINE" || status == "INITIALIZING" || status == "UNINITIALIZED" || status == "DISABLED") {
        logWarn("Tibber", "Tibber Binding ist in problematischem Zustand: " + status)

        Stromeingang_Tibber_defekt.sendCommand(ON)
    }
end

then I set up 2 JS scripts in Openhab UI and a small rule in Openhab UI

          // Binding neu starten
		  things.getThing('tibber:tibberapi:Tibber_API').setEnabled(true);
          // Item auf OFF setzen
          items.getItem("Stromeingang_Tibber_defekt").sendCommand("OFF");
          console.warn("WARN: Tibber Binding wurde gestoppt. Aktuell werden keine Preise angezeigt. Es wurde wieder neugestartet")

and

          // Binding neu starten
		  things.getThing('tibber:tibberapi:Tibber_API').setEnabled(false);
		  java.lang.Thread.sleep(250);
		  things.getThing('tibber:tibberapi:Tibber_API').setEnabled(true);
          // Item auf OFF setzen
          items.getItem("Stromeingang_Tibber_defekt").sendCommand("OFF");
          console.warn("WARN: Tibber Binding wurde gestoppt. Aktuell werden keine Preise angezeigt. Es wurde wieder neugestartet")

I know it is not perfect. But it is a solution for me and for the last 2 weeks it worked fine for me. I hope that the update of the tibber app will come soon.