LightwaveRF Binding Updated

Everything is working fine still. But just out of interest, I checked openhab.log before I left for work this morning, and noticed the following:

> 2015-11-25 06:41:59.965 [ERROR] [l.internal.LightwaveRfWifiLink] - Error converting message: :030Fxx,361,!R7D1F0|mainlight|Off

> 2015-11-25 06:42:01.338 [ERROR] [l.internal.LightwaveRfWifiLink] - Error converting message: :030Fxx,100,!F*p

> 2015-11-25 06:42:01.975 [ERROR] [l.internal.LightwaveRfWifiLink] - Error converting message: :030Fxx,361,!R7D1F0|mainlight|Off

> 2015-11-25 06:42:02.678 [ERROR] [l.internal.LightwaveRfWifiLink] - Error converting message: :030Fxx,362,!R7D1F1|mainlight|On

> 2015-11-25 06:42:07.661 [ERROR] [l.internal.LightwaveRfWifiLink] - Error converting message: :030Fxx,100,!F*p

After scratching my head for a bit, I thought it looked like a timer I had set up ages ago to turn my sonā€™s bedroom light off in the night once he was asleep (something Iā€™m hoping openHAB will make easier and more transparent for me now!).

But looking at those times, theyā€™re pretty weird (thatā€™s around the time he gets up - heā€™s 3!) and it sends two ā€˜offsā€™ and then an ā€˜onā€™, which isnā€™t how I would ever have set it up in the first place. Theyā€™re roughly around the time of the start of ā€˜civil twilightā€™ but that could be a coincidence.

So even though I did a hard reset on the WiFi Link, it looks like it might be doing something funky with an old setup. Or more likely, the Lightwave RF cloud server is attempting to send a command to my WiFi Link, but the device is rejecting it because itā€™s been deregistered.

Interestingā€¦the messages there are different to the ones that I handle (which is why the error comes up)ā€¦

**030Fxx,**361,!R7D1F0|mainlight|Off

The bit in bold isnā€™t supported and as far as I know isnā€™t in the API unless theyā€™ve changed it.

These commands you see must have been sent by either the iOS/Andriod App or some thing other than openhab on your network. Could anything else be sending updates?

I know the issue with the Dusk/Dawn time and will fix as soon as I can. I just need to multiply the number by 1000 for Java.

Yeah I think this is the breakdown:

030Fxx = Last few characters of the MAC address of WiFi Link (Iā€™m going to obfuscate that in the original post, can you too @neil_renaud, slight security risk!)

361 = command number, maybe 3xx numbers come from the cloud?

!R7D1F0|mainlight|Off = device mapping & action

So yeah I think itā€™s coming from the cloud server, based on a timer I set up ages ago, and completely forgot about (it would have been in v1 of their iOS app - theyā€™re now on v3!)

Fixed date parsing.

Also added an extra bit of info to the debug logging that will say which IP a message came from. @tinkerfailure if you enable debug logging you should then be able to see where those commands came from. It will look like this:

Message received from: ā€œreceivePacket.getAddress()ā€ message: ā€œreceivedMessageā€

@neil_renaud I have installed ALPHA5, I like the addition of the IP address in the logs, nice work.

I am still waiting on a status message to see if dusk / dawn look better.

I too have alpha5 installed now. The date is now formatted thus:

25 November 2015 at 07:36:02

Which is exactly what I was expecting. Thank you @neil_renaud.

Iā€™ve set the logging level to see what I get from that weird message tomorrow morning at 6am!

Same here, just received a status message and dusk / dawn now working, I also changed my formatting to match yours @tinkerfailure

What formatting do you have uptime?

Big thanks @neil_renaud

Iā€™ve still got it how you had it "Wifi Link Uptime [%.2f]". Itā€™s just a number isnā€™t it, not a Datetime? Have you managed to change it?

Turns out I was getting connection requests from an IP on my network. Checked on the router and itā€™s my iPhoneā€¦

Opened up the old Lightwave iOS app (where Iā€™d created the timers) and tried to delete them using the app. It gave me a load of errors, so I tried sending the string via the shell on the Pi and it seemed to accept the command:

> 2015-11-25 21:23:43.960 [DEBUG] [.l.i.LightwaveRFReceiverThread] - Message received from: /192.168.1.[iphone] message:480,!FcP"*"|Cancel All|Seq & Timers
> 2015-11-25 21:23:43.962 [ERROR] [l.internal.LightwaveRfWifiLink] - Error converting message: 480,!FcP"*"|Cancel All|Seq & Timers
> 2015-11-25 21:23:44.266 [DEBUG] [.l.i.LightwaveRFReceiverThread] - Message received from: /192.168.1.[pi] message:480,OK

> 2015-11-25 21:24:37.440 [DEBUG] [.l.i.LightwaveRFReceiverThread] - Message received from: /192.168.1.[pi] message:480,OK

> 2015-11-25 21:24:48.187 [DEBUG] [.l.i.LightwaveRFReceiverThread] - Message received from: /192.168.1.[pi] message:480,OK

> 2015-11-25 21:24:54.777 [DEBUG] [.l.i.LightwaveRFReceiverThread] - Message received from: /192.168.1.[pi] message:480,OK

> 2015-11-25 21:25:43.692 [DEBUG] [.l.i.LightwaveRFReceiverThread] - Message received from: /192.168.1.[iphone] message:482,!FcP"*"|Cancel All|Seq & Timers
> 2015-11-25 21:25:43.695 [ERROR] [l.internal.LightwaveRfWifiLink] - Error converting message: 482,!FcP"*"|Cancel All|Seq & Timers
> 2015-11-25 21:25:44.000 [DEBUG] [.l.i.LightwaveRFReceiverThread] - Message received from: /192.168.1.[pi] message:482,OK

I get this whenever I have the iOS app open in the foreground:

> 2015-11-25 21:36:45.941 [DEBUG] [.l.i.LightwaveRFReceiverThread] - Message received from: /192.168.1.xxx message::030F47,100,!F*p

Interesting as when I open the official LightwaveRF app on an iOS device I get these version messages and the version item I have configured is updated correctly, the version message is coming from the new Wifi Link and the other message from the iOS device :-

2015-11-25 21:45:19.070 [DEBUG] [.l.i.LightwaveRFReceiverThread:128 ]- Message received from: /*.*.*.* message:100,?V="N2.91Y"
2015-11-25 21:45:19.071 [DEBUG] [.l.internal.LightwaveRfBinding:292 ]- Publishing Update org.openhab.binding.lightwaverf.internal.command.LightwaveRfVersionMessage@3c064614 to [LW_WifiL_Ver]
2015-11-25 21:45:19.072 [INFO ] [.l.internal.LightwaveRfBinding:300 ]- Update from LightwaveRf ItemName[LW_WifiL_Ver], State[N2.91Y]
2015-11-25 21:45:26.472 [DEBUG] [.l.i.LightwaveRFReceiverThread:128 ]- Message received from: /*.*.*.* message:100,!F*p

UPDATE: just did some more testing and when the LightwaveRF app is in the foreground I am getting version messages over and over, not a problem just an observation.

Yeah me too. Will go away once we turn DEBUG off.

UPDATE: any idea how the WiFi Link knows our Lat/Long?

Just been doing some basic testing on the Energy Monitor implementation and it seems to work perfectly from what I can tell so far:

2015-11-26 01:06:52.822 [INFO ] [.l.internal.LightwaveRfBinding] - Update from LightwaveRf ItemName[EnergyUseYesterday], State[11554]
2015-11-26 01:06:52.825 [INFO ] [.l.internal.LightwaveRfBinding] - Update from LightwaveRf ItemName[EnergyUseCurrent], State[540]
2015-11-26 01:06:52.825 [INFO ] [runtime.busevents             ] - EnergyUseYesterday state updated to 11554
2015-11-26 01:06:52.827 [INFO ] [.l.internal.LightwaveRfBinding] - Update from LightwaveRf ItemName[EnergyUseToday], State[390]
2015-11-26 01:06:52.828 [INFO ] [runtime.busevents             ] - EnergyUseCurrent state updated to 540
2015-11-26 01:06:52.831 [INFO ] [runtime.busevents             ] - EnergyUseToday state updated to 390

Many thanks for your efforts on this @neil_renaud

I believe the app does that to detect if it is on your local network or remote. As youā€™ve seen it just constantly sends a registration message to which the hub replies with the Version message that doesnā€™t include all the other data.

I didnā€™t change the uptime - Are you fairly sure it is the date the router started as opposed to a number of seconds, minutes etc that it has been up? What happens if you power on/off your router do you get a number close to 0 or something that is obviously the date you restarted it? One check you can do is take the number you get. Times it be 1000 (Add 3 "0"s on the end). Then enter it into the left box on this site to see what date it would represent: http://www.fileformat.info/tip/java/date2millis.htm

In my mind uptime is a number of seconds/minutes/hours and not a date however if it is a real date Iā€™ll change it.

Also Iā€™ve not implemented Timers. These are pushed to the wifi link I believe so that it actually runs the timer at a given time. I didnā€™t see an easy/nice way to fit that into Openhabā€¦

Yeah thatā€™s true, it probably is a count of seconds since it last rebooted. Or milliseconds! I just need to reformat it into something more readable likexx days, xx hours and xx minutes or something like that. Iā€™ll write a simple rule.

As far as Iā€™m concerned the timers on the WiFi Link become obsolete once openHAB is involved. As I found, there was an ancient one Iā€™d set up, forgotten about, and had no way of seeing it was there! Iā€™d much rather have something I can control more explicitly like rules in openHAB.

Agreed, I think uptime is more likely just seconds since last reset.

@tinkerfailure I am guessing that the Lat / Lon maybe related to your IP / ISP, mine is miles off but I dont see how it can be corrected.

I think you set a region when you setup your on line account with themā€¦

Canā€™t remember the setup. I guess it must have asked something.

Maybe it does a reverse whois on the IP address the WiFi Link appears from or something. I think mine looks pretty accurate for where we are.
I have entered accurate ones for the astro binding anyway, so Iā€™ll be using that for sunset/sunrise type stuff.

I checked the logs again this morning, and didnā€™t see those weird timer messages, so hopefully theyā€™re deleted now. I switched a few lights on and off from the iOS interface and it paused a bit and then caused the RF jam alarm to go off on my DSC alarm! Never had that before. Hope thatā€™s just a one off.

What fun and gamesā€¦

I can change my location in the Andriod app settings. Just changed from Birmingham to London.

Oh yeah, just found my location in the new iOS app. Donā€™t ever remember setting it though. I think it must have done a reverse whois on my IP. Thatā€™s the most logical way to do it, as far as I can see.

Iā€™ve been looking into the uptime thing. I thought there would be a simple inbuilt function to convert seconds to days/hours/minutes. But I canā€™t seem to find anything.

The reason I expected it was because you can do just that in PHP. You can use the gmdate() function:

> echo gmdate("H:i:s", 685);

Where 685 is the number of seconds. Giving the result:

> 00:11:25

If it was set to Birmingham I suspect that default it to their office location :wink:

This might help converting the time - as openhab uses Joda I believe you can use it in the rules but Iā€™ve no experience iā€™m sure wiki/forum might have some examples:

Neil