RFXCOM 2.0 binding

I’ve been using it for a couple of days now just fine, I added the RFXCOM binding through paperui and added the “things” as they came in the inbox.
Since I’m upgrading from OH1 I’ve reused my items file and edited the channels accordingly (found the channel string by checking the thing name in paper UI), example:

rfxcom.items:
Contact DoorLockStateBasement "Basement door" <lock> (basement) { channel="rfxcom:lighting2:usb0:15632578_10:contact" }

rfxcom.things
Bridge rfxcom:bridge:usb0 [ serialPort="/dev/ttyUSB0" ]

NB:

  • I’m using OH2 snapshot #791

Thanks Alpoy,

I’ve removed my things file for the time being in an attempt to configure through the paperUI (I recall doing this the first time in order to understand the syntax).

I don’t see anything in the inbox (paperui or karaf console), but exceptions thrown in openhab.log:

2017-02-18 19:26:32.897 [DEBUG] [org.openhab.binding.rfxcom          ] - BundleEvent INSTALLED - org.openhab.binding.rfxcom
2017-02-18 19:26:33.071 [DEBUG] [org.openhab.binding.rfxcom          ] - BundleEvent RESOLVED - org.openhab.binding.rfxcom
2017-02-18 19:26:33.082 [DEBUG] [org.openhab.binding.rfxcom          ] - BundleEvent STARTING - org.openhab.binding.rfxcom
2017-02-18 19:26:33.114 [DEBUG] [org.openhab.binding.rfxcom          ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={component.name=org.openhab.binding.rfxcom.discovery, component.id=200, service.id=343, service.bundleid=227, service.scope=bundle} - org.openhab.binding.rfxcom
2017-02-18 19:26:33.164 [ERROR] [org.openhab.binding.rfxcom          ] - [org.openhab.binding.rfxcom.discovery(200)] Error during instantiation of the implementation object
java.lang.NoClassDefFoundError: org/openhab/binding/rfxcom/RFXComBindingConstants
	at org.openhab.binding.rfxcom.internal.discovery.RFXComBridgeDiscovery.<init>(RFXComBridgeDiscovery.java:56)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_101]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_101]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_101]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_101]

I’ll try and apt-get update/upgrade, followed by an uninstall and re-install of the whole OH2 packages.

Cheers
James

@james_2_roberts I’m by no means an expert on the binding, but I do have it working happily on OH2 via paperUI. I would suggest you go through paperUI first just to make sure that you have the binding working correctly, before trying to get the text based .things file method working.

Also are you using beta 5 or the release version of OH2? If you are still on beta 5, I suggest you upgrade to the release version.

One other point - I don’t think you need the rfxcom.cfg file with the OH2 binding as the serial port is configured in the thing definition (as an aside, even if you did use a config file, the syntax of your line does not look correct as with OH2 we no longer prefix the binding name on each line of the config file - thus your line should read serialPort=/dev/ttyUSB0 ).

Thanks @smar,

I’m making progress. I performed a clean install of OH2 (apt-get purge, followed by install), this time I started with an empty list of bindings and just installed the rfxcom binding, along with the rfxcom.cfg file.

The rfxcom wasn’t found by the paperUI, so there’s no way I can configure it?

I did try the following .things file:

Bridge rfxcom:bridge:usb0 [ serialPort="/dev/ttyUSB0" ] {
	Thing lighting5 15770872_16 "Mood" @ "Lounge" [deviceId="15770872.16", subType="LightwaveRF,Siemens"]
	Thing lighting5 15776004_16 "Mood" @ "Bedroom 1" [deviceId="15770872.16", subType="LightwaveRF,Siemens"]
	}

which gave the following output in events.log:

2017-02-19 08:15:21.221 [ThingAddedEvent           ] - Thing 'rfxcom:bridge:usb0' has been added.
2017-02-19 08:15:21.317 [ThingAddedEvent           ] - Thing 'rfxcom:lighting5:usb0:15770872_16' has been added.
2017-02-19 08:15:21.477 [hingStatusInfoChangedEvent] - 'rfxcom:bridge:usb0' changed from UNINITIALIZED to INITIALIZING
2017-02-19 08:15:21.502 [hingStatusInfoChangedEvent] - 'rfxcom:bridge:usb0' changed from INITIALIZING to OFFLINE
2017-02-19 08:15:21.512 [hingStatusInfoChangedEvent] - 'rfxcom:lighting5:usb0:15770872_16' changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)
2017-02-19 08:15:21.516 [hingStatusInfoChangedEvent] - 'rfxcom:lighting5:usb0:15776004_16' changed from UNINITIALIZED to INITIALIZING
2017-02-19 08:15:21.522 [hingStatusInfoChangedEvent] - 'rfxcom:lighting5:usb0:15776004_16' changed from INITIALIZING to OFFLINE (BRIDGE_OFFLINE)
2017-02-19 08:15:21.525 [ThingAddedEvent           ] - Thing 'rfxcom:lighting5:usb0:15776004_16' has been added.
2017-02-19 08:15:21.529 [hingStatusInfoChangedEvent] - 'rfxcom:lighting5:usb0:15770872_16' changed from UNINITIALIZED (HANDLER_MISSING_ERROR) to INITIALIZING
2017-02-19 08:15:21.533 [hingStatusInfoChangedEvent] - 'rfxcom:lighting5:usb0:15770872_16' changed from INITIALIZING to OFFLINE (BRIDGE_OFFLINE)

At which point OH2 appears to have crashed…

Cheers
James

What if you only define the bridge in the things file, and let the lighting5 things add them self by creating some activity on the rfxcom device (switch on the lights assuming these are light devices etc.)

At least, when I got my rfxcom bridge defined, the things came ‘automagically’ in the inbox when the devices started to communicate (temperature sensors by timer, door sensors after I open/closed the door and so on).

I followed the PaperUI route, installing both the RFXCOM binding through the PaperUI, and also configuring it manually, specifying only the serial port as: /dev/ttyUSB0
The resulting logs show:

==> events.log <==
2017-02-19 12:22:07.615 [ThingAddedEvent           ] - Thing 'rfxcom:bridge:a99227cd' has been added.
2017-02-19 12:22:07.669 [hingStatusInfoChangedEvent] - 'rfxcom:bridge:a99227cd' changed from UNINITIALIZED to INITIALIZING
2017-02-19 12:22:07.679 [hingStatusInfoChangedEvent] - 'rfxcom:bridge:a99227cd' changed from INITIALIZING to OFFLINE

==> openhab.log <==
2017-02-19 12:22:07.766 [ERROR] [g.rfxcom.handler.RFXComBridgeHandler] - Connection to RFXCOM transceiver failed: invalid port

Cheers
James

hm, I’m using a raspberry pi so the only suggestion I have left is to check /etc/default/openhab2:
I’ve added this (specifically /dev/ttyUSB0 for rfxcom):
EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyAMA0:/dev/ttyACM0"

Also added “openhab” to the dialout group in /etc/group.

Remember to restart after these changes

Thanks @lfs_alp5,

Changes made, restarting as I type…

==> events.log <==
2017-02-19 14:26:41.912 [hingStatusInfoChangedEvent] - 'rfxcom:bridge:c62488dd' changed from INITIALIZING to OFFLINE
2017-02-19 14:26:41.914 [hingStatusInfoChangedEvent] - 'rfxcom:bridge:c62488dd' changed from UNINITIALIZED to INITIALIZING

==> openhab.log <==
2017-02-19 14:26:41.999 [ERROR] [g.rfxcom.handler.RFXComBridgeHandler] - Connection to RFXCOM transceiver failed: invalid port

At which point OpenHAB2 stops running, PaperUI doesn’t respond…

Going to give this one last try, using the things file again and see if that’s any better.

If it would help, I’ll raise a bug, but I’m not sure what would help…

tried again with the following .things file:

Bridge rfxcom:bridge:usb0 [ serialPort="/dev/ttyUSB0" ] {}

and the following happens before OpenHAB2 bails out:

==> openhab.log <==
2017-02-19 14:34:46.462 [INFO ] [ore.internal.i18n.LocaleProviderImpl] - Locale set to en_EN
2017-02-19 14:35:12.616 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'rfxcom.things'
2017-02-19 14:35:23.348 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at /start
2017-02-19 14:35:23.676 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui

==> events.log <==
2017-02-19 14:35:26.783 [ThingAddedEvent           ] - Thing 'rfxcom:bridge:usb0' has been added.
2017-02-19 14:35:26.847 [hingStatusInfoChangedEvent] - 'rfxcom:bridge:usb0' changed from UNINITIALIZED to INITIALIZING
2017-02-19 14:35:26.873 [hingStatusInfoChangedEvent] - 'rfxcom:bridge:usb0' changed from INITIALIZING to OFFLINE

@james_2_roberts Just reading back up the thread, I see that you tried the paperUI route but you were not able to get it to work due to an ‘invalid port’ error. How exactly did you specify the port? i.e. did you manually install the RFXCom USB Transceiver?

Also, just to make sure that you’ve got all the bases ticked, are you 100% sure you have the port correct and accessible to the openhab user? Have you started openHAB with the port in the environment variable correctly (EXTRA_JAVA_OPTS)?

Hi @smar,

When I used the PaperUI route, I manually added the thing as an RFXCOM USB Transceiver specifying the port as follows:

/dev/ttyUSB0

That gave me:

==> events.log <==
2017-02-19 12:22:07.615 [ThingAddedEvent           ] - Thing 'rfxcom:bridge:a99227cd' has been added.
2017-02-19 12:22:07.669 [hingStatusInfoChangedEvent] - 'rfxcom:bridge:a99227cd' changed from UNINITIALIZED to INITIALIZING
2017-02-19 12:22:07.679 [hingStatusInfoChangedEvent] - 'rfxcom:bridge:a99227cd' changed from INITIALIZING to OFFLINE

==> openhab.log <==
2017-02-19 12:22:07.766 [ERROR] [g.rfxcom.handler.RFXComBridgeHandler] - Connection to RFXCOM transceiver failed: invalid port
pi@openhab ~ $ groups openhab
openhab : openhab dialout
pi@openhab ~ $ cat /etc/default/openhab2
EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyAMA0:/dev/ttyACM0"

RFXCOM works perfectly without any issues at all on OH1.8.3

I use the RFXCOM 1.x binding with OH2 and manual configuration without any issues on my RPi2B.

Remember to reboot your Pi after messing with the serial port:

sudo reboot now

As Robert says, you can use the 1.8 binding in OH2, if you prefer.

For the OH2 binding, the only other things that I can think of to check are:

  1. Check that the device actually exists at /dev/ttyUSB0 (you can just do a ls -la /dev/ttyUSB0). Frequently with Linux, when you plug/unplug a device, it increments the device port number, hence the reason it is usually easier to use a symlink for the port, so you know what it is going to be every time.

  2. As far as I am aware, the serial bundle should be installed by default. However, it may be worth checking in your karaf that this has actually been installed.

Sorry my bad. I actually use the 2.0 binding.

Hi @rtvb , I tried using the 1.9 snapshot and 1.10 snapshots before the 2.0 binding - my preference was to get OH2 up and running “as was” before attempting to migrate to 2.0 bindings - I can’t say I relish migrating the rest of the bindings after the experience so far with rfxcom :slight_smile:

CHeers
James

Thanks for you continued help on this, I can’t imagine how painful it must be watching me do this!

OK…

I’ve added the following to /etc/udev/rules.d/50-usb-serial.rules:

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{product}=="RFXtrx433", ATTRS{serial}=="A1XFDNKA" SYMLINK+="USBrfxcom", GROUP="dialout", MODE="0666"

Performed sudo reboot, can see /dev/USBrfxcom -> ttyUSB0

Serial bundle:

openhab> bundle:list | grep -i serial
211 | Active   |  80 | 3.12.0.OH             | nrjavaserial
openhab> feature:list | grep -i serial
openhab-binding-serial1                   | 1.9.0.RC1        |          | Uninstalled | openhab-addons-2.0.0.RC1        | Serial Binding
openhab-binding-serial1                   | 1.9.0.RC1        |          | Uninstalled | addons-2.0.0.RC1                | Serial Binding
esh-tp-jax-rs-provider-gson               | 0.9.0.b3         |          | Started     | distro-2.0.0.RC1                | JAX-RS provider for de/serialization using Gson
openhab-transport-serial                  | 2.0.0.RC1        |          | Started     | distro-2.0.0.RC1                | Serial Transport
openhab>

Adding via the following .things file:

Bridge rfxcom:bridge:usb0 [ serialPort="/dev/USBrfxcom" ] {}

results in:

2017-02-20 07:07:57.740 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'rfxcom.things'
2017-02-20 07:07:58.090 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'rfxcom.things'
2017-02-20 07:07:58.176 [ERROR] [g.rfxcom.handler.RFXComBridgeHandler] - Connection to RFXCOM transceiver failed: invalid port
2017-02-20 07:07:58.179 [ERROR] [g.rfxcom.handler.RFXComBridgeHandler] - Connection to RFXCOM transceiver failed: invalid port

Adding manually via PaperUI flashes up a “Error” at the bottom of the PaperUI and OpenHAB2 crashes…

Anything else I can try…please :expressionless:

Cheers
James

I have a “Thermostat3” device that I can control with the RfxCom. Would like to control it with the binding as well. What needs to be done to add an extra device? Just testing? Implementing certain calls? I can both test and program myself.

Basically you need to add new message implementation RFXComThermostat3Message.java and thing description file.

See currently supported messages as a example from here and description files here