openhab / openhab-addons

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

[fronius] NullPointerException (no new values until openhab restart) #3556

Closed cybermanat closed 6 years ago

cybermanat commented 6 years ago

When running a while, sometimes the binding stops working (not refreshing any value) and a java.lang.NullPointerException: null occurs.

Logfile Output:

java.lang.NullPointerException: null
    at org.openhab.binding.fronius.handler.FroniusBaseThingHandler.updateChannel(FroniusBaseThingHandler.java:110) ~[?:?]
    at org.openhab.binding.fronius.handler.FroniusBaseThingHandler.updateChannels(FroniusBaseThingHandler.java:85) ~[?:?]
    at org.openhab.binding.fronius.handler.FroniusSymoInverterHandler.refresh(FroniusSymoInverterHandler.java:58) ~[?:?]
    at org.openhab.binding.fronius.handler.FroniusBridgeHandler.lambda$0(FroniusBridgeHandler.java:109) ~[?:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
    at java.lang.Thread.run(Thread.java:748) [?:?] 

After enabling debug mode for the binding I got the following response data:

working response part from GetPowerFlowRealtimeData.fcgi:

"Site" : {
            "E_Day" : 26300,
            "E_Total" : 82703.0078125,
            "E_Year" : 82703.5,
            "Meter_Location" : "grid",
            "Mode" : "meter",
            "P_Akku" : null,
            "P_Grid" : 1645.7999632135034,
            "P_Load" : -1675.7999632135034,
            "P_PV" : 30,
            "rel_Autonomy" : 1.7901897994121083,
            "rel_SelfConsumption" : 100
         }

non working response with NullPointerException:

"Site" : {
            "E_Day" : 26300,
            "E_Total" : 82703.0078125,
            "E_Year" : 82703.5,
            "Meter_Location" : "grid",
            "Mode" : "meter",
            "P_Akku" : null,
            "P_Grid" : 1612.0499639678746,
            "P_Load" : -1612.0499639678746,
            "P_PV" : null,
            "rel_Autonomy" : 0,
            "rel_SelfConsumption" : null
         }

Expected Behavior

Setting the value and continue to update the values instead of crashing and ignoring the "null" value.

Current Behavior

NullPointerException appears and after that, the binding don't update values and seems to be crashed (openhab needs to be restarted)

Possible Solution

Ignore "null" values or translate them to "0"

Steps to Reproduce (for Bugs)

  1. Run for a while (didn't run for a whole day)
  2. Maybe it is needed, that P_PV gets null, if no sun is shining and PV production stops

Your Environment

cybermanat commented 6 years ago

Problem occurs, if Data is empty and Status Code is 8 (Transfer timeout) Request: solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceId=1&DataCollection=CommonInverterData api Respone: "Body" : { "Data" : {} }, "Head" : { "RequestArguments" : { "DataCollection" : "CommonInverterData", "DeviceClass" : "Inverter", "DeviceId" : "1", "Scope" : "Device" }, "Status" : { "Code" : 8, "Reason" : "Transfer timeout.", "UserMessage" : "" }, "Timestamp" : "2018-05-11T10:51:16+02:00" } }

dsemprich commented 6 years ago

My fronius binding also not updating the values and showing minus data for grid and load power

9037568 commented 6 years ago

Anyone care to try out a test jar?

aMU5Ed commented 5 years ago

Hi, I just updated to 2.4.0 Snapshot of this Jar and experience some more nullpointer exceptions.

2018-10-25 08:52:26.468 [WARN ] [mmon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception java.lang.NullPointerException: null at org.openhab.binding.fronius.handler.FroniusSymoInverterHandler.getValue(FroniusSymoInverterHandler.java:86) ~[?:?] at org.openhab.binding.fronius.handler.FroniusBaseThingHandler.updateChannel(FroniusBaseThingHandler.java:99) ~[?:?] at org.openhab.binding.fronius.handler.FroniusBaseThingHandler.updateChannels(FroniusBaseThingHandler.java:85) ~[?:?] at org.openhab.binding.fronius.handler.FroniusSymoInverterHandler.refresh(FroniusSymoInverterHandler.java:58) ~[?:?] at org.openhab.binding.fronius.handler.FroniusBridgeHandler.lambda$0(FroniusBridgeHandler.java:109) ~[?:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?] at java.lang.Thread.run(Thread.java:748) [?:?]

Please give me some suggestions if this would be only a configuration issue.

KR, Thomas