openhab / openhab-addons

Add-ons for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
1.86k stars 3.58k forks source link

[tibber] Missing channel for accumulatedReward (from Live API) #12273

Closed skenhall closed 1 year ago

skenhall commented 2 years ago

Your Environment

openHAB 3.2

Description

According to Tibber's API documentation for live measurements https://developer.tibber.com/docs/reference#livemeasurement there is also data available for the earnings (reward) for sold electricity: accumulatedReward | Float | Accumulated reward since midnight; requires active Tibber power deal

Would be super to also get this data into openHAB!

lsiepel commented 1 year ago

@skenhall just looked at the binding and the API, this doesn't look very difficult te get into the binding. Alle the message parsing is allready in place and it looks like it is 4- lines of code or so. But, as i'm not able to use tibber myself, i need you to test my changes. Are you able to spend some time to test?

skenhall commented 1 year ago

Yes, for sure!

Best regards, Per


Från: lsiepel @.> Skickat: Tuesday, January 10, 2023 8:18:27 PM Till: openhab/openhab-addons @.> Kopia: Per Skenhall @.>; Mention @.> Ämne: Re: [openhab/openhab-addons] [tibber] Missing channel for accumulatedReward (from Live API) (Issue #12273)

@skenhallhttps://github.com/skenhall just looked at the binding and the API, this doesn't look very difficult te get into the binding. Alle the message parsing is allready in place and it looks like it is 4- lines of code or so. But, as i'm not able to use tibber myself, i need you to test my changes. Are you able to spend some time to test?

— Reply to this email directly, view it on GitHubhttps://github.com/openhab/openhab-addons/issues/12273#issuecomment-1377733503, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADUZMPP4RRAYRGIMFL6CHALWRWYYHANCNFSM5OHFJOZQ. You are receiving this because you were mentioned.Message ID: @.***>

lsiepel commented 1 year ago

There you go: https://1drv.ms/u/s!AnMcxmvEeupwjqJi0lZi9bodhlkFmw?e=dpcKLL Uninstall current tibber binding, drop this file in you addons folder and it should be picked up in seconds.

You should then be able to bind an item to the channel: accumulatedReward it is of type reward:

    <channel-type id="reward">
        <item-type>Number:Dimensionless</item-type>
        <label>Total Reward</label>
        <description>Reward at given time interval (e.g. hourly, daily, accumulated since midnight)</description>
        <state pattern="%.3f"></state>
    </channel-type>

If you confirm the value is loaded, i'll file a PR for this change.

skenhall commented 1 year ago

That was quick! I will test it, but it might take some days, as it’s winter and we have very grey weather in Stockholm right now so the solar panels have not produced enough power to export anything for more than a week (and therefore nothing to sell and no reward).

Let’s hope for better weather with sun!

Best regards, Per


Från: lsiepel @.> Skickat: Tuesday, January 10, 2023 9:20:15 PM Till: openhab/openhab-addons @.> Kopia: Per Skenhall @.>; Mention @.> Ämne: Re: [openhab/openhab-addons] [tibber] Missing channel for accumulatedReward (from Live API) (Issue #12273)

There you go: https://1drv.ms/u/s!AnMcxmvEeupwjqJi0lZi9bodhlkFmw?e=dpcKLL Uninstall current tibber binding, drop this file in you addons folder and it should be pciked up in seconds.

You should then be able to bind an item to the channel: accumulatedReward it is of type reward:

    <channel-type id="reward">
            <item-type>Number:Dimensionless</item-type>
            <label>Total Reward</label>
            <description>Reward at given time interval (e.g. hourly, daily, accumulated since midnight)</description>
            <state pattern="%.3f"></state>
    </channel-type>

If you confirm the value is loaded, i'll file a PR for this change.

— Reply to this email directly, view it on GitHubhttps://github.com/openhab/openhab-addons/issues/12273#issuecomment-1377799634, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADUZMPIOFBOTFPMENFP3LOTWRW777ANCNFSM5OHFJOZQ. You are receiving this because you were mentioned.Message ID: @.***>

skenhall commented 1 year ago

Hi again,

Today we had som sunshine and some energy was sold! 🙂

Tried to installed the addon, but got this error at startup: 2023-01-13 18:15:54.413 [WARN ] [org.apache.felix.fileinstall ] - Error while starting bundle: file:/usr/share/openhab/addons/org.openhab.binding.tibber-3.4.1-SNAPSHOT.jar org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.tibber [26] Unresolved requirement: Import-Package: org.openhab.core.io.net.http

      at org.eclipse.osgi.container.Module.start(Module.java:463) ~[org.eclipse.osgi-3.17.200.jar:?]       at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:445) ~[org.eclipse.osgi-3.17.200.jar:?]       at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1260) [bundleFile:3.7.4]       at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1233) [bundleFile:3.7.4]       at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) [bundleFile:3.7.4]       at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) [bundleFile:3.7.4]       at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316) [bundleFile:3.7.4]

Not sure what that is about, but Tibber binding seems not to be starting...

BR, Per


Från: lsiepel @.> Skickat: den 10 januari 2023 21:20 Till: openhab/openhab-addons @.> Kopia: Per Skenhall @.>; Mention @.> Ämne: Re: [openhab/openhab-addons] [tibber] Missing channel for accumulatedReward (from Live API) (Issue #12273)

There you go: https://1drv.ms/u/s!AnMcxmvEeupwjqJi0lZi9bodhlkFmw?e=dpcKLL Uninstall current tibber binding, drop this file in you addons folder and it should be pciked up in seconds.

You should then be able to bind an item to the channel: accumulatedReward it is of type reward:

    <channel-type id="reward">
            <item-type>Number:Dimensionless</item-type>
            <label>Total Reward</label>
            <description>Reward at given time interval (e.g. hourly, daily, accumulated since midnight)</description>
            <state pattern="%.3f"></state>
    </channel-type>

If you confirm the value is loaded, i'll file a PR for this change.

— Reply to this email directly, view it on GitHubhttps://github.com/openhab/openhab-addons/issues/12273#issuecomment-1377799634, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADUZMPIOFBOTFPMENFP3LOTWRW777ANCNFSM5OHFJOZQ. You are receiving this because you were mentioned.Message ID: @.***>

jlaur commented 1 year ago

@skenhall - is it when using the JAR file? If yes, can you try to install the Air Quality binding and then try again?

skenhall commented 1 year ago

Hi again,

Installing that other binding fixed the dependency - is this a bug in the Tibber binding, that it is not properly declaring its dependencies?

However with the snapshot version now installed without error at start up, there are still no new channels to link to (see attached screenshot): [cid:790d6654-78be-40a1-ae2c-bfaaee5d0333]

@lsiepel: Is there perhaps more than those four line of code that need to be added for this new channel to be visible in UI?

BR, Per


Från: Jacob Laursen @.> Skickat: den 13 januari 2023 18:56 Till: openhab/openhab-addons @.> Kopia: Per Skenhall @.>; Mention @.> Ämne: Re: [openhab/openhab-addons] [tibber] Missing channel for accumulatedReward (from Live API) (Issue #12273)

@skenhallhttps://github.com/skenhall - is it when using the JAR file? If yes, can you try to install the Air Quality binding and then try again?

— Reply to this email directly, view it on GitHubhttps://github.com/openhab/openhab-addons/issues/12273#issuecomment-1382195362, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADUZMPJ5QR4JY3DFTUZEBOTWSGJL7ANCNFSM5OHFJOZQ. You are receiving this because you were mentioned.Message ID: @.***>

jlaur commented 1 year ago

@skenhall - no, it's a problem when manually dropping JARs in the addons directory. In this case dependent features are not automatically installed. I had the exact same problem two days ago when working on an add-on in a clean 4.0 snapshot system not having any official add-ons installed.

lsiepel commented 1 year ago

You might need to re-create the thing before the new channel is shown. the screenshot seems to be missing from the post.

skenhall commented 1 year ago

Hi again,

Sorry for the delay, but I realised I need to setup a separate test environment and not mess up my production OpenHAB instance with tests 🙂

Now the new instance is up and I can confirm that I see the channel "Total Reward" - however today was again totally grey in Stockholm are, so no energy sold and no reward...

I will be back assoo as I have som actual number of reward from Tibber to report to confirm the values.

BR, Per


Från: lsiepel @.> Skickat: den 15 januari 2023 16:20 Till: openhab/openhab-addons @.> Kopia: Per Skenhall @.>; Mention @.> Ämne: Re: [openhab/openhab-addons] [tibber] Missing channel for accumulatedReward (from Live API) (Issue #12273)

You might need to re-create the thing before the new channel is shown. the screenshot seems to be missing from the post.

— Reply to this email directly, view it on GitHubhttps://github.com/openhab/openhab-addons/issues/12273#issuecomment-1383178630, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADUZMPI2EMIWB64L27GG2VDWSQIVRANCNFSM5OHFJOZQ. You are receiving this because you were mentioned.Message ID: @.***>

skenhall commented 1 year ago

Sorry to say, but no data is reported in channel "Total Reward". Today I had a really small sales (0.02 SEK) and I can get that directly from Tibber's API explorer (see attached screen shot). Live data Tibber API 2023-01-23

However if I connect OpenHAB Tibber binding to same account the "Total Reward" i NULL (see attached screen shot) OpenHAB Tibber items 2023-01-23

Other data from API seems fine.

So probably something not right...

Can I switch on some more detailed logging, or how to continue debugging?

lsiepel commented 1 year ago

It will help if you enable debug logging and send the logs, also if you are able to send the related events. From the console you can enable debug logging: log:set debug org.openhab.binding.tibber

But i might have found the cause allready. The accumulatedReward was not yet added to the query. I thought it would be just another field that was returned, but due to your example, it came into my mind to look at the request.

Two test jars, pick one depending on your test systemen 3.x or 4.x 3.4.2: https://1drv.ms/u/s!AnMcxmvEeupwjqVH4mkQC4BrMOPcgw?e=GkFr43 4.0.0: https://1drv.ms/u/s!AnMcxmvEeupwjqVGznHUFOHls71Icw?e=HpEtvr

skenhall commented 1 year ago

Success!

I can now confirm that the latest addon version you provided @lsiepel worked just fine: image

lsiepel commented 1 year ago

Thanks, just filed the PR, now we wait for it to get merged.

skenhall commented 1 year ago

Great! Looking forward to that.


Från: lsiepel @.> Skickat: Wednesday, January 25, 2023 10:24:36 PM Till: openhab/openhab-addons @.> Kopia: Per Skenhall @.>; Mention @.> Ämne: Re: [openhab/openhab-addons] [tibber] Missing channel for accumulatedReward (from Live API) (Issue #12273)

Thanks, just filed the PR, now we wait for it to get merged.

— Reply to this email directly, view it on GitHubhttps://github.com/openhab/openhab-addons/issues/12273#issuecomment-1404242357, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADUZMPK2WW7PCJSYXCVVVCDWUGKZJANCNFSM5OHFJOZQ. You are receiving this because you were mentioned.Message ID: @.***>