openhab / openhab-addons

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

[jeelink] Add Revolt protocol #6077

Closed NightDragon1 closed 4 years ago

NightDragon1 commented 4 years ago

Hi all!

Systeminfo I'm running openHAB 2.4.0 on Raspberry Pi 3 B+ (Raspian Buster). I'm using the Jeelink Binding and added my nanoCUL 433MHz Stick.

Request I would like to ask you if you could add support for the Revolt protocol, please.

What i did so far When manually initializing the stick via minicom with "fx\n" (Slow RF) "X21\n" (Raw output), i can receive the data from the Revolt Energy Meter NC-5262. (somehow initializing via the Jeelink Binding doesn't work properly with my nanoCUL, so i have to connect after openhab2 connected, to the serial and send the commands) The data is shown in the log when setting the jeelink binding to TRACE loglevel. However as there is no matcher it get's droped by the plugin. As I'm not good enough in Java I would like to ask you to add the Protocol to your Plugin.

Protocol Definition FHEM does handle it using this module: https://github.com/mhop/fhem-mirror/blob/master/fhem/FHEM/19_Revolt.pm In X21 the CUL outputs the RAW data. derived from the below examples and the FHEM PM Module, and if I didn't make any mistake the following byte interpretation is given: (I started counting at 1 not 0, all values are hex representatives fo decimal values) Byte 1 = Protocol type (r = Revolt) Byte 2-5 = Sensor ID Byte 6-7 = Voltage in V Byte 8-11 = Current as 1/100 of one A Byte 12-13 = Frequency in Hz Byte 14-17 = Power as 1/10 of one W Byte 18-19 = Power Factor as 1/100 of one VA Byte 20-23 = Energy Counter in 1/100 of one Wh

A example Reading from the TRACE 2019-09-15 17:13:24.851 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB1: r5646E50000320008646D5E02 2019-09-15 17:13:25.943 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB1: r4F1BE400513206875B312F25 2019-09-15 17:13:27.263 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB1: r559AE300573206EB5A45C94D

Some more under https://pastebin.com/NVnGTrvG

If you need any help testing it, please let me know.

Thanks, BR, Rob

vbier commented 4 years ago

It does not make much sense to implement the protocol if the stick can not be initialized correctly with the binding. How did you try to initialize it? Did you try the init command "fx;X21"? If yes, can you please turn on TRACE logging and then once again set that init command for the the stick and paste the relevant part of the log?

NightDragon1 commented 4 years ago

From my point of view the init procedure and the protocol support are independent things, whatever i agree that both issues should be fixed for a proper solution.

Yes i tried to init it via "fx;X21". Exactly as the binding docu tells.

LOG-TRACE of Init (it's the device on /dev/ttyUSB1 aka 9c7418fc

2019-12-10 10:56:20.811 [DEBUG] [elink.internal.JeeLinkHandlerFactory] - creating JeeLinkHandler for thing 9c7418fc...
2019-12-10 10:56:20.817 [DEBUG] [elink.internal.JeeLinkHandlerFactory] - registering sensor discovery service...
2019-12-10 10:56:20.862 [DEBUG] [org.openhab.binding.jeelink         ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={service.id=567, service.bundleid=215, service.scope=singleton} - org.openhab.binding.jeelink
2019-12-10 10:56:20.886 [DEBUG] [l.connection.JeeLinkSerialConnection] - Creating serial connection for port /dev/ttyUSB1 with baud rate 57600...
2019-12-10 10:56:20.890 [DEBUG] [l.connection.JeeLinkSerialConnection] - Opening serial connection to port /dev/ttyUSB1 with baud rate 57600...
2019-12-10 10:56:20.905 [DEBUG] [ding.jeelink.internal.JeeLinkHandler] - Connection to port /dev/ttyUSB1 opened.
2019-12-10 10:56:20.909 [DEBUG] [ding.jeelink.internal.JeeLinkHandler] - Init commands scheduled in 10 seconds.
2019-12-10 10:56:20.912 [DEBUG] [ding.jeelink.internal.JeeLinkHandler] - Monitoring job started.
2019-12-10 10:56:23.290 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB0: OK 9 9 1 4 146 45
2019-12-10 10:56:23.292 [TRACE] [.LaCrosseTemperatureReadingConverter] - Creating reading from: OK 9 9 1 4 146 45
2019-12-10 10:56:24.440 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB0: OK 9 17 1 4 204 54
2019-12-10 10:56:24.445 [TRACE] [.LaCrosseTemperatureReadingConverter] - Creating reading from: OK 9 17 1 4 204 54
2019-12-10 10:56:25.208 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB0: OK 9 0 1 4 194 56
2019-12-10 10:56:25.211 [TRACE] [.LaCrosseTemperatureReadingConverter] - Creating reading from: OK 9 0 1 4 194 56
2019-12-10 10:56:26.248 [DEBUG] [sse.LaCrosseTemperatureSensorHandler] - updating states for thing Temperatur Abstellraum (9): temp=17.0 (16.999989), humidity=45, batteryNew=false, batteryLow=false
2019-12-10 10:56:27.812 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB0: OK 9 6 1 4 197 45
2019-12-10 10:56:27.815 [TRACE] [.LaCrosseTemperatureReadingConverter] - Creating reading from: OK 9 6 1 4 197 45
2019-12-10 10:56:28.074 [DEBUG] [sse.LaCrosseTemperatureSensorHandler] - updating states for thing Temperatur Schlafzimmer (2): temp=25.0 (24.985195), humidity=49, batteryNew=false, batteryLow=false
2019-12-10 10:56:28.508 [INFO ] [org.quartz.core.QuartzScheduler     ] - Scheduler openHAB-job-scheduler_$_NON_CLUSTERED started.
2019-12-10 10:56:30.911 [DEBUG] [ding.jeelink.internal.JeeLinkHandler] - Sending init commands for port /dev/ttyUSB1: fx;X21
2019-12-10 10:56:30.916 [DEBUG] [connection.AbstractJeeLinkConnection] - Writing to device on port /dev/ttyUSB1: [fx, X21]
2019-12-10 10:56:37.526 [DEBUG] [sse.LaCrosseTemperatureSensorHandler] - updating states for thing Temperatur Filamentbox1 (12): temp=22.8 (22.799997), humidity=43, batteryNew=false, batteryLow=false
2019-12-10 10:57:28.785 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB0: OK 9 2 1 4 225 49
2019-12-10 10:57:28.788 [TRACE] [.LaCrosseTemperatureReadingConverter] - Creating reading from: OK 9 2 1 4 225 49
2019-12-10 10:57:29.189 [WARN ] [eneric.internal.generic.ChannelState] - Command 'FFB36B' not supported by type 'ColorValue': FFB36B is not a valid RGB syntax
2019-12-10 10:57:29.678 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB0: OK 9 12 1 4 204 43
2019-12-10 10:57:29.680 [TRACE] [.LaCrosseTemperatureReadingConverter] - Creating reading from: OK 9 12 1 4 204 43
2019-12-10 10:58:30.484 [DEBUG] [nal.discovery.SensorDiscoveryService] - discovery started for bridge jeelink:jeelinkUsb:9c7418fc
2019-12-10 10:58:30.487 [DEBUG] [nal.discovery.SensorDiscoveryService] - discovery started for bridge jeelink:jeelinkUsb:f57eaa62
2019-12-10 10:58:37.540 [DEBUG] [sse.LaCrosseTemperatureSensorHandler] - updating states for thing Temperatur Filamentbox1 (12): temp=22.8 (22.799997), humidity=43, batteryNew=false, batteryLow=false
2019-12-10 10:59:00.484 [DEBUG] [nal.discovery.SensorDiscoveryService] - discovery stopped for bridge jeelink:jeelinkUsb:9c7418fc
2019-12-10 10:59:00.488 [DEBUG] [nal.discovery.SensorDiscoveryService] - discovery stopped for bridge jeelink:jeelinkUsb:f57eaa62
vbier commented 4 years ago

Can you try https://github.com/vbier/openhab2-addons/raw/jar/bundles/org.openhab.binding.jeelink/org.openhab.binding.jeelink-2.5.0-SNAPSHOT.jar and see if this version can correctly send the init commands? If not, is there some special handling when you send the init commands manually? Is there a response? Also, a log excerpt from the new version would be fine.

NightDragon1 commented 4 years ago

I'm sorry - no change (new device id 75d8aeec)

2019-12-10 17:48:44.238 [INFO ] [org.apache.felix.fileinstall        ] - Installing bundle org.openhab.binding.jeelink / 2.5.0.201912101413
2019-12-10 17:48:44.858 [INFO ] [org.apache.felix.fileinstall        ] - Started bundle: file:/usr/share/openhab2/addons/org.openhab.binding.jeelink-2.5.0-SNAPSHOT.jar

2019-12-10 18:12:21.022 [DEBUG] [elink.internal.JeeLinkHandlerFactory] - creating JeeLinkHandler for thing 75d8aeec...
2019-12-10 18:12:21.028 [DEBUG] [elink.internal.JeeLinkHandlerFactory] - registering sensor discovery service...
2019-12-10 18:12:21.080 [DEBUG] [org.openhab.binding.jeelink         ] - ServiceEvent REGISTERED - {org.eclipse.smarthome.config.discovery.DiscoveryService}={service.id=527, service.bundleid=215, service.scope=singleton} - org.openhab.binding.jeelink
2019-12-10 18:12:21.114 [DEBUG] [l.connection.JeeLinkSerialConnection] - Creating serial connection for port /dev/ttyUSB1 with baud rate 57600...

==> /var/log/openhab2/events.log <==
2019-12-10 18:12:21.114 [hingStatusInfoChangedEvent] - 'jeelink:jeelinkUsb:75d8aeec' changed from UNINITIALIZED to INITIALIZING

==> /var/log/openhab2/openhab.log <==
2019-12-10 18:12:21.117 [DEBUG] [l.connection.JeeLinkSerialConnection] - Opening serial connection to port /dev/ttyUSB1 with baud rate 57600...
2019-12-10 18:12:21.129 [DEBUG] [ding.jeelink.internal.JeeLinkHandler] - Connection to port /dev/ttyUSB1 opened.
2019-12-10 18:12:21.134 [DEBUG] [ding.jeelink.internal.JeeLinkHandler] - Init commands scheduled in 10 seconds.

==> /var/log/openhab2/events.log <==
2019-12-10 18:12:21.136 [hingStatusInfoChangedEvent] - 'jeelink:jeelinkUsb:75d8aeec' changed from INITIALIZING to ONLINE

==> /var/log/openhab2/openhab.log <==
2019-12-10 18:12:21.137 [DEBUG] [ding.jeelink.internal.JeeLinkHandler] - Monitoring job started.

==> /var/log/openhab2/openhab.log <==
2019-12-10 18:12:30.464 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB0: OK 9 2 1 4 222 45
2019-12-10 18:12:30.467 [TRACE] [.LaCrosseTemperatureReadingConverter] - Creating reading from: OK 9 2 1 4 222 45
2019-12-10 18:12:30.587 [DEBUG] [sse.LaCrosseTemperatureSensorHandler] - updating states for thing Temperatur Filamentbox1 (12): temp=22.7 (22.710003), humidity=42, batteryNew=false, batteryLow=false
2019-12-10 18:12:30.704 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB0: OK 9 8 1 4 26 106
2019-12-10 18:12:30.706 [TRACE] [.LaCrosseTemperatureReadingConverter] - Creating reading from: OK 9 8 1 4 26 106
2019-12-10 18:12:31.136 [DEBUG] [ding.jeelink.internal.JeeLinkHandler] - Sending init commands for port /dev/ttyUSB1: fx;X21
2019-12-10 18:12:31.140 [DEBUG] [connection.AbstractJeeLinkConnection] - Writing to device on port /dev/ttyUSB1: [fx, X21]
2019-12-10 18:12:21.114 [hingStatusInfoChangedEvent] - 'jeelink:jeelinkUsb:75d8aeec' changed from UNINITIALIZED to INITIALIZING
2019-12-10 18:12:21.136 [hingStatusInfoChangedEvent] - 'jeelink:jeelinkUsb:75d8aeec' changed from INITIALIZING to ONLINE

I don't receive any values from it.

Usually after this I can invoke the init commands manually very easily using echo via bash

[18:16:23] root@openhab:# echo "fx\n" >> /dev/ttyUSB1
[18:16:27] root@openhab:# echo "X21\n" >> /dev/ttyUSB1

Once done so I can see the following messages in the trace:

==> /var/log/openhab2/openhab.log <==
2019-12-10 18:17:11.904 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB1: r52D6E5000132000F64693E0E
2019-12-10 18:17:12.425 [TRACE] [connection.AbstractJeeLinkConnection] - Read line from port /dev/ttyUSB1: r52D6E5000132000F64693E0C
vbier commented 4 years ago

Are you sure you have the new version running?

2019-12-10 18:12:31.140 [DEBUG] [connection.AbstractJeeLinkConnection] - Writing to device on port /dev/ttyUSB1: [fx, X21]

should no longer be in the logs.

NightDragon1 commented 4 years ago

I expected so: 2019-12-10 17:48:44.238 [INFO ] [org.apache.felix.fileinstall ] - Installing bundle org.openhab.binding.jeelink / 2.5.0.201912101413 2019-12-10 17:48:44.858 [INFO ] [org.apache.felix.fileinstall ] - Started bundle: file:/usr/share/openhab2/addons/org.openhab.binding.jeelink-2.5.0-SNAPSHOT.jar

NightDragon1 commented 4 years ago

give me a few minutes - I'll make sure that 2.4.0 is removed...

vbier commented 4 years ago

Let us continue the discussion here: https://community.openhab.org/t/binding-configuration-for-revolt-radio-energy-meter-nc-5262/14186/4.