User Tools

Site Tools


openhab

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
openhab [2018/01/02 18:36]
robm created
openhab [2018/01/03 00:31] (current)
robm
Line 17: Line 17:
 Create the following start-up file, I called mine ''/opt/openhab/run.sh'': Create the following start-up file, I called mine ''/opt/openhab/run.sh'':
  
-<code:bash> +<code:bash>#!/bin/bash -x
-#!/bin/bash -x+
 CMD=( CMD=(
     docker run     docker run
Line 35: Line 34:
     openhab/openhab:2.3.0-snapshot-amd64-debian     openhab/openhab:2.3.0-snapshot-amd64-debian
 ) )
-"${CMD[@]}"+"${CMD[@]}" || docker start --attach --interactive openhab
 </code> </code>
  
Line 71: Line 70:
 <code> <code>
 openhab> log:tail openhab> log:tail
 +</code>
 +
 +===== Manually pairing and testing control via LightwaveRF Wi-Fi Link =====
 +
 +Fear, uncertainty, and doubt (FUD) caused me some issues when I was first installed the LightwaveRF bindings for openHAB, so I ended up using a manual method to pair **and** test my pairing.
 +
 +Assuming you have not previously paired the device you are running openHAB on (VirtualBox VM in my case) with the LighwaveRF Wi-Fi Link the following command will cause its green LED to blink, inviting you to press the LINK button. (I understand that newer models which have a screen ask you if you want to pair a new app).
 +
 +<note tip>You may need to ''sudo apt install socat''</note>
 +
 +<code>
 +echo -ne '100,!F*p' | socat STDIN UDP-DATAGRAM:255.255.255.255:9760,broadcast,sourceport=9761
 +</code>
 +
 +The LightwaveRF Wi-Fi Link will ask you to accept the pairing (blinking LED on my model). Do so. The LightwaveRF Wi-Fi Link will now accept commands originating from your system (identified by its Ethernet MAC address). So in the case of my Virtual Machine, the virtual NIC's MAC is what is important.
 +
 +I tested control by running the following to send commands to the first light in the first room I ever linked to the LightwaveRF Wi-Fi Link (the LWLink learnt of this device when I added it to the [[https://play.google.com/store/apps/details?id=com.dolphin.lightwaverf.tcg|Android app]])
 +
 +Room 1, Light 1, Function 0 (OFF):
 +
 +<code>
 +echo -ne '100,!R1D1F0' | socat STDIN UDP-DATAGRAM:255.255.255.255:9760,broadcast,sourceport=9761
 +</code>
 +
 +Room 1, Light 1, Function 1 (ON):
 +
 +<code>
 +echo -ne '100,!R1D1F1' | socat STDIN UDP-DATAGRAM:255.255.255.255:9760,broadcast,sourceport=9761
 +</code>
 +
 +<note tip>The LightwaveRF Link protocol is documented at https://api.lightwaverf.com/introduction_basic_comms.html</note>
 +
 +===== Configuring the (not yet installed) LightwaveRF Bindings =====
 +
 +Best to create the configuration file *before* installing the bindings to avoid some noisy start-up messages.
 +
 +The instructions for the legacy (openHAB v1) bindings for LightwaveRF are [[https://github.com/openhab/openhab1-addons/wiki/LightwaveRF-Binding|here]].
 +
 +Create a new file at ''/opt/openhab/conf/services/lightwaverf.cfg'' (all files in this directory are named, so just ensure it is unique. Most guides call this file ''openhab.cfg''), and enter the following:
 +
 +<note important>Do **not** copy the sample at [[https://github.com/openhab/openhab1-addons/wiki/LightwaveRF-Binding|GitHub]], it has errors!
 +
 +''lightwaveRf:ip'' should be ''lightwaverf:ip'' (note the case!) throughout, and the sendport and receiveport numbers are backwards!
 +
 +</note>
 +
 +<code:bash>################################### LightwaveRf Binding #####################################
 +#
 +# The IP Address of the LightwaveRf Wifi Link you can use the broadcast address (required)
 +lightwaverf:ip=255.255.255.255
 +# The port to monitor for messages you shouldn't need to change this
 +lightwaverf:receiveport=9761
 +# The port to send messages on, it will also be monitored for incoming messages
 +# you shouldn't need to change this
 +lightwaverf:sendport=9760
 +# For a new computer you will need to register it with the wifi link to be allowed to send messages
 +# setting this to true we will send a registration message on startup. You will need to confirm
 +# registration on the wifi link. There is no harm leaving this as true but you can set to false
 +# once you have registerd for the first time.
 +lightwaverf:registeronstartup=false
 +# Delay between sending messages in ms to avoid swapming Wifi Link
 +lightwaverf:senddelay=2000
 +# Timeout for OK Messages in ms, we will retry messages we don't receive an ok for in the timeout
 +lightwaverf:okTimeout=1000
 </code> </code>
  
Line 92: Line 155:
  
 <code> <code>
-18:22:05.597 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: IP[255.255.255.255+22:48:21.683 [INFO ] [htwaverf.internal.LightwaveRfWifiLink] - LightwaveRfWifiLink Connection Stopped 
-18:22:05.599 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: ReceivePort[9761+22:48:21.735 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: IP[192.168.1.50
-18:22:05.599 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: Send Port[9760+22:48:21.739 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: ReceivePort[9760
-18:22:05.600 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: Register On Startup[true+22:48:21.740 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: Send Port[9761
-18:22:05.600 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: Send Delay [100+22:48:21.740 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: Register On Startup[false
-18:22:05.602 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: Timeout for Ok Messages [500+22:48:21.741 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: Send Delay [2000
-18:22:05.606 [INFO ] [htwaverf.internal.LightwaveRfWifiLink] - Starting LightwaveRfWifiLink Connection +22:48:21.741 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: Timeout for Ok Messages [1000
-18:22:05.830 [ERROR] [htwaverf.internal.LightwaveRfWifiLink] - Error converting message: *!{"trans":483,"mac":"20:3B:85","time":1514917325,"pkt":"error","fn":"nonRegistered","payload":"Not yet registered. See LightwaveLink"+22:48:21.742 [INFO ] [htwaverf.internal.LightwaveRfWifiLink] - Starting LightwaveRfWifiLink Connection
-18:22:06.128 [INFO ] [verf.internal.LightwaveRFSenderThread] - Ok message not received for 100,!F*p +
-, retrying again. Retry count 2 +
-18:22:06.433 [ERROR] [htwaverf.internal.LightwaveRfWifiLink] - Error converting message: *!{"trans":484,"mac":"20:3B:85","time":1514917326,"pkt":"error","fn":"nonRegistered","payload":"Not yet registered. Send !F*p to register"+
-18:22:06.730 [INFO ] [verf.internal.LightwaveRFSenderThread] - Ok message not received for 100,!F*p +
-, retrying again. Retry count 3 +
-18:22:07.048 [ERROR] [htwaverf.internal.LightwaveRfWifiLink] - Error converting message: *!{"trans":485,"mac":"20:3B:85","time":1514917326,"pkt":"error","fn":"nonRegistered","payload":"Not yet registered. Send !F*p to register"+
-18:22:07.333 [INFO ] [verf.internal.LightwaveRFSenderThread] - Ok message not received for 100,!F*p +
-, retrying again. Retry count 4 +
-18:22:07.560 [ERROR] [htwaverf.internal.LightwaveRfWifiLink] - Error converting message: *!{"trans":486,"mac":"20:3B:85","time":1514917327,"pkt":"error","fn":"nonRegistered","payload":"Not yet registered. Send !F*p to register"+
-18:22:07.935 [INFO ] [verf.internal.LightwaveRFSenderThread] - Ok message not received for 100,!F*p +
-, retrying again. Retry count 5 +
-18:22:08.174 [ERROR] [htwaverf.internal.LightwaveRfWifiLink] - Error converting message: *!{"trans":487,"mac":"20:3B:85","time":1514917328,"pkt":"error","fn":"nonRegistered","payload":"Not yet registered. Send !F*p to register"+
-18:22:08.538 [ERROR] [verf.internal.LightwaveRFSenderThread] - Unable to send message 100,!F*p +
- after 5 attempts giving up+
 </code> </code>
  
-You need to press the LINK button on the LightwaveRF Wi-Fi Link during those messages to pair it. This only has to be done once, and permits the MAC address of the VM to send commands to the LightwaveRF Wi-Fi Link. +If you change the configuration file, you can restart (all) legacy openHAB v1 bindings by restarting the compatibility layer bundle from the interactive prompt of OpenHAB (the ''/opt/openhab/run.sh'' script):
- +
-If you miss get as far at the "giving up" message you can restart the binding to try again. Legacy bindings do not appear in the list of bundles, **but** you can effectively reload all of them by restarting the legacy compatibility layer.+
  
 <code> <code>
-openhab> bundle:restart "openHAB 1.x Compatibility Layer" +bundle:restart "openHAB 1.x Compatibility Layer"
-openhab> +
-</code> +
- +
-This is what success looks like in the output of ''log:tail'': +
- +
-<code> +
-18:34:28.024 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: IP[255.255.255.255] +
-18:34:28.025 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: ReceivePort[9761] +
-18:34:28.026 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: Send Port[9760] +
-18:34:28.026 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: Register On Startup[true] +
-18:34:28.026 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: Send Delay [100] +
-18:34:28.027 [INFO ] [ghtwaverf.internal.LightwaveRfBinding] - LightwaveBinding: Timeout for Ok Messages [500] +
-18:34:28.027 [INFO ] [htwaverf.internal.LightwaveRfWifiLink] - Starting LightwaveRfWifiLink Connection +
-18:34:28.227 [ERROR] [htwaverf.internal.LightwaveRfWifiLink] - Error converting message: *!{"trans":509,"mac":"20:3B:85","time":1514918067,"pkt":"error","fn":"nonRegistered","payload":"Not yet registered. See LightwaveLink"+
-18:34:28.546 [INFO ] [verf.internal.LightwaveRFSenderThread] - Ok message not received for 100,!F*p +
-, retrying again. Retry count 2 +
-18:34:28.841 [ERROR] [htwaverf.internal.LightwaveRfWifiLink] - Error converting message: *!{"trans":510,"mac":"20:3B:85","time":1514918068,"pkt":"error","fn":"nonRegistered","payload":"Not yet registered. Send !F*p to register"+
-18:34:29.046 [ERROR] [htwaverf.internal.LightwaveRfWifiLink] - Error converting message: *!{"trans":511,"mac":"20:3B:85","time":1514918068,"type":"link","prod":"lwl","pairType":"local","msg":"success","class":"","serial":""+
-18:34:29.148 [INFO ] [verf.internal.LightwaveRFSenderThread] - Ok message not received for 100,!F*p +
-, retrying again. Retry count 3 +
-18:34:29.359 [INFO ] [verf.internal.LightwaveRFSenderThread] - Ok message received for 100,!F*p +
- +
-18:34:29.359 [WARN ] [ghtwaverf.internal.LightwaveRfBinding] - No item for incoming message[100,?V="N2.94D" +
-]+
 </code> </code>
openhab.1514918202.txt.gz · Last modified: 2018/01/02 18:36 by robm