LightwaveRF Binding Updated

I’ll have to answer in stages, but here’s the first. Yes, the DimLevel works fine:

2019-05-14 10:33:04.991 [vent.ItemStateChangedEvent] - Lightwave_BedroomLight_switch changed from OFF to ON
2019-05-14 10:33:04.998 [vent.ItemStateChangedEvent] - Lightwave_BedroomLight_dimLevel changed from 100 to 55
2019-05-14 10:33:05.005 [vent.ItemStateChangedEvent] - Lightwave_BedroomLight_power changed from 0.0 to 2.0
2019-05-14 10:33:05.008 [vent.ItemStateChangedEvent] - Lightwave_BedroomLight_Power_Cost changed from 0.000 to 0.00026
2019-05-14 10:33:14.663 [vent.ItemStateChangedEvent] - Lightwave_BedroomLight_power changed from 2.0 to 18.0
2019-05-14 10:33:14.675 [vent.ItemStateChangedEvent] - Lightwave_BedroomLight_Power_Cost changed from 0.00026 to 0.00234
2019-05-14 10:34:04.585 [vent.ItemStateChangedEvent] - Lightwave_BedroomLight_switch changed from ON to OFF
2019-05-14 10:34:04.602 [vent.ItemStateChangedEvent] - Lightwave_BedroomLight_power changed from 18.0 to 0.0
2019-05-14 10:34:04.607 [vent.ItemStateChangedEvent] - Lightwave_BedroomLight_Power_Cost changed from 0.00234 to 0.000

That’s a single-gang Gen2 dimmer being driven from OpenHAB

Here is the .items file that gets created for a Gen 2 dimmer:

Switch Lightwave_BedroomLight_identify “Bedroom Light identify” (GroupGroundSocketsOther)
Switch Lightwave_BedroomLight_reset “Bedroom Light reset” (GroupGroundSocketsOther)
Switch Lightwave_BedroomLight_upgrade “Bedroom Light upgrade” (GroupGroundSocketsOther)
Number Lightwave_BedroomLight_diagnostics "Bedroom Light diagnostics "
String Lightwave_BedroomLight_periodOfBroadcast "Bedroom Light periodOfBroadcast "
Number Lightwave_BedroomLight_rgbColor "Bedroom Light rgbColor "
Switch Lightwave_BedroomLight_switch “Bedroom Light” (GroupGroundSockets)
Dimmer Lightwave_BedroomLight_dimLevel “Bedroom Light dimLevel” (GroupGroundLights)
String Lightwave_BedroomLight_dimSetup "Bedroom Light dimSetup "
Switch Lightwave_BedroomLight_protection “Bedroom Light protection” (GroupGroundSocketsOther)
Number Lightwave_BedroomLight_power “Bedroom Light power [%.1f W] (Read Only)” (GroupGroundSocketsPower)
Number Lightwave_BedroomLight_energy “Bedroom Light energy [%.2f kWh] (Read Only)” (GroupGroundSocketsEnergy)
String Lightwave_BedroomLight_bulbSetup "Bedroom Light bulbSetup "
Number Lightwave_BedroomLight_Power_Cost “Bedroom Light Power Cost [%.3f]” (GroupGroundSocketsPowerCost)
Number Lightwave_BedroomLight_Energy_Cost “Bedroom Light Energy Cost [%.2f]” (GroupGroundSocketsEnergyCost)

Here’s the Structure for the Gen 2 dimmer:

{“deviceId”:“5a6a3fbfc211836b17f98f26-28-3157328472+0”,“name”:“Bedroom Light”,“productCode”:“L21”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5b59e7cd6955591b24a9d698”,“name”:“Bedroom Light”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-88-3157328472+0”,“type”:“identify”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-89-3157328472+0”,“type”:“reset”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-90-3157328472+0”,“type”:“upgrade”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-91-3157328472+0”,“type”:“diagnostics”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-92-3157328472+0”,“type”:“periodOfBroadcast”,“writable”:true},
{“featureId”:“5a6a3fbfc211836b17f98f26-93-3157328472+0”,“type”:“rgbColor”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-94-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-95-3157328472+0”,“type”:“dimLevel”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-96-3157328472+0”,“type”:“dimSetup”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-97-3157328472+0”,“type”:“protection”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-98-3157328472+0”,“type”:“power”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-99-3157328472+0”,“type”:“energy”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-121-3157328472+0”,“type”:“bulbSetup”,“writable”:true}]}],“product”:“L21”,“device”:“dimmer”,“desc”:“Smart Dimmer”,“type”:“lwrfTwoWay_v2”,“cat”:“Lighting”,“gen”:2},

Here’s the .items for a Gen 1 Plug-In Socket Switch:

Switch Lightwave_LavaLamp_switch “Lava Lamp” (GroupGroundSockets)
Switch Lightwave_LavaLamp_protection “Lava Lamp protection” (GroupGroundSocketsOther)
Number Lightwave_LavaLamp_Power_Cost “Lava Lamp Power Cost [%.3f]” (GroupGroundSocketsPowerCost)
Number Lightwave_LavaLamp_Energy_Cost “Lava Lamp Energy Cost [%.2f]” (GroupGroundSocketsEnergyCost)

And here’s the Structure for it:

{“deviceId”:“5a6a3fbfc211836b17f98f26-14-3157328472+0”,“name”:“Out3”,“productCode”:“LW320”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5a8c99a8b6fce426e56237b9”,“name”:“Lava Lamp”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-46-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-47-3157328472+0”,“type”:“protection”,“writable”:true}]}],“product”:“LW320”,“device”:“socket”,“desc”:“Plug-In Socket”,“type”:“lwrfOneWay_v1”,“cat”:“Power”,“gen”:1},

From the Structure you can get the LWRF Product Code, the device type, the category (power or lighting) and the Gen 1 or 2 simply by pulling the right fields out of the JSON. You can do that with JSONPATH as you’re already doing, or with a regular expression. I’ve messed with both approaches and have some examples if you need.

I didn’t bother with the Gen 2 sockets as you’ve got those, but I can if you ask.

I’ve got both types of Gen 1 plug-in socket and they both look exactly the same in the structure and items file. Also I have a Gen 1 three-way relay but that shows up in the structure as three Gen1 plug-in sockets because that’s basically what the innards are. So the structure and items for that also read exactly as for the Lava Lamp (yes, I’m sad, I do have a lava lamp and I quite like it).

Thanks for that.
Its as I thought for the gen1’s: it’s just my own implementation for costs that’s been added, I just need to filter this in the original code - you can just delete the lines from your items file and also the rules file to save having to run the setup again.
Based on that I don’t think we need to determine whether an item is a gen1 or 2.

I had a little look at the bulb and dim setup yesterday but couldn’t find anything relating to them. I’ll wait for the developers to come back to me on them (lightwave have emailed me back and passed it on).

Oh and you can probably lower the refresh time to 5 seconds without any error, I’m running every 4 at present and looks all ok.

I’ll try the faster refresh. I wonder how frequent we can go before Lightwave get sick of us :wink:
I’ll delete the unused power items and I’m also going to comment out the LinkPlus time etc to reduce the load a bit.
Also I’m going to pull the DimSetup and BulbSetup for several dimmers that I know are set up different. Still no idea what the values mean but it might add a couple more pieces to the jigsaw.

If you put it down to fire every second you’ll see how long the rule takes to complete if you leave one of the time items active.
And I had it running every 3 seconds for a day and didn’t get banned

Before I get onto all the stuff I said in my previous update I would do (!), here’s a little something else from my .items file:

//LandingLights2
Switch Lightwave_LandingLights2_switch “Landing Lights 2” (GroupGroundSockets)
Dimmer Lightwave_LandingLights2_dimLevel “Landing Lights 2 dimLevel” (GroupGroundLights)
String Lightwave_LandingLights2_dimSetup "Landing Lights 2 dimSetup "
Switch Lightwave_LandingLights2_protection “Landing Lights 2 protection” (GroupGroundSocketsOther)
Number Lightwave_LandingLights2_power “Landing Lights 2 power [%.1f W] (Read Only)” (GroupGroundSocketsPower)
Number Lightwave_LandingLights2_energy “Landing Lights 2 energy [%.2f kWh] (Read Only)” (GroupGroundSocketsEnergy)
String Lightwave_LandingLights2_bulbSetup "Landing Lights 2 bulbSetup "
Number Lightwave_LandingLights2_Power_Cost “Landing Lights 2 Power Cost [%.3f]” (GroupGroundSocketsPowerCost)
Number Lightwave_LandingLights2_Energy_Cost “Landing Lights 2 Energy Cost [%.2f]” (GroupGroundSocketsEnergyCost)

//LandingLights1
Switch Lightwave_LandingLights1_switch “Landing Lights 1” (GroupGroundSockets)
Dimmer Lightwave_LandingLights1_dimLevel “Landing Lights 1 dimLevel” (GroupGroundLights)
String Lightwave_LandingLights1_dimSetup "Landing Lights 1 dimSetup "
Switch Lightwave_LandingLights1_protection “Landing Lights 1 protection” (GroupGroundSocketsOther)
Number Lightwave_LandingLights1_power “Landing Lights 1 power [%.1f W] (Read Only)” (GroupGroundSocketsPower)
Number Lightwave_LandingLights1_energy “Landing Lights 1 energy [%.2f kWh] (Read Only)” (GroupGroundSocketsEnergy)
Switch Lightwave_LandingLights1_identify “Landing Lights 1 identify” (GroupGroundSocketsOther)
Switch Lightwave_LandingLights1_reset “Landing Lights 1 reset” (GroupGroundSocketsOther)
Switch Lightwave_LandingLights1_upgrade “Landing Lights 1 upgrade” (GroupGroundSocketsOther)
Number Lightwave_LandingLights1_diagnostics "Landing Lights 1 diagnostics "
String Lightwave_LandingLights1_periodOfBroadcast "Landing Lights 1 periodOfBroadcast "
Number Lightwave_LandingLights1_rgbColor "Landing Lights 1 rgbColor "
String Lightwave_LandingLights1_bulbSetup "Landing Lights 1 bulbSetup "
Number Lightwave_LandingLights1_Power_Cost “Landing Lights 1 Power Cost [%.3f]” (GroupGroundSocketsPowerCost)
Number Lightwave_LandingLights1_Energy_Cost “Landing Lights 1 Energy Cost [%.2f]” (GroupGroundSocketsEnergyCost)

//BathroomLights
Switch Lightwave_BathroomLights_switch “Bathroom Lights” (GroupGroundSockets)
… and so on

Going through the .items file I realised it’s a massive help if you section it up using a comment line that shows the name as I’ve done above. I’m pretty sure you’re already extracting and using the name so hopefully this should be easy. Maybe even with a blank line before each comment as well as I’ve done.

The other difference here is that LandingLights 1 and 2 are linked for 2-way switching/dimming in the LWRF app. LandingLights1 is the master, and LandingLights2 as the slave has a few items that get missed off because they are now a pair. Might be unimportant in the long run, but at least you’ve got an example of how a 2-way setup looks in the API

I did have that all done and I will re add, got lost when I re wrote the refresh rule

I also want to look at the rgb colour as I think we can prob have any colour now, just wish they’d add on colour aswell as off

That’s the colour of the LED on the socket/dimmer. Never saw the point of that feature to be honest

Its nice to fit it in with the ambiance of the room, just doesn’t make sense only being able to change the ‘off’ colour, especially seeing as you can set it as green :boom:

Hows the system running anyhow… Mine seems very stable and hasnt had a hiccup as far as i can tell.

Been on the road so not played much since we last spoke. It’s still working though so that’s good.
Noticed two things. One, when I change anything in the update.rules it seems to throw errors for 30 seconds or so then sorts itself out and starts working again. And If I use the LWRF app to change the dim level of a Gen 2 dimmer that’s off then it switches it on as well. Need to test from within OpenHAB to see if that’s the same. Strictly speaking the switch and the dim level should be separate and shouldn’t interact at all

It’s throwing errors as it’s trying to read from the file that although you see as changed, the operating system actually deletes and recreates, so your always going to get that, it’s because it’s firing continuously and is mid process when the file is deleted.

All my dimming devices behave in that way. 0% is the equivalent of OFF so the second you change it to anything other than that it turns the switch on. I have fibaro dimmers and hue bulbs that do exactly the same.

Interesting. On the LWRF app the dim level and the switch are separate and one doesn’t trigger the other. So to turn a light on at 30% that’s two actions, set dim level to 30% and then set switch to on. Sounds rubbish but it’s actually really useful - for example I have a late night automation that changes the dim level of my bedroom light, bathroom light and landing light without switching them on so that if they do get switched on during the night they come on really dim. No matter though, what we’re talking about here is the behaviour of the OpenHAB when controlling lights. I don’t mind if that does the ‘sensible’ thing and turns the switch on as well as I can still have my app automations and they still work fine.

Hi All,
I’m trying to pair a LWRF Power socket (Gen1 double socket) but cannot get it to pair - i have been using the RFXCOM Lighting5 Actuator as I cant see a listing for the sockets.
Could someone know which settings in Paper UI i need to use - have many of the Gen1 dimmer switchs that work really well.
Thanks!

You could always use my gen2 solution above and just delete Everything in the created files bar the sockets (you would need to use the lightwave hub tho for the sockets)
I don’t have any gen1 stuff to help you otherwise.

Yeah, no hub here unfortunately :frowning: But thanks for your reply!

@delid4ve
Something odd’s started happening here. It’s been working fine for quite a while, but last night I noticed the polling rule failing continually with “the JSON string can’t be empty”.
I fired off the Auth rule and that worked okay, and I can also change a device switch or dimmer level in my sitemap and the light/socket responds so my system must still be talking to the API and authenticating correctly as it can still push commands to my Lightwave kit.
I put an additional logging line into the polling rule to output the contents of Readme (the string that comes back from the cURL) and it’s empty!
Any ideas?
I’m tempted to re-run the whole thing from scratch and set it up again, but before I do is there a later version of the script?

All my lightwave gear is offline atm as I’ve ripped out my kitchen.
I’ve just checked my log though and I have exactly the same.
There are a lot of bad gateway errors and also that features have not been found.
I think they either have an issue or have changed the api
I’m just firing up postman now to take a look. Give me 10.

What time were your errors?
Mine were from 01:39 this morning.
It seemed to recover though around 1030am.
I’ve just added the link plus time back in to check it’s working and seems to be fine now.
I think they went down their end based on the bad gateway errors I got.

Everything returned ok in postman aswell.
This is exactly why I hate cloud products, don’t know if you see my thread about an alternative to lightwave that I found last week, maybe of interest in the long run, haven’t had time to test it yet tho

Mine’s still failing.

Here’s the log, same every time it runs:

2019-06-06 20:40:10.127 [INFO ] [marthome.model.script.ligtwave.rules] - Structure rule returned this -
2019-06-06 20:40:10.137 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘LightWave Structure’: json string can not be null or empty

The first line is the extra logging line I put into the rule:

rule “LightWave Structure”
when
Time cron “0/60 * * ? * * *”
then
var String Access_Token = Access_Token.state.toString
var String Readme = executeCommandLine(“curl@@-s@@-X@@POST@@https://publicapi.lightwaverf.com/v1/features

{"featureId":"xxxxxxxxxxxxxxxx" }]}”,10000)

logInfo(“ligtwave.rules”, "Structure rule returned this - " + Readme.toString)

var Number Electricity_Cost = 0.13
var Lightwave_LinkPlus_currentTime_Value = transform(“JSONPATH”,"$.xxxxxxxx

As I said the wierd thing is I can still control everything with the switch rule, it’s just the refresh that’s broken and I haven’t changed a thing. For some reasom the cURL is failing completely. To double-prove that I took the -s option off the cURL command line and then I get all of the cURL throughput figures but no data at all.

Proper odd.