LightwaveRF Binding Updated

The problem with the api is there doesn’t seem to be a way to get ALL device/feature status’s with one request

Think I’ve sorted the issue. Will post up after footy training in couple hours

Didn’t quite work.

It’s created:

Lightwave_Items_Authentication.items
Lightwave_Rules_Authentication.rules
Lightwave_Rules_Structures.rules

But nothing else

In the file Lightwave_Setup.rules at this point:

//Get Items And Features
var String access = Access_Token.state.toString
val deviceresults =
executeCommandLine(“curl@@-g@@-XGET@@https://publicapi.lightwaverf.com/v1/Structure/” + Structure.state.toString + "@@-H@@Authorization:bearer " + access,5000)

my editor is red-lining Access_Token and Structure as undefined. They
aren’t defined elsewhere in that file, but they do exist as items in
the .items files and I’ve displayed them on my sitemap to check they
definitely contain values, which they do.

I’m also seeing this in the event log:

2019-05-02 21:06:31.202 [INFO ] [clipse.smarthome.model.script.Exec13] -
2019-05-02 21:06:37.328 [INFO ] [clipse.smarthome.model.script.Exec14] -
2019-05-02 21:06:37.483 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘LightWave_Rules_Structures.rules’
2019-05-02 21:06:37.952 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Lightwave_Setup’: For input string: “{nullHub”,“gen”:2}]}"
2019-05-02 21:06:38.842 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘LightWave_Rules_Structures.rules’
2019-05-02 21:06:47.794 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Lightwave_Setup’: For input string: “{nullHub”,“gen”:2}]}"

Since Exec13 and Exec14 come right before the //Get Items And Features
section, which would generate the missing extra files, I’m guessing
the problem is indeed that those two variables aren’t defined.

Any thoughts?

Hi, In other systems with an api that has access tokens and things passed to it
I have passed the access token and parameters directly in the command line .sh

eg

/usr/bin/curl -s -X GET 'https://api.openuv.io/api/v1/uv?lat=54.93&lng=-1.98' -H 'x-access-token:e3824e3693a7657848976498764974c216d803' > /home/chod/openhab2/html/openuv.txt

then I read the returned JSON with

String Openuv_UVIndexMax "UV Index (max): [%s]" <uvsun>  http="<[http://127.0.0.1:8080/static/openuv.txt:60000:JSONPATH($.result.uv_max)]" }

rather than pass from an Item, which I’m not sure how you would, which I will look into

Further update:

I don’t think it’s anything to do with those two values being undefined.
I added a line to the rule to log what comes back as deviceresults and this is what it gets:

2019-05-02 21:40:05.384 [INFO ] [smarthome.model.script.deviceresults] - % Total % Received % Xferd Average Speed Time Time
Time Current

                             Dload  Upload   Total   Spent    Left  Speed

0 0 0 0 0 0 0 0 --:–:-- --:–:–
–:–:-- 0{“name”:“My
Group”,“groupId”:“5a6a3fbfc211836b17f98f26-5a6a3fbfc211836b17f98f27”,“devices”:[{“deviceId”:“5a6a3fbfc211836b17f98f26-1-3157328472+0”,“name”:“LinkPlus”,“productCode”:“L2”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5a6a3fbfc211836b17f98f2d”,“name”:“LinkPlus”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-1-3157328472+0”,“type”:“currentTime”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-2-3157328472+0”,“type”:“buttonPress”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-3-3157328472+0”,“type”:“time”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-4-3157328472+0”,“type”:“date”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-5-3157328472+0”,“type”:“monthArray”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-6-3157328472+0”,“type”:“weekdayArray”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-7-3157328472+0”,“type”:“timeZone”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-8-3157328472+0”,“type”:“locationLongitude”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-9-3157328472+0”,“type”:“locationLatitude”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-10-3157328472+0”,“type”:“duskTime”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-11-3157328472+0”,“type”:“dawnTime”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-12-3157328472+0”,“type”:“rgbColor”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-112-3157328472+0”,“type”:“day”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-113-3157328472+0”,“type”:“month”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-114-3157328472+0”,“type”:“year”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-119-3157328472+0”,“type”:“weekday”,“writable”:false}]}],“product”:“L2”,“device”:“LinkPlus”,“desc”:“Central
Hub”,“type”:“lwrfTwoWay_v2”,“cat”:“Hub”,“gen”:2},{“deviceId”:“5a6a3fbfc211836b17f98f26-4-3157328472+0”,“name”:“Test”,“productCode”:“L42”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5a6f8129f97b651e2d50edff”,“name”:“Internet”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-32-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-33-3157328472+0”,“type”:“outletInUse”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-34-3157328472+0”,“type”:“protection”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-35-3157328472+0”,“type”:“power”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-36-3157328472+0”,“type”:“energy”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-25-3157328472+0”,“type”:“identify”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-26-3157328472+0”,“type”:“reset”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-27-3157328472+0”,“type”:“upgrade”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-28-3157328472+0”,“type”:“diagnostics”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-29-3157328472+0”,“type”:“periodOfBroadcast”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-30-3157328472+0”,“type”:“rgbColor”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-31-3157328472+0”,“type”:“voltage”,“writable”:false}]},{“featureSetId”:“5a6a3fbfc211836b17f98f26-5a6f8129f97b651e2d50ee00”,“name”:“TV
Socket”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-37-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-38-3157328472+0”,“type”:“outletInUse”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-39-3157328472+0”,“type”:“protection”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-40-3157328472+0”,“type”:“power”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-41-3157328472+0”,“type”:“energy”,“writable”:false}]}],“product”:“L42”,“device”:“socket”,“desc”:“Smart
Socket”,“type”:“lwrfTwoWay_v2”,“cat”:“Power”,“gen”:2},{“deviceId”:“5a6a3fbfc211836b17f98f26-11-3157328472+0”,“name”:“Test3”,“productCode”:“LW320”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5a8c9651b6fce426e5615ee4”,“name”:“Green
Lamp”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-44-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-45-3157328472+0”,“type”:“protection”,“writable”:true}]}],“product”:“LW320”,“device”:“socket”,“desc”:“Plug-In
Socket”,“type”:“lwrfOneWay_v1”,“cat”:“Power”,“gen”:1},{“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},{“deviceId”:“5a6a3fbfc211836b17f98f26-23-3157328472+0”,“name”:“New001”,“productCode”:“LW320”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5ab405b39439d716e327c3ec”,“name”:“Outside
Lights”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-42-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-43-3157328472+0”,“type”:“protection”,“writable”:true}]}],“product”:“LW320”,“device”:“socket”,“desc”:“Plug-In
Socket”,“type”:“lwrfOneWay_v1”,“cat”:“Power”,“gen”:1},{“deviceId”:“5a6a3fbfc211836b17f98f26-24-3157328472+0”,“name”:“Twigs”,“productCode”:“LW320”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5ab407069439d716e32816eb”,“name”:“Twigs”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-48-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-49-3157328472+0”,“type”:“protection”,“writable”:true}]}],“product”:“LW320”,“device”:“socket”,“desc”:“Plug-In
Socket”,“type”:“lwrfOneWay_v1”,“cat”:“Power”,“gen”:1},{“deviceId”:“5a6a3fbfc211836b17f98f26-25-3157328472+0”,“name”:“Window
Lights”,“productCode”:“LW320”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5ab407849439d716e32836e5”,“name”:“Window
Lights”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-50-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-51-3157328472+0”,“type”:“protection”,“writable”:true}]}],“product”:“LW320”,“device”:“socket”,“desc”:“Plug-In
Socket”,“type”:“lwrfOneWay_v1”,“cat”:“Power”,“gen”:1},{“deviceId”:“5a6a3fbfc211836b17f98f26-26-3157328472+0”,“name”:“Hall
Lights”,“productCode”:“L22”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5b2ea8c13f97f36a63dac7aa”,“name”:“Hall
Lights”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-58-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-59-3157328472+0”,“type”:“dimLevel”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-60-3157328472+0”,“type”:“dimSetup”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-61-3157328472+0”,“type”:“protection”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-62-3157328472+0”,“type”:“power”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-63-3157328472+0”,“type”:“energy”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-52-3157328472+0”,“type”:“identify”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-53-3157328472+0”,“type”:“reset”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-54-3157328472+0”,“type”:“upgrade”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-55-3157328472+0”,“type”:“diagnostics”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-56-3157328472+0”,“type”:“periodOfBroadcast”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-57-3157328472+0”,“type”:“rgbColor”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-124-3157328472+0”,“type”:“bulbSetup”,“writable”:true}]},{“featureSetId”:“5a6a3fbfc211836b17f98f26-5b2ea8c13f97f36a63dac7ab”,“name”:“Landing
Lights 2”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-64-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-65-3157328472+0”,“type”:“dimLevel”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-66-3157328472+0”,“type”:“dimSetup”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-67-3157328472+0”,“type”:“protection”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-68-3157328472+0”,“type”:“power”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-69-3157328472+0”,“type”:“energy”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-125-3157328472+0”,“type”:“bulbSetup”,“writable”:true}]}],“product”:“L22”,“device”:“dimmer”,“desc”:“Smart
Dimmer”,“type”:“lwrfTwoWay_v2”,“cat”:“Lighting”,“gen”:2},{“deviceId”:“5a6a3fbfc211836b17f98f26-27-3157328472+0”,“name”:“Upstairs”,“productCode”:“L22”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5b2eaa333f97f36a63db2506”,“name”:“Landing
Lights 1”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-76-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-77-3157328472+0”,“type”:“dimLevel”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-78-3157328472+0”,“type”:“dimSetup”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-79-3157328472+0”,“type”:“protection”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-80-3157328472+0”,“type”:“power”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-81-3157328472+0”,“type”:“energy”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-70-3157328472+0”,“type”:“identify”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-71-3157328472+0”,“type”:“reset”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-72-3157328472+0”,“type”:“upgrade”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-73-3157328472+0”,“type”:“diagnostics”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-74-3157328472+0”,“type”:“periodOfBroadcast”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-75-3157328472+0”,“type”:“rgbColor”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-122-3157328472+0”,“type”:“bulbSetup”,“writable”:true}]},{“featureSetId”:“5a6a3fbfc211836b17f98f26-5b2eaa333f97f36a63db2507”,“name”:“Bathroom
Lights”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-82-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-83-3157328472+0”,“type”:“dimLevel”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-84-3157328472+0”,“type”:“dimSetup”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-85-3157328472+0”,“type”:“protection”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-86-3157328472+0”,“type”:“power”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-87-3157328472+0”,“type”:“energy”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-123-3157328472+0”,“type”:“bulbSetup”,“writable”:true}]}],“product”:“L22”,“device”:“dimmer”,“desc”:“Smart
Dimmer”,“type”:“lwrfTwoWay_v2”,“cat”:“Lighting”,“gen”:2},{“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},{“deviceId”:“5a6a3fbfc211836b17f98f26-29-3157328472+0”,“name”:“Morning
Room Light”,“productCode”:“L21”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5b5af1ec6955591b24e7a207”,“name”:“Morning
Room Light”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-100-3157328472+0”,“type”:“identify”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-101-3157328472+0”,“type”:“reset”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-102-3157328472+0”,“type”:“upgrade”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-103-3157328472+0”,“type”:“diagnostics”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-104-3157328472+0”,“type”:“periodOfBroadcast”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-105-3157328472+0”,“type”:“rgbColor”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-106-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-107-3157328472+0”,“type”:“dimLevel”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-108-3157328472+0”,“type”:“dimSetup”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-109-3157328472+0”,“type”:“protection”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-110-3157328472+0”,“type”:“power”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-111-3157328472+0”,“type”:“energy”,“writable”:false},{“featureId”:“5a6a3fbfc211836b17f98f26-120-3157328472+0”,“type”:“bulbSetup”,“writable”:true}]}],“product”:“L21”,“device”:“dimmer”,“desc”:“Smart
Dimmer”,“type”:“lwrfTwoWay_v2”,“cat”:“Lighting”,“gen”:2},{“deviceId”:“5a6a3fbfc211836b17f98f26-30-3157328472+0”,“name”:“Christmas
Lights”,“productCode”:“LW320”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5c044a037d7db22a0a43152b”,“name”:“Reading
Lamp”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-115-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-116-3157328472+0”,“type”:“protection”,“writable”:true}]}],“product”:“LW320”,“device”:“socket”,“desc”:“Plug-In
Socket”,“type”:“lwrfOneWay_v1”,“cat”:“Power”,“gen”:1},{“deviceId”:“5a6a3fbfc211836b17f98f26-31-3157328472+0”,“name”:“Outdoor
Lights”,“productCode”:“LW320”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5c044c037d7db22a0a442beb”,“name”:“Gracies
Star”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-117-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-118-3157328472+0”,“type”:“protection”,“writable”:true}]}],“product”:“LW320”,“device”:“socket”,“desc”:“Plug-In
Socket”,“type”:“lwrfOneWay_v1”,“cat”:“Power”,“gen”:1},{“deviceId”:“5a6a3fbfc211836b17f98f26-32-3157328472+0”,“name”:“Greenhouse
Light”,“productCode”:“LW380”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5caa2c2a2d87a76677a91bea”,“name”:“Greenhouse
Light”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-126-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-127-3157328472+0”,“type”:“protection”,“writable”:true}]}],“product”:“LW380”,“device”:“socket”,“desc”:“Plug-In
Socket”,“type”:“lwrfOneWay_v1”,“cat”:“Power”,“gen”:1},{“deviceId”:“5a6a3fbfc211836b17f98f26-33-3157328472+0”,“name”:“Pump”,“productCode”:“LW380”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5caa2cb22d87a76677a91bf3”,“name”:“Pump”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-128-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-129-3157328472+0”,“type”:“protection”,“writable”:true}]}],“product”:“LW380”,“device”:“socket”,“desc”:“Plug-In
Socket”,“type”:“lwrfOneWay_v1”,“cat”:“Power”,“gen”:1},{“deviceId”:“5a6a3fbfc211836b17f98f26-34-3157328472+0”,“name”:“Garden
Lights”,“productCode”:“LW380”,“featureSets”:[{“featureSetId”:“5a6a3fbfc211836b17f98f26-5caa2d8f2d87a76677a91c13”,“name”:“Garden
Lights”,“features”:[{“featureId”:“5a6a3fbfc211836b17f98f26-130-3157328472+0”,“type”:“switch”,“writable”:true},{“featureId”:“5a6a3fbfc211836b17f98f26-131-3157328472+0”,“type”:“protection”,“writable”:true}]}],“product”:“LW380”,“device”:“socket”,“desc”:"Plug-In
Sock

100 16435 100 16435 0 0 40971 0 --:–:-- --:–:-- --:–:-- 41087

et",“type”:“lwrfOneWay_v1”,“cat”:“Power”,“gen”:1}]}

Then the next line in the log is the error we’ve seen before, coming
from the next line in the rule:

2019-05-02 21:40:05.395 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Lightwave_Setup’: For input string: “{nullHub”,“gen”:2}]}"

So is the issue here might be the numerical data report lines that
curl seems to be adding in, particularly at the end where it breaks up
the data?
Is there a command line option for curl to get rid of those?

Here you go, sorry for the delay work commitments slowed me down:
1: Download the two files and put in the respective folders and remove the .txt extension
2 :Ensure openhab has write permissions on items and rules folders (these are hard coded as etc/openhab2/* so if you need to change you need to edit the rules file and replace all occurrences with your path)
3: In rules file add username and password in the variables at the top of the file.
4: Add the switch switch created in the items file to habpanel or another ui
5: Hit the switch and wait for the magic (monitor the log for errors as the major steps are logged)
6: If it doesn’t work you can make your changes and hit the switch again as the rule automatically deletes old files.

I only have 1 gen2 hub and multiple gen2 sockets on my setup so hopefully it will work for others. it will create the necessary files for you to play about though. I have only implemented switches/power and energy at present but if you look at the api and my files you.ll be able to work it out.
switch - self explanatory
Energy - power consumption (total) in W/hrs - divide by 1000 to get kW/h
Power - current consumption in watts
the devices poll every ten seconds at present but you can change on cron timings.

its not perfect and is consuming alot of threads but i just wanted to get a working solution first, ill be working on it over the coming months, unless someone wants to take it and create a binding (i dont have the knowledge YET)
Feedback welcome.LightWave_Setup.items.txt (28 Bytes)

Lightwave_Setup.rules.txt (10.0 KB)

** UPDATE** Use this rules file instead:

1 Like

just uploaded reworked files, delete existing files, put username and password back in rules file and fire the rule either with the item file switch or however.
yes the report return values are the biggest pain, i havn’t been able to get the http binding to accept the headers though in rules. i’m going to look at appending the http.cfg file with the bits needed, wont be easy to automate for others to setup though as if it errors out then wont be able to just delete their cfg file in fear of other items in there.

the biggest problem with the old files was the crons not firing. ive taken a different route now. run it but if it erros out, this time instead of doing the device results log, do the JSON that follows it, this should have removed the log header and be a full json string.

just re uploaded the rule file, small mistake in it, a stray + sign.

Ill have a look at your log tomorrow, bed time, knackered.
post up a new one from this new rule file if you can. at least i can now see other item types aswell to see their properties.

screenshot whilst boiling the kettle, its working so sense of achievement this end for something i feared i was never going to get implemented, even if it is a bodge route for now

could you do a get request through postman for /structures ( take out your personal details) and post it to me so i can look at the differences between yours and mine, it may be my substring commands dont work on your setup, so would like to find a better way.

looking at your logs you put up though i dont think it authenticated and got the structure in time, the new rule should fix that.

this is why i changed the way i did it as i was getting the same

this is also the reason it didnt generate the items files for the actual devices, should be like 5 files in total (3 rule 2 items), it couldnt discover the devices as it failed at the structure.

Could you please post the and solution to this when you find it? The xiaomi binding is crashing quartz / cron for me. Want to see if I can change it to not.

Thanks

Solution was to do away with cron timers :smile:
Have you got a lot of rules with timers in?
If so, depending on the rule there are other options

So you had timers in rules or in binging?

Thanks. I’ll give it a try and report back.
Appreciate the work you’ve put into this, you’re years ahead of where I would have been by now.

I’ve made a few changes to my files which ill replicate back to the setup file when i get a minute and upload:

  • Changed Power and Energy to Number rather than string in rule and items and corrected Kwh value
  • Added units to items
  • Created a Group Structure for combined usage / energy
    • Added Groups To Items
  • Added default icons and groups to items

Other Changes To Implement:

  • Log KwH Historical Usage to Item/File/Persistence so monthly usage can be monitored
  • Add Rule/Switch to reset Historical Usage (user definable Daily/weekly/monthly/yearly (i will log them all and just have the reset as user definable)

Ive also sent a request to Lightwave regarding limits on api calls as i had a few issues (when really hammering the service whilst debugging) where i got 500 server errors (it blocked me) and a few json responses saying too many requests
I’ve been running without errors for about 10 hours now Update Had my rule terminating on a null value, I’m adding some error handling in as if the value returned is null/another error for any reason it stops the rule from firing in the loop.

i was using cron timers in rules and it kept crashing. I was calling rules (2 of) every 10 seconds and the rules were fairly long so i think it just run out of threads and locked it up until reboot. Which may be the case also for the binding. Where is the cron being used your talking about? directly in the binding or are you calling the binding from cron rules?

Probably makes sense for me to wait until you’ve posted the updated files with your changes. Give me a shout when they’re ready and I’ll give them a go. The authentication is still working though, the logs say it refreshed my token a few hours ago.

Also re your earlier comment I can give you whatever you need from the system this end but I’m not familiar with postman:

could you do a get request through postman for /structures ( take out your personal details) and post it to me

Could you point me to some info?

Postman is just a windows application that allows you to send http requests (post/get etc) with headers and a body that cannot normally be integrated in a url in a browser. If you look at my send command line arguments in the rules (forget the backslashes and @@ signs) you will get an understanding. So and thing that follows an -H is a header (for instance, content-type is the header and the information relating to that header is application/json. Postman allows you to specify the headers, and also the body (-d). I’ve only just learnt all this myself but it gives a clear understanding to you then what my rules are accomplishing.
It doesn’t matter about waiting as in my setup rule it will delete the existing files before re creating them (I done this purposely to make it easy for people to add my changes).

Having monitored it today there is definitely a request limit to light waves servers but they do not specify it anywhere I can find, which annoys me slightly in the fact that there is no function within the api to get the status of all features with one call, instead having to query every item, which if you had 20 double sockets and just wanted the 3 statuses I have integrated is 120 calls( each double socket is 2 items x 20 = 40 x 3 features). Do that every 10 seconds to keep everything in sync and the data is mounting up.

I’m learning myself (I’m a refrigeration engineer by trade) so I’ll probably find a better approach. I see from the api that web hooks can be created so if a device status changes it will send the data to an endpoint, however I don’t know much about webhooks at present and don’t see how it can send data to the normal person with a dynamic IP address/ no domain without knowing when it changes. I’m happy I’ve got so far and if I can just get the few little niggles ironed out it’s a building block for me to take further.

Right I’ve done some more research and I can now successfully get all values from a single poll of the api.
This is going to drastically improve things and make life a lot easier.
I don’t know when I’m going to get a chance to implement but hopefully at some point this weekend/bank holiday Monday.

haven’t done a lot of testing but seems more stable.
1 request to lightwaves servers now so shouldn’t hit api limits which they still haven’t advised.
also added costs (current and historical)
going to attempt to move this over to exec binding this week so it executes cleaner
Lightwave_Setup.rules.txt (9.6 KB)

** UPDATE** Use this file instead:

Tried it again with your latest file this evening. Everything seems to work but then it stops, different error this time:

2019-05-07 20:13:36.531 [INFO ] [clipse.smarthome.model.script.Exec11] -
2019-05-07 20:13:42.635 [INFO ] [clipse.smarthome.model.script.Exec12] -
2019-05-07 20:13:42.893 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘LightWave_Rules_Authentication.rules’
2019-05-07 20:13:44.393 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘LightWave_Rules_Authentication.rules’
2019-05-07 20:13:47.697 [INFO ] [clipse.smarthome.model.script.Exec13] -
2019-05-07 20:13:53.760 [INFO ] [clipse.smarthome.model.script.Exec14] -
2019-05-07 20:13:54.173 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘LightWave_Rules_Structures.rules’
2019-05-07 20:13:55.536 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘LightWave_Rules_Structures.rules’
2019-05-07 20:14:04.231 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Lightwave_Setup’: For input string: “{nullHub”,“gen”:2}]}"

That’s as far as it goes. Still just the same two items files like before.

Maybe my LWRF setup is different to yours in some way? I have Gen 1 plug-in relay sockets, a Gen 1 3-way relay, Gen 2 double sockets and Gen 2 dimmers both one and two gang. What diagnostic info from my system would help you?

I get the same, but i have a gen 1 hub, which i guessed was why