csowada / ebus

This library handles the communication with heating engineering via the eBUS specification. This protocol is used by many heating manufacturers in Europe.
Eclipse Public License 1.0
5 stars 7 forks source link

buildMasterTelegram crashes with NullPointerException #8

Closed JensJordan closed 4 years ago

JensJordan commented 4 years ago

Item "CGB2_Heizung_Programm" is linked to channel "bm2_heating_program-heating-circuit#program". Receiving data from Wolf-CGB2 is working fine without error, but sending data results always in a NullPointerException.

Item definition:

String CGB2_Heizung_Programm  "Heizung Programm: [%s]" {channel="ebus:bm2:home1:85:bm2_heating_program-heating-circuit#program"}

Thing definition:

Bridge ebus:bridge:home1 "eBUS Bridge (serial)" @ "eBus" [
    serialPort="/dev/ttyUSB0",
    masterAddress="FF",
    advancedLogging=false,
    serialPortDriver="nrjavaserial",
    parsers="common,wolf-bm2,wolf-cgb2,wolf-mm1"]
{
    Thing bm2 85 "Wolf BM-2 (0x85)" [ slaveAddress="85" , masterAddress="80"]
    {
        Channels:
        Type bm2_heating_program-heating-circuit_program : bm2_heating_program-heating-circuit#program
    }
}

Error Log:

12:34:17.228 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'CGB2_Heizung_Programm' received command 0
12:34:17.233 [INFO ] [arthome.event.ItemStatePredictedEvent] - CGB2_Heizung_Programm predicted to become 0
12:34:17.252 [INFO ] [smarthome.event.ItemStateChangedEvent] - CGB2_Heizung_Programm changed from 2 to 0
12:34:17.285 [WARN ] [e.csdev.ebus.command.EBusCommandUtils] - Replace slave target address 85 with valid master address !
12:34:17.289 [ERROR] [rnal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ebus.internal.handler.EBusHandle@e21c99': null
java.lang.NullPointerException: null
        at de.csdev.ebus.command.EBusCommandUtils.buildMasterTelegram(EBusCommandUtils.java:361) ~[?:?]
        at de.csdev.ebus.command.EBusCommandUtils.buildMasterTelegram(EBusCommandUtils.java:299) ~[?:?]
        at de.csdev.ebus.client.EBusClient.buildTelegram(EBusClient.java:160) ~[?:?]
        at org.openhab.binding.ebus.internal.utils.EBusClientBridge.generateSetterTelegram(EBusClientBridge.java:197) ~[?:?]
        at org.openhab.binding.ebus.internal.handler.EBusHandler.handleCommand(EBusHandler.java:316) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_152]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_152]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_152]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_152]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [bundleFile:?]
        at com.sun.proxy.$Proxy135.handleCommand(Unknown Source) [?:?]
        at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:74) [bundleFile:?]
        at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:48) [bundleFile:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_152]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_152]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_152]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_152]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_152]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_152]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_152]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_152]

openHAB: 2.5.1-2 eBUS Binding: 2.5.1-4 Java: Zulu 1.8.0_152 (same results with Oracle-Java-8)

My last working (send and receive) eBUS release is: 2.4.0.RC4

csowada commented 4 years ago

Yes, the NPE is an issue, but your slave address has no master address pair in eBUS standard. So your master address 0x80 is not available and invalid. My BM2 is on slave address 0x35 for example.

BTW: You not need to define the master address in your thing file, it is calculated by default. Also the parser from v1 binding, please remove it.

csowada commented 4 years ago

Fixed with https://github.com/csowada/ebus/commit/7ac05e417577b62a762b7d6c09061e3bbc7e08d5 , will be released in version 1.0.6

JensJordan commented 4 years ago

Please re-open this issue. The NPE issue is fixed for the case: No Master Address is calculated and 'masterAddress' is not set in Bridge / Thing definition. But if the Master Address can't be calculated and the option 'masterAddress' is used (refer to Bridge Configuration / Thing Configuration), following NPE occurs if a message shall be send:

22:22:38.962 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'CGB2_Heizung_Programm_TEST_85' received command 3
22:22:38.977 [INFO ] [arthome.event.ItemStatePredictedEvent] - CGB2_Heizung_Programm_TEST_85 predicted to become 3
22:22:38.992 [ERROR] [rnal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ebus.internal.handler.EBusHandle@f48e22': Cannot replace the slave address 0x85 with a master address because it is a slave address without a master address.
java.lang.IllegalArgumentException: Cannot replace the slave address 0x85 with a master address because it is a slave address without a master address.
        at de.csdev.ebus.command.EBusCommandUtils.buildMasterTelegram(EBusCommandUtils.java:370) ~[?:?]
        at de.csdev.ebus.command.EBusCommandUtils.buildMasterTelegram(EBusCommandUtils.java:320) ~[?:?]
        at de.csdev.ebus.client.EBusClient.buildTelegram(EBusClient.java:160) ~[?:?]
        at org.openhab.binding.ebus.internal.utils.EBusClientBridge.generateSetterTelegram(EBusClientBridge.java:197) ~[?:?]
        at org.openhab.binding.ebus.internal.handler.EBusHandler.handleCommand(EBusHandler.java:316) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_152]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_152]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_152]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_152]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [bundleFile:?]
        at com.sun.proxy.$Proxy1753.handleCommand(Unknown Source) [?:?]
        at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:74) [bundleFile:?]
        at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:48) [bundleFile:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_152]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_152]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_152]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_152]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_152]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_152]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_152]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_152]
22:22:39.005 [INFO ] [smarthome.event.ItemStateChangedEvent] - CGB2_Heizung_Programm_TEST_85 changed from 0 to 3

My eBus Devices List:

MA | SA | Identifier     | Device         | Manufacture               | ID | Firmware   | Hardware   | Last Activity
---+----+----------------+----------------+----------------------+----+------------+------------+---------------------
FF | 04 |                | <interface>    | eBUS Library              |    | null       | null       | ---
   | 51 | 01 14 00 10 00 | ---            | G. Kromschröder AG        | 50 | 2.08       | null       | Mon Feb 03 22:23:49 CET 2020
FF | 04 |                | <interface>    | eBUS Library              |    | null       | null       | Mon Feb 03 22:24:11 CET 2020
30 | 35 | 00 20 00 00 C0 | bm2            | Wolf GmbH                 | 19 | 2.04       | 0          | Mon Feb 03 22:24:11 CET 2020
70 | 75 |                | ---            | null                      |    | null       | null       | Mon Feb 03 22:23:21 CET 2020
03 | 08 | 01 21 00 5A 40 | cgb2           | Wolf GmbH                 | 19 | 40.01      | 0          | Mon Feb 03 22:24:11 CET 2020
F1 | F6 |                | ---            | null                      |    | null       | null       | Mon Feb 03 22:24:05 CET 2020
   | 85 | 00 20 00 00 C0 | bm2            | Wolf GmbH                 | 19 | 2.04       | 0          | Mon Feb 03 22:23:47 CET 2020
----------------------------------------------------------------------------------------------------------------------

*) I don't understand, why the Master Address for "bm2-85" is not set.

My updated eBus Thing definition:

Bridge ebus:bridge:heating "eBUS Bridge (ebusd)" @ "eBus" [ ipAddress="127.0.0.1", port=8888, networkDriver="ebusd", masterAddress="FF", advancedLogging=false ]
{
    Thing bm2 35 "Wolf BM-2 (0x35)" @ "eBus" [ slaveAddress="35" ]
    {
        Channels:
        Type bm2_heating_program-heating-circuit_program : bm2_heating_program-heating-circuit#program 
        Type bm2_dhw_program-dhw-circuit_program : bm2_dhw_program-dhw-circuit#program
    }
    Thing bm2 85 "Wolf BM-2 (0x85)" @ "eBus" [ slaveAddress="85", masterAddress="FF" ]
    {
        Channels:
        Type bm2_heating_program-heating-circuit_program : bm2_heating_program-heating-circuit#program 
    }
}

BTW: Without definition of the master address the following error message occurs:

00:37:10.836 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'CGB2_Heizung_Programm_TEST_85' received command 3
00:37:10.849 [INFO ] [arthome.event.ItemStatePredictedEvent] - CGB2_Heizung_Programm_TEST_85 predicted to become 3
00:37:10.890 [ERROR] [rnal.common.AbstractInvocationHandler] - An error occurred while calling method 'ThingHandler.handleCommand()' on 'org.openhab.binding.ebus.internal.handler.EBusHandler@f48e22': Cannot replace the slave address 0x85 with a master address because it is a slave address without a master address.
java.lang.IllegalArgumentException: Cannot replace the slave address 0x85 with a master address because it is a slave address without a master address.
        at de.csdev.ebus.command.EBusCommandUtils.buildMasterTelegram(EBusCommandUtils.java:370) ~[?:?]
        at de.csdev.ebus.command.EBusCommandUtils.buildMasterTelegram(EBusCommandUtils.java:320) ~[?:?]
        at de.csdev.ebus.client.EBusClient.buildTelegram(EBusClient.java:160) ~[?:?]
        at org.openhab.binding.ebus.internal.utils.EBusClientBridge.generateSetterTelegram(EBusClientBridge.java:197) ~[?:?]
        at org.openhab.binding.ebus.internal.handler.EBusHandler.handleCommand(EBusHandler.java:316) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor215.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_152]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_152]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [bundleFile:?]
        at com.sun.proxy.$Proxy1972.handleCommand(Unknown Source) [?:?]
        at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:74) [bundleFile:?]
        at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:48) [bundleFile:?]
        at sun.reflect.GeneratedMethodAccessor214.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_152]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_152]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_152]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_152]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_152]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_152]
00:37:10.931 [INFO ] [smarthome.event.ItemStateChangedEvent] - CGB2_Heizung_Programm_TEST_85 changed from 0 to 3
csowada commented 4 years ago

Yes, the master address is not used in that case. But the master address is not well supported, it is on my remove list for further releases. So you are not able to work with the 30/35 address?

JensJordan commented 4 years ago

For bm2_dhw_program-dhw-circuit#program with 30/35 address the getter and setter are working like a charm. But the bm2_heating_program-heating-circuit#program doesn't work with 30/35 address. The getter is working fine with slave address 0x85 and in eBus Binding V1 the setter use 0xFF as master address.