openhab / openhab-addons

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

[groheondus] No automatic refresh #10612

Closed PottiMc closed 1 year ago

PottiMc commented 3 years ago

Expected Behavior

The Grohe Ondus Binding should refresh every 15 minutes (900s) as polling interval.

Current Behavior

The binding is only refreshing when disabled and enabled again. Values are different from Grohe Sense Android App.

I tried uninsalling and reinstalling the binding, did not help. Refresh token is set and account credentials are given.

All I can see in the log files is the following. The java error messages only show up at the first starting, after that, everything looks fine, bridge is online and SenseGuard too.

==> /var/log/openhab/openhab.log <==

2021-04-29 08:20:01.706 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘groheondus:account:8a040c38be’ changed from UNINITIALIZED (DISABLED) to INITIALIZING

2021-04-29 08:20:01.727 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘groheondus:account:8a040c38be’ changed from INITIALIZING to UNKNOWN

==> /var/log/openhab/openhab.log <==

2021-04-29 08:20:03.072 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception:

java.lang.NullPointerException: null

at org.openhab.binding.groheondus.internal.handler.GroheOndusBaseHandler.getRoom(GroheOndusBaseHandler.java:135) ~[?:?]

at org.openhab.binding.groheondus.internal.handler.GroheOndusBaseHandler.getAppliance(GroheOndusBaseHandler.java:144) ~[?:?]

at org.openhab.binding.groheondus.internal.handler.GroheOndusBaseHandler.updateChannels(GroheOndusBaseHandler.java:102) ~[?:?]

at org.openhab.binding.groheondus.internal.handler.GroheOndusAccountHandler.lambda$2(GroheOndusAccountHandler.java:154) ~[?:?]

at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]

at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085) ~[?:?]

at org.openhab.binding.groheondus.internal.handler.GroheOndusAccountHandler.lambda$1(GroheOndusAccountHandler.java:151) ~[?:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[?:?]

at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[?:?]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]

at java.lang.Thread.run(Thread.java:834) [?:?] ==> /var/log/openhab/events.log <==

2021-04-29 08:20:03.072 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing ‘groheondus:account:8a040c38be’ changed from UNKNOWN to ONLINE

==> /var/log/openhab/openhab.log <==

2021-04-29 08:30:12.307 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler GroheOndusSenseGuardHandler of thing groheondus:senseguard:8a040c38be:e95c8f14-e75c-4aaa-bec5-a0767544612b tried accessing its bridge although the handler was already disposed.

2021-04-29 08:30:12.309 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler GroheOndusSenseGuardHandler tried updating the thing status although the handler was already disposed.

Steps to Reproduce (for Bugs)

  1. Fresh install of binding
  2. Enter account data
  3. Add SenseGuard device

Your Environment

OpenHab 3.0.2 (Issue was in former 3 versions too, didn't test on OH2) RaspberryPi4B

CyberChris79 commented 2 years ago

@PottiMc even after a re-enabling of the thing, you might still get an error. So I updated my rule to simply check every 5 minutes;

rule "Restart Grohe ondus when valve offline"
when 
   Time cron "0 0/5 * 1/1 * ? *"
then
    var thingStatusInfo = getThingStatusInfo("groheondus:account:account")

    if ((thingStatusInfo !== null) && (thingStatusInfo.getStatus().toString() == "OFFLINE")) {
         logInfo("FILE", "Grohe offline")
         sendHttpPutRequest("http://USER:PWD@127.0.0.1:8080/rest/things/groheondus%3Aaccount%3Aaccount/enable","text/plain",'false',5000)

         createTimer(now.plusMinutes(1),  [|
            sendHttpPutRequest("http://USER:PWD@127.0.0.1:8080/rest/things/groheondus%3Aaccount%3Aaccount/enable","text/plain",'true',5000)
            logInfo("FILE", "Grohe re-enabled")
         ] )
    }
end

Hey seime,

first of all, I also want to thank you for your great job and your support. I tried your rule, but for me it does not really seems to work. After a few days the connection lost again. i could reconnect it by update the token again.

Chris

PottiMc commented 2 years ago

Hi @CyberChris79

please double check you changed all the variables correctly and adjusted them to your binding.

Look at the Username, Password, IP, port, thing name, account name, etc. Make sure you don't have an @ in your password, it could lead to potential problems.

These are very simple commands every openhab installation is capable of when used correctly.

If you can't find the failure please send me the details above, I can rewrite the rule for you. Never post your username and password!

CyberChris79 commented 2 years ago

Hello @PottiMc,

thank you very much. I thought the error came from the rule configuration and i reinstalled the binding inclusive the things and item. But it still got some error. My OpenHAB Log show me this error

[ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.groheondus.internal.handler.GroheOndusSenseGuardHandler@b35a48': null

This is my rule `configuration: {} triggers:

Thank you in advanced CyberChris

alfpf commented 1 year ago

First of all, thanks @seime and @PottiMc for working on this issue. I have as well experienced all the same issues with the Grohe binding as you mention in this thread, but after your input, my setup is now working acceptably. I use version 3, very much (based on @PottiMc comment that this was the most stable one) the contribution i can make to support others have similar issues is that I’ve slightly updated the ”reset-rule” as my issue was that when the connection to the Grohe service broke, I needed to first disable/reenable the Grohe account thing, then followed by disabling/enabling the Grohe sense guard thing to get it working again.

rule "Restart Grohe ondus when valve offline"
when 
   Time cron "0 0/5 * 1/1 * ? *"
then
    var thingStatusInfo2 = getThingStatusInfo("groheondus:senseguard:5cc6aaa3bc:199ff93d-4419-41ad-b83f-f32b0c0b0b5f")
    //logInfo("myLog","Grohe Account, Status: " + thingStatusInfo.getStatus().toString() )      
    //logInfo("myLog","Grohe Sense Guard, Status: " + thingStatusInfo2.getStatus().toString() ) 
    if ((thingStatusInfo2 !== null) && ((thingStatusInfo2.getStatus().toString() == "OFFLINE") || (thingStatusInfo2.getStatus().toString() == "UNINITIALIZED"))) {
        logInfo("myLog", "Grohe Sense Guard is OFFLINE, disabling Grohe Account..")
        sendHttpPutRequest("http://<your account>:<your password>@192.168.1.5:8080/rest/things/groheondus%3Aaccount%3A5cc6aaa3bc/enable","text/plain",'false',5000)

        createTimer(now.plusMinutes(1),  [|
            sendHttpPutRequest("http://<your account>:<your password>@192.168.1.5:8080/rest/things/groheondus%3Aaccount%3A5cc6aaa3bc/enable","text/plain",'true',5000)
            logInfo("myLog", "Grohe Sense Guard, Account re-enabled")
         ] )
        createTimer(now.plusMinutes(2),  [|
            sendHttpPutRequest("http://<your account>:<your password>@192.168.1.5:8080/rest/things/groheondus%3Asenseguard%3A5cc6aaa3bc%3A199ff93d-4419-41ad-b83f-f32b0c0b0b5f/enable","text/plain",'true',5000)
            logInfo("myLog", "Grohe Sense Guard Item re-enabled")
         ] )
    }
end