LightwaveRF Binding Updated

Hey @neil_renaud,

Is there any functionality for accessing the ‘moods’?

I was just looking into emulating the way I’ve got my PHP set up at the moment. One of the things I want to do is to switch the house to ‘night’ mode when I arm the alarm when we go to bed. This switches all the lights off, apart from a few in the kids bedrooms.
At the moment I do that by sending an ‘all off’ mood to the living room, kitchen, halls, outside lights etc, and a ‘mood 2’, or in fact, do nothing (leave them as they are) for the kids rooms. It means I only have to send about 6 or 7 commands and all the lights do what they’re supposed to do.

This is my ‘states’ PHP function.

> function statecontrol($state_to_convert)
>     {
>         if ($state_to_convert == "on")
>         {
>             $devicestatus = "F1";
>         }
>         else if ($state_to_convert == "off")
>         {
>             $devicestatus = "F0";
>         }
>         else if ($state_to_convert == "alloff")
>         {
>             $devicestatus = "Fa";
>         }
>         else if ($state_to_convert == "mood1")
>         {
>             $devicestatus = "FmP1";
>         }
>         else if ($state_to_convert == "mood2")
>         {
>             $devicestatus = "FmP2";
>         }                
>         else if ($state_to_convert == "mood3")
>         {
>             $devicestatus = "FmP3";
>         }
>         else if ($state_to_convert == "1")
>         {
>             $devicestatus = "FdP1";
>         }
>         else if ($state_to_convert >= "2")
>         {
>             $devicestatus = "FdP" . ROUND($state * 0.32);
>         }
>     return $devicestatus;
>     }

So I’ve got access to the ‘all off’ and ‘mood x’ options too. To replicate that in openHAB I was thinking I’d create a virtual item like this:

> Switch Light_g00_room01 "Kitchen Master" <kitchen> (allLights) { lightwaverf="room1,device=XXX,type=SWITCH" }

The obvious question, what is XXX?!

Does that make sense? I don’t think I’ve explained it very well, sorry!


I didn’t code in the moods as in theory you’d code up rules in openhab instead of having hard coded memory in your wifi link. However in reality the Lightwave wireless protocol is quite slow to send each message (and the wifi link doesn’t help as it doesn’t seem to queue messages) so I can see why you would want it. I will take a look but it might not be this side of Christmas.



Yeah I was thinking about a more robust openHAB based system, like you say. I could have a combination of groups and/or virtual items to define moods etc. But I’m very aware of the slowness of the WiFi link responses, so having to only send 7-8 messages out of openHAB would be much slicker at this end.

As I mentioned with my problems with the timers I’d set up and forgotten about on the WiFi link, I don’t like the fact the lightwaverf app etc is a little bit obscure and ‘hidden’. I would prefer to have a very readable file in openHAB that I can look at in 3 years time, and understand how things are set up.

I really only want to achieve two main scenarios. A custom ‘all off’ type behaviour that gets triggered 15 minutes after the alarm is ‘stay armed’. As that means the last person has gone to bed, and the only lights that need to remain on are the nightlights in the kids bedrooms (I’ll probably have a ‘guests’ switch that will disclude the guest bedrooms in case the in-laws are reading in bed or something!)

The other scenario will come into play when the alarm is disarmed. I’m planning on using the Astro binding to work out whether it’s dark (or going dark) outside, and to then set the lights to ‘normal’ mode. We do this manually now via my lightwave PHP script and a custom dashboard we all have on our iPhones. Obviously I can have a similar rule in openHAB that runs before sunset to check to see if the alarm is armed (therefore whether the house is occupied). And either switch on ‘normal’ lighting, or maybe switch on some low level lights even if we’re not home as a security measure.

So both are trivial to do if I can send ‘mood’ messages to the WiFi link. But similarly, I could establish enmeshed groups that meet the same ends, using a ‘for each’ type approach for the group. But as you say, this could cause problems with the WiFi Link delays. Although, I think my PHP script waits for a second between broadcasts anyway, and it’s not too sluggish.

Thanks again Neil for all your efforts on the lightwave binding. Did I read somewhere that you’re developing it into OH2?


I’ve not started looking at porting this to OH2 yet. Basically I wrote it to use in my house so until OH2 is ready for use in a system we depend on I won’t install OH2 at home and therefore have no way to test OH2.

However as long as OH2 is the future then I will eventually port it.


New release Alpha6… includes Mood, All Off and Radiator Valve positions.

I’ve also swapped the relay around so it follows the lightwave spec I have. Let me know of any issues here.

Updated Lightwave Binding including:

  1. Improved the message sending and receiving so both can happen at the same time
  2. Added support for Relays
  3. Added support for Energy Monitor
  4. Added support for status message from lightwave wifi link
  5. Tidied code and improved inheritence
  6. Added Functional Test
  7. Added All Off Message Support
  8. Added support for Moods
  9. Fixed UPDATETIME on Wifi Link and Heat Info Messages

To Use MOOD and ALL_OFF. You provide the Room and the type ALL_OFF or MOOD. Although note - if your mood is set light 1 to 50% and light2 to 75% this will send the command to Lightwave to do that but Openhab will have no idea what the mood does to your lights and as such the status of your lights won’t be represented in Openhab. The same applies for ALL_OFF - although here I might consider some hackery as it should be achievable to set all lights in a room off.

1 Like

Cheers @neil_renaud. You are a gent. I’ve just downloaded and installed so I’ll let you know how I get on with the moods (lightwaverf moods that is!)

Hi @neil_renaud,

Just got around to working on this again. Can I ask for some clarification on how to access the ALL_OFF and mood stuff? Should I create a new switch item with the correct ‘room’ assignment and then give it an ALL_OFF or MOOD1 somehow?

I’ve just been testing using openHAB to cycle through a group of lights using a ‘foreach’ and it takes bloody ages because of the delay in sending each message. It works, but I’m sure sending 6 moods is quicker than 15 device specific commands!

I don’t really find a need to specify dimming levels etc for lights when they switch on, I kind of leave that to us to set manually when we’re using the room, and let the automation just return it to the last state it was in when it switches it back on.

Thanks again Neil.

I’m still getting intermittent problems with the connection to the WiFi Link. It was fine last night. Would send commands with no problems. Yet now I’m getting a load of errors complaining about openHAB not receiving an ‘OK’.

I’ve changed nothing on either box since last night!

2015-12-17 13:25:04.256 [DEBUG] [.b.l.i.LightwaveRFSenderThread] - Sending command[306,!R7D1F0
2015-12-17 13:25:04.758 [INFO ] [.b.l.i.LightwaveRFSenderThread] - Ok message not received for 306,!R7D1F0
, retrying again. Retry count 4
2015-12-17 13:25:06.760 [DEBUG] [.b.l.i.LightwaveRFSenderThread] - Sending command[306,!R7D1F0
2015-12-17 13:25:07.265 [INFO ] [.b.l.i.LightwaveRFSenderThread] - Ok message not received for 306,!R7D1F0
, retrying again. Retry count 5
2015-12-17 13:25:09.267 [DEBUG] [.b.l.i.LightwaveRFSenderThread] - Sending command[306,!R7D1F0
2015-12-17 13:25:09.769 [ERROR] [.b.l.i.LightwaveRFSenderThread] - Unable to send message 306,!R7D1F0
 after 5 attemps giving up

I think it must be the WiFi Link being flakey. It’s quite a serious problem, as it sets off the RF Jam detection on my DSC alarm because it’s flooding the airwaves with RF!. Which would set the whole alarm off if I wasn’t in.

EDIT: Actually, I don’t think it is the WiFi Link. I restarted openHAB and voila, it works again…

2015-12-17 13:31:28.236 [DEBUG] [.b.l.i.LightwaveRFSenderThread] - Sending command[211,!R7D1F0
2015-12-17 13:31:28.347 [DEBUG] [.l.i.LightwaveRFReceiverThread] - Message received from: /192.168.1.xx message:211,OK

2015-12-17 13:31:28.352 [INFO ] [.b.l.i.LightwaveRFSenderThread] - Ok message received for 211,!R7D1F0

Yeah there was a bug I’ve just fixed here:

Essentially overnight there is a message that I wasn’t parsing correctly and it caused the receiving thread to die. This release should fix it.

For ALL_OFF as we don’t have a push button in openhab you’ll need to bind it to a switch. Turning the switch on or off will send an ALL_OFF.

For Moods you need a Number item and then you set it to the number of the mood you want to send… so set it to 1 will call mood 1, 2 will call mood2 etc. I’m not sure how they are numbered but I suspect in the Lightwave App the first mood you entered is number 1 etc.

1 Like


@SupraWez, @tinkerfailure, @morak

Can you comment on the pull request if you have tested and are happy this is working? Then I can get the changes merged properly into Openhab.

1 Like

Also if the resend logic causes issues with the alarm I’d suggest you might want to try setting the okTimeout higher in openhab.cfg. In reality I think the ok messages are quite quick so really this will just delay how quickly it retries.

Also I could make the number of retries configurable.

Both of these might stop the alarm going off if there is a genuine issue getting to the wifi link (e.g its fuse blew in the middle of the night)?


Yea I set the pause between messages to 500ms and the lenght of time to wait for an OK to 5000ms. Seems to work OK.
It did cross my mind to have the number of retries configurable. That could be quite handy.

Just so you know, I’ve just spotted an error on the tail of the log:

2015-12-19 00:19:47.183 [ERROR] [l.internal.LightwaveRfWifiLink] - Error converting message: *?{"trans":1338,"mac":"03:xx:xx","cmd":"get_duskdawn","lat":xx.xx,"long":xx.xx,"offset":0}
    2015-12-19 00:19:47.216 [ERROR] [l.internal.LightwaveRfWifiLink] - Error converting message: *!{"trans":1339,"source_id":"03:xx:xx","source":"wfl","type":"log","payload":"DAWN/DUSK SET"}

But I still have ‘normal’ connectivity with the WiFi Link, no errors about it being unregistred,

Yeah I will try to make the retries configurable.

That message is the one that caused the problem where it died (interesting I don’t get the second message that is the response). I will look to make it not error in the future but time is short at the moment.

I’ve just pushed out another version allowing you to configure some items to be in only or out only. I’m going to start to use this to allow me to send the messages using the RFXCOM binding but get updates if someone uses the app.

It is here:

Did Mood and ALL_OFF work for you?

Hey @neil_renaud

First off happy new year.

I have not been on here for a few days so have just upgraded from ALPHA5 straight to ALPHA9 and all looks good to me, my dimming is working etc, in fact it all seems a little more responsive than before.

Any actions taken in the official LightwaveRF app are also showing up in the OpenHAB GUI but not the other way round, I guess this is normal behavior.


1 Like

Happy New Year.

Glad it is working well.

Yeah I’m not sure the Lightwave App will replicate any actions you do in openhab it isn’t well coded and I’m not sure they’d be expecting other systems to send commands.

That being said I’d personally ditch the lightwave app and only use openhab you could easily create a sitemap to replicate the lightwave app functionality.

Also I assume that if you send a dimming command in the lightwave app, close the app and open it again later it probably don’t load the same dimming level you set…after all the one problem with Lightwave is it is one way communication so there is no way for the app to know the current setting.


I am having problems getting a dimmer working. If I set up an item as a switch it works OK but when I set a dimmer up I cannot get it working and don’t see any commands being sent in the log file. Clearly I have set up the dimmer wrongly.

My item is:
Dimmer Lamp_Master_Bedroom "Master Bedroom Lamp Dimmer [%d %%]" (gFF_MasterBedroom) { lightwaverf="room=1,device=3,type=DIMMER" }

and the sitemap entry is:
Slider item=Lamp_Master_Bedroom

with a rule based on the dimmer rule in the open demo rule file.

Can anyone point me to a correct set of declarations to get this to work?

P.S. I have Moods working OK. They start numbering from 0 (zero).

On your sitemap can you try adding:

Group item=gFF_MasterBedroom

And when you go into it see if the Dimmer works there?

I’ve never set them up individually as you mention (although I’m sure there will be a way).

Hey @neil_renaud

Just a quick one, I have noticed since the upgrade that the LightWave Wifi Link stats are no longer updating.

The log shows error converting message :-

2016-01-19 11:32:43.419 [DEBUG] [.l.i.LightwaveRFReceiverThread:118 ]- Message received from: / message:*!{"trans":293,"mac":"00:00:00","time":1453203224,"type":"hub","prod":"lwl","fw":"N2.91Z","uptime":950631,"timeZ":0,"lat":00.00,"long":-00.00,"duskT":1453220997,"dawnT":1453190795,"tmrs":0,"evns":0,"run":0,"macs":9,"ip":"","devs":0}
2016-01-19 11:32:43.420 [ERROR] [l.internal.LightwaveRfWifiLink:173 ]- Error converting message: *!{"trans":293,"mac":"00:00:00","time":1453203224,"type":"hub","prod":"lwl","fw":"N2.91Z","uptime":950631,"timeZ":0,"lat":00.00,"long":-00.00,"duskT":1453220997,"dawnT":1453190795,"tmrs":0,"evns":0,"run":0,"macs":9,"ip":"","devs":0}

Hey @neil_renaud

Just seen the ALPHA10 release which I have now upgraded, thanks.

No problem.