New Jeelink Openhab2 Binding

You need to make additional serial ports visible to openHab by specifying them in system property gnu.io.rxtx.SerialPorts. I have modified /etc/defaults/openhab to contain
EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyElero:/dev/ttyJeelink:/dev/ttyS0:/dev/ttyAMA0"

1 Like

This is a good hint, will try that.

Hi @vbier,

Thanks for providing this binding!
I try to get it running with ec3k devices.

Having some trouble 


This is the log

2017-07-22 14:09:40.839 [TRACE] [link.handler.JeeLinkSerialConnection] - Read line from port COM4: OK 0E3D 29984033 28690166 54358 3 135 8 22
2017-07-22 14:09:45.413 [TRACE] [jeelink.handler.JeeLinkSensorHandler] - JeeLink sensor cyclic propagation for thing ec3k 1 (jeelink:ec3k:a92ee4a3)...
2017-07-22 14:09:50.756 [TRACE] [link.handler.JeeLinkSerialConnection] - Read line from port COM4: OK 0E3D 29984043 28690172 54358 3 135 8 4
2017-07-22 14:09:55.844 [TRACE] [link.handler.JeeLinkSerialConnection] - Read line from port COM4: OK 0E3D 29984048 28690177 54358 3 135 8 31
2017-07-22 14:10:00.788 [TRACE] [link.handler.JeeLinkSerialConnection] - Read line from port COM4: OK 0E3D 29984053 28690182 54358 3 135 8 19
2017-07-22 14:10:08.963 [TRACE] [jeelink.handler.JeeLinkSensorHandler] - JeeLink sensor cyclic propagation for thing ec3k 1 (jeelink:ec3k:a92ee4a3)...
2017-07-22 14:10:09.166 [TRACE] [jeelink.handler.JeeLinkSensorHandler] - JeeLink sensor cyclic propagation for thing ec3k 1 (jeelink:ec3k:a92ee4a3)...
2017-07-22 14:10:20.774 [TRACE] [jeelink.handler.JeeLinkSensorHandler] - JeeLink sensor cyclic propagation for thing ec3k (jeelink:ec3k:a92ee4a3)...
2017-07-22 14:10:26.568 [TRACE] [jeelink.handler.JeeLinkSensorHandler] - JeeLink sensor cyclic propagation for thing ec3k 1 (jeelink:ec3k:a92ee4a3)...
2017-07-22 14:10:26.766 [TRACE] [jeelink.handler.JeeLinkSensorHandler] - JeeLink sensor cyclic propagation for thing ec3k 1 (jeelink:ec3k:a92ee4a3)...
2017-07-22 14:10:40.783 [TRACE] [link.handler.JeeLinkSerialConnection] - Read line from port COM4: OK 0E3D 29984093 28690221 54358 3 135 8 17
2017-07-22 14:10:45.411 [TRACE] [jeelink.handler.JeeLinkSensorHandler] - JeeLink sensor cyclic propagation for thing ec3k 1 (jeelink:ec3k:a92ee4a3)...
2017-07-22 14:10:55.836 [TRACE] [link.handler.JeeLinkSerialConnection] - Read line from port COM4: OK 0E3D 29984108 28690234 54358 3 135 8 24
2017-07-22 14:11:06.091 [TRACE] [link.handler.JeeLinkSerialConnection] - Read line from port COM4: OK 0E3D 29984118 28690244 54358 3 135 8 11

Those are my things

Thing jeelink:jeelink:631fdfea "Jeelink ec3k" @ "home" [ portName="serial://COM4", sketchName="ec3kSerial" ]
Thing jeelink:ec3k:a92ee4a3 "ec3k 1" (jeelink:jeelink:631fdfea)  @ "home" [ sensorId="0E3D"]

Problem is that the “bridge” (jeelink:jeelink:631fdfea) is displayed ONLINE, but the thing “jeelink:ec3k:a92ee4a3” is always OFFLINE.

Items connected to jeelink:ec3k:a92ee4a3 do show no value.

Number ec3k1Power "ec3k1 power" {channel="jeelink:ec3k:a92ee4a3:currentWatt"}
Number ec3k1Max "ec3k1 max" {channel="jeelink:ec3k:a92ee4a3:maxWatt"}

What am I doing wrong here?
I’m using OH2.1 and https://github.com/vbier/openhab2-addons/blob/complete/addons/binding/org.openhab.binding.jeelink/org.openhab.binding.jeelink-2.1.0-SNAPSHOT.jar

The lines that are read from the sensor do not look like ec3kSerial output. If you look at this post, you see that the messages should have a completely different format. Do you have ec3kSerial sketch on your stick?

Right. Issue was an outdated sketch. Working now! Very cool, thanks for your efforts @vbier

Found a little issue (which probably only affects me) 


long consumptionTotal = ((con1 << 24) + (con2 << 16) + (con3 << 8) + con4) / 1000;

You return kWh not Wh.
In my use case I like to report (and persist) the consumption per day. Usually (in my old OH1 Binding) I was doing this using some OH rule. Unfortunately kWh is not the right dimension for this. I would need Wh.

So question is if you would consider changing the code? If not -> no problem. I can fork and do it myself.

If you are the only one with the problem, then either nobody else uses this or all others like the Wh. I can add a configuration entry to choose whether Wh or kWh shall be reported and default that to Wh, but as I am currently in the process of getting my pull request approved, I will do that after the binding is part of the official distribution.

Fine for me. Gonna fork it meanwhile. Thanks

I have some trouble since a couple of days with my jeelink/lacrosse devices. My receiver is configured with port “serial:///dev/ttyUSB-jeelink”, which is available via EXTRA_JAVA_OPTS. The receiver in online in PaperUI and also in the openhab logs:

2017-07-25 09:32:33.098 [INFO ] [link.handler.JeeLinkSerialConnection] - Creating serial connection for port /dev/ttyUSB-jeelink with baud rate 57600...
2017-07-25 09:32:33.098 [INFO ] [link.handler.JeeLinkSerialConnection] - Opening serial connection to port /dev/ttyUSB-jeelink with baud rate 57600...
2017-07-25 09:32:33.139 [INFO ] [nding.jeelink.handler.JeeLinkHandler] - updating JeeLinkHandler for port /dev/ttyUSB-jeelink to be ONLINE...
2017-07-25 09:32:33.141 [INFO ] [nding.jeelink.handler.JeeLinkHandler] - JeeLinkHandler for port /dev/ttyUSB-jeelink is ONLINE.

The lacrosse things are “UNINITIALIZED - HANDLER_INITIALIZING_ERROR” in PaperUI and won’t get updated. But if I open the port via screen command, I’ll get the right data:

OK 9 54 1 4 212 58
OK 9 23 1 4 213 56
OK 9 58 1 4 212 57
OK 9 46 1 4 206 62

My devices are 0777 and the openhab user is also member of “dialout” group:

crwxrwxrwx 1 root dialout 188, 2 Jul 25 10:16 /dev/ttyUSB2
lrwxrwxrwx 1 root root         7 Jul 25 09:05 /dev/ttyUSB-jeelink -> ttyUSB2

Any ideas what’s going wrong?

Do you have any exceptions in the log file? Did you remove the stick from the PC while openHAB had been running?

If you can access the port and read data from the command line while openHAB is running, then it is not in use by openHAB.

Please enable trace logging to confirm that the binding does not actually read anything. If you do not see any lines showing that input has been read from the port, then touch the binding jar. This will trigger a binding reload and openHAB will try to close and open the port again.

Hi Volker, thank you for the fast reply. No relevant data at the log file at debug level, but after touching the file, I got some real data. In my case some sensors are still offline, but this could be another problem.

Thank you!

The binding logs input read from the port only in trace level, so there is nothing to see in debug level.

There seems to be a reconnect problem once the connection to the serial port has been dropped. This happens for example when you unplug the stick, but might as well happen when other problems occur.

You’re right, debug just shows an update. Trace shows:

2017-07-25 13:03:52.678 [TRACE] [link.handler.JeeLinkSerialConnection] - Read line from port /dev/ttyUSB-jeelink: OK 9 35 1 4 212 57                                       │
2017-07-25 13:03:52.679 [TRACE] [.LaCrosseTemperatureReadingConverter] - Creating reading from: OK 9 35 1 4 212 57

There are still not all sensors back again and new sensor id’s won’t be found. Maybe they need a hardware reboot. :wink:

If the binding reads input from the port, then a reboot most likely won’t help. You can see in your log excerpt that you get values for a sensor with id 9. Are there values for other sensors, too?

No Values for the missing sensors, but they are - as far as I see via ip-cam ;), alive and shows values. Will restart them, when I am home again.

Did you move the sensors away from the stick or did you get any new hardware that might interfere with the Jeelinks radio? You could try to move one of the sensors that can not be found next to the stick to rule out this kind of problems.

Rebooting the pc should only be the last resort.

No new Hardware and the missings sensors are closer that the working ones. Maybe the sensors just need a “reboot” (battery off/on).

If you take the battery out they will get a new ID. So you at least have to update the sensor ID in the thing configuration, or recreate the things. I would test this with one sensor first, and one by one with the remaining sensors thereafter.

Restart the sensors (battery) solved my problem. Receiver got new sensor data. Reason unknown, but solved.

Just a quick note for those who use version 2.2 of this binding.

Definition of things changed slightly. Here is my working (Windows) example:

ec3k

Thing jeelink:jeelinkUsb:ec3k "Jeelink ec3k" @ "home" [ serialPort="COM4", sketchName="ec3kSerial" ]
Thing jeelink:ec3k:0E3D "ec3k 1" (jeelink:jeelinkUsb:ec3k)  @ "home" [ sensorId="0E3D"]
Thing jeelink:ec3k:14E7 "ec3k 2" (jeelink:jeelinkUsb:ec3k)  @ "home" [ sensorId="14E7"]

lacrosse

Thing jeelink:jeelinkUsb:lacrosse "Jeelink lacrosse" @ "home" [ serialPort="COM6", sketchName="LaCrosseITPlusReader" ]
Thing jeelink:lacrosse:sensor1 "Jeelink lacrosse 1" (jeelink:jeelinkUsb:lacrosse)  @ "home" [ sensorId="16", minTemp=10, maxTemp=32]
Thing jeelink:lacrosse:sensor2 "Jeelink lacrosse 2" (jeelink:jeelinkUsb:lacrosse)  @ "home" [ sensorId="18", minTemp=10, maxTemp=32]
1 Like