Use Wirelesstag sensors with OpenHAB?

I have, although I’ve only tried it with 1.8, and I believe things have changed in 2.0 that may stop it working.

Here’s a copy of one of my working entries from the wireless tag interface: http://192.168.0.113:8080/CMD?WT_PIR_Kitchen=ON

Note you need to change it to match the ip your OH runs at, change the WT_PIR_Kitchen to match one of your items, and make sure private IP is checked

I’ve moved a bit further forward, I’ve now got the payload coming into the script successfully. As suggested above, I’ve added this to the loginfo

Now, I’m getting
016-10-07 19:14:28.413 [ERROR] [.script.engine.ScriptExecutionThread] - Rule ‘UnpackWirelesstagPayload’: cannot invoke method public int java.lang.String.length() on null

Here is my output
{“d”:[{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Back Door”,“uuid”:“395eac08-3a39-4df0-9b32-8007a8d03712”,“comment”:"",“slaveId”:3,“tagType”:13,“lastComm”:131203375093281886,“alive”:true,“signaldBm”:-79,“batteryVolt”:2.8438254936935978,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:5,“eventState”:4,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:18.508745193481445,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:63.20623779296875,“capRaw”:0,“az2”:0,“capEventState”:1,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-15381,“freqCalApplied”:18424,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:255,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.88},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Front Door”,“uuid”:“a73fc3da-89b0-4537-8543-1e4c4eb417b4”,“comment”:"",“slaveId”:2,“tagType”:13,“lastComm”:131090996181611151,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.7126537052616704,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:5,“eventState”:4,“tempEventState”:0,“OutOfRange”:true,“lux”:0,“temperature”:18.304967880249023,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:59.25421142578125,“capRaw”:0,“az2”:0,“capEventState”:2,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-141,“freqCalApplied”:21337,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:255,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.24},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“My Keys”,“uuid”:“a84ea7f9-06fe-4fc7-8f6b-5bb03e37f3e3”,“comment”:"",“slaveId”:6,“tagType”:13,“lastComm”:131106038629255376,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.7408466488344163,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:10,“eventState”:3,“tempEventState”:0,“OutOfRange”:true,“lux”:0,“temperature”:18.1011905670166,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:56.84332275390625,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-13879,“freqCalApplied”:16122,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:111,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.38},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Tag 5”,“uuid”:“cb0f78db-e9f0-4cbe-9c84-c0d55774f061”,“comment”:"",“slaveId”:5,“tagType”:13,“lastComm”:130963036652188222,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.47269217344349,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:1,“tempEventState”:1,“OutOfRange”:true,“lux”:0,“temperature”:15.8918209075928,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:57.34686279296875,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-239,“freqCalApplied”:4041,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:255,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.12},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Front Room PIR”,“uuid”:“40eede82-bbbe-4e2f-961a-42ef27db8b46”,“comment”:"",“slaveId”:8,“tagType”:72,“lastComm”:131203371457656474,“alive”:true,“signaldBm”:-77,“batteryVolt”:2.9228289150440681,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:6,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:17.479135513305664,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:64.57952880859375,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:-16911,“freqCalApplied”:22141,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:66,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.92},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Hall PIR”,“uuid”:“c86b7a79-2b4a-4ba9-8811-22748f618c93”,“comment”:"",“slaveId”:7,“tagType”:72,“lastComm”:131203375193594197,“alive”:true,“signaldBm”:-74,“batteryVolt”:2.9885736379998096,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:6,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:18.176267623901367,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:64.281982421875,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:479,“freqCalApplied”:3190,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:16,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.94},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Back Room PIR”,“uuid”:“dd2eb71c-d614-4697-a301-0b15a31ae0c1”,“comment”:"",“slaveId”:9,“tagType”:72,“lastComm”:131203377552187733,“alive”:true,“signaldBm”:-75,“batteryVolt”:2.9712186470843114,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:6,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:19.463279724121094,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:65.258544921875,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:577,“freqCalApplied”:-1250,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:57,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.93},{"__type":“MyTagList.Tag”,“notificationJS”:null,“name”:“Kitchen Thermostat”,“uuid”:“9c352334-3811-4bab-8295-6047a15407d8”,“comment”:"@Home",“slaveId”:-1,“tagType”:62,“lastComm”:131203373037000000,“alive”:true,“signaldBm”:-60,“batteryVolt”:3,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:5,“tempEventState”:1,“OutOfRange”:false,“lux”:0,“temperature”:20,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:55,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:{“nest_id”:“YucPu7ZCFhaC9-ezLcJTouwLnnHJaWv9”,“honeywell_device_id”:0,“th_low”:18,“th_high”:24,“threshold_q”:{"__type":“MyTagList.Tag+ThresholdQuantization”,“min”:9,“max”:32,“step”:0.1,“sample1”:18,“sample2”:24},“targetUuid”:“9c352334-3811-4bab-8295-6047a15407d8”,“turnOff”:false,“fanOn”:false,“disableLocal”:false,“issuedState”:0},“playback”:null,“postBackInterval”:600,“rev”:0,“version1”:3,“freqOffset”:-18153,“freqCalApplied”:0,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:0,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.94}]}

Any ideas?

I’ve got URL calling going on with my old Openhab installation

http://username:password@externalIPADDRESS:8085/CMD?EventState06=DetectedMovement

Mine has authentication enabled. Remember that the port needs to be opened externally if not getting the tag manager to call it…

What does your rule file look like? Are you 100% positive all the items and vars are named EXACTLY the same? Even with the same capitalization? Those tend to be my biggest errors. Regardless, the rule is finding a null entry and failing.

[quote=“a8ree, post:58, topic:6790”]
I’ve got URL calling going on with my old Openhab installation

http://username:password@externalIPADDRESS:8085/CMD?EventState06=DetectedMovement
[/quote] Do you use mapping to have the item state DetectedMovement map to an On state with a switch? Whether I use On, ON, on, Open, OPEN or any variation of after the CMD?itemname= I get no change to the item state. I’m calling the URL from a local tag manager and without any authentication. shrug

I use a string rather than a switch for my items so I can have multiple states

I’m hoping someone can sense check this as I think I’m going crazy……Sorry for placing so much info here but I think I’m going off my head!

My Item is set up as

String wtPayload {exec="<[C:\Openhab\conf\scripts\getTagList.cmd:50000:REGEX((.*?))]" }

The getTagList.cmd content is

curl -s -X POST -H “Content-Type: application/json; charset=utf-8” -H “Authorization: bearer XXXXXX-0fa9-4258-b8d0-98aa6157d21e” -d “” “http://mytaglist.com/ethClient.asmx/GetTagList

I’ve modified the rule file to allow me to test with:
1- Script working as originally posted - it will transform the data that is sent from the batch file
2- Use a previously exported taglist that I assign to the same payload variable

I comment out each in turn to test

i.e.

rule UnpackWirelesstagPayload
when
Item wtPayload received update
then

logInfo("wt", "Wireless Tag Payload arrived...")

// 1 - The next line to test with the scripted payload
val String payload = wtPayload.state.toString

// 2 - This line to test with the set payload
// var String payload = ‘{“d”:[{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Back Door”,“uuid”:“395eac08-3a39-4df0-9b32-8007a8d03712”,“comment”:"",“slaveId”:3,“tagType”:13,“lastComm”:131203733220625542,“alive”:true,“signaldBm”:-81,“batteryVolt”:2.8291962707054732,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:5,“eventState”:4,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:17.125207901000977,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:63.45037841796875,“capRaw”:0,“az2”:0,“capEventState”:1,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-15481,“freqCalApplied”:18424,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:255,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.88},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Front Door”,“uuid”:“a73fc3da-89b0-4537-8543-1e4c4eb417b4”,“comment”:"",“slaveId”:2,“tagType”:13,“lastComm”:131090996181611151,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.7126537052616704,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:5,“eventState”:4,“tempEventState”:0,“OutOfRange”:true,“lux”:0,“temperature”:18.304967880249023,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:59.25421142578125,“capRaw”:0,“az2”:0,“capEventState”:2,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-141,“freqCalApplied”:21337,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:255,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.24},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“My Keys”,“uuid”:“a84ea7f9-06fe-4fc7-8f6b-5bb03e37f3e3”,“comment”:"",“slaveId”:6,“tagType”:13,“lastComm”:131106038629255376,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.7408466488344163,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:10,“eventState”:3,“tempEventState”:0,“OutOfRange”:true,“lux”:0,“temperature”:18.1011905670166,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:56.84332275390625,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-13879,“freqCalApplied”:16122,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:111,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.38},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Tag 5”,“uuid”:“cb0f78db-e9f0-4cbe-9c84-c0d55774f061”,“comment”:"",“slaveId”:5,“tagType”:13,“lastComm”:130963036652188222,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.47269217344349,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:1,“tempEventState”:1,“OutOfRange”:true,“lux”:0,“temperature”:15.8918209075928,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:57.34686279296875,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-239,“freqCalApplied”:4041,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:255,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.12},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Front Room PIR”,“uuid”:“40eede82-bbbe-4e2f-961a-42ef27db8b46”,“comment”:"",“slaveId”:8,“tagType”:72,“lastComm”:131203734313750182,“alive”:true,“signaldBm”:-78,“batteryVolt”:2.9226575175410949,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:6,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:17.875965118408203,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:64.5718994140625,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:-17097,“freqCalApplied”:22141,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:66,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.92},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Hall PIR”,“uuid”:“c86b7a79-2b4a-4ba9-8811-22748f618c93”,“comment”:"",“slaveId”:7,“tagType”:72,“lastComm”:131203733075000440,“alive”:true,“signaldBm”:-72,“batteryVolt”:2.9884504750112115,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:6,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:18.455120086669922,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:63.92340087890625,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:215,“freqCalApplied”:3190,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:16,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.94},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Back Room PIR”,“uuid”:“dd2eb71c-d614-4697-a301-0b15a31ae0c1”,“comment”:"",“slaveId”:9,“tagType”:72,“lastComm”:131203733380313102,“alive”:true,“signaldBm”:-75,“batteryVolt”:2.9714635900454036,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:6,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:18.905572891235352,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:62.41278076171875,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:369,“freqCalApplied”:-1250,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:57,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.93},{"__type":“MyTagList.Tag”,“notificationJS”:null,“name”:“Kitchen Thermostat”,“uuid”:“9c352334-3811-4bab-8295-6047a15407d8”,“comment”:"@Home",“slaveId”:-1,“tagType”:62,“lastComm”:131203734217940000,“alive”:true,“signaldBm”:-60,“batteryVolt”:3,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:5,“tempEventState”:1,“OutOfRange”:false,“lux”:0,“temperature”:20.5,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:50,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:{“nest_id”:“YucPu7ZCFhaC9-ezLcJTouwLnnHJaWv9”,“honeywell_device_id”:0,“th_low”:14,“th_high”:24,“threshold_q”:{"__type":“MyTagList.Tag+ThresholdQuantization”,“min”:9,“max”:32,“step”:0.1,“sample1”:14,“sample2”:24},“targetUuid”:“9c352334-3811-4bab-8295-6047a15407d8”,“turnOff”:false,“fanOn”:false,“disableLocal”:false,“issuedState”:0},“playback”:null,“postBackInterval”:600,“rev”:0,“version1”:3,“freqOffset”:-18153,“freqCalApplied”:0,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:0,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.94}]}’

logInfo("wt", payload)

var i = -1
//search for no more than 999 tags (this can be modified to whatever, just be sure to adjust the ".length" in the following if statement
while ((i=i+1) <= 999) {
	//parsing an item that doesn't exist returns the entire string
	//so a length larger than 3 characters has exceeded our max slaveID value of 999
	if (transform("JSONPATH", "$.d["+i+"].slaveId", payload).length > 3){
		return false //stop processing
		}

Etc…

Here is the output when running with the original (1)

2016-10-13 11:08:47.246 [INFO ] [rg.eclipse.smarthome.model.script.wt] - Wireless Tag Payload arrived…
2016-10-13 11:08:47.246 [INFO ] [rg.eclipse.smarthome.model.script.wt] - C:\Openhab\userdata>curl -s -X POST -H “Content-Type: application/json; charset=utf-8” -H “Authorization: bearer XXXXXXX-0fa9-4258-b8d0-98aa6157d21e” -d “” “http://mytaglist.com/ethClient.asmx/GetTagList
{“d”:[{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Back Door”,“uuid”:“395eac08-3a39-4df0-9b32-8007a8d03712”,“comment”:"",“slaveId”:3,“tagType”:13,“lastComm”:131207823430274117,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.7843747114367434,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:5,“eventState”:1,“tempEventState”:0,“OutOfRange”:true,“lux”:0,“temperature”:17.489860534667969,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:67.5626220703125,“capRaw”:0,“az2”:0,“capEventState”:1,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:107,“freqCalApplied”:2803,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:175,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.67},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Front Door”,“uuid”:“a73fc3da-89b0-4537-8543-1e4c4eb417b4”,“comment”:"",“slaveId”:2,“tagType”:13,“lastComm”:131090996181611151,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.7126537052616704,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:5,“eventState”:4,“tempEventState”:0,“OutOfRange”:true,“lux”:0,“temperature”:18.304967880249023,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:59.25421142578125,“capRaw”:0,“az2”:0,“capEventState”:2,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-141,“freqCalApplied”:21337,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:255,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.24},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“My Keys”,“uuid”:“a84ea7f9-06fe-4fc7-8f6b-5bb03e37f3e3”,“comment”:"",“slaveId”:6,“tagType”:13,“lastComm”:131106038629255376,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.7408466488344163,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:10,“eventState”:3,“tempEventState”:0,“OutOfRange”:true,“lux”:0,“temperature”:18.1011905670166,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:56.84332275390625,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-13879,“freqCalApplied”:16122,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:111,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.38},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Tag 5”,“uuid”:“cb0f78db-e9f0-4cbe-9c84-c0d55774f061”,“comment”:"",“slaveId”:5,“tagType”:13,“lastComm”:130963036652188222,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.47269217344349,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:1,“tempEventState”:1,“OutOfRange”:true,“lux”:0,“temperature”:15.8918209075928,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:57.34686279296875,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-239,“freqCalApplied”:4041,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:255,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.12},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Front Room PIR”,“uuid”:“40eede82-bbbe-4e2f-961a-42ef27db8b46”,“comment”:"",“slaveId”:8,“tagType”:72,“lastComm”:131204242634375585,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.9227316354915449,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:6,“tempEventState”:0,“OutOfRange”:true,“lux”:0,“temperature”:17.704362869262695,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:64.59478759765625,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:-17227,“freqCalApplied”:22141,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:66,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.92},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Hall PIR”,“uuid”:“c86b7a79-2b4a-4ba9-8811-22748f618c93”,“comment”:"",“slaveId”:7,“tagType”:72,“lastComm”:131208266530312699,“alive”:true,“signaldBm”:-71,“batteryVolt”:2.9721654436629645,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:6,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:17.307533264160156,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:66.12066650390625,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:-15725,“freqCalApplied”:19173,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:49,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.94},{"__type":“MyTagList.Tag”,“notificationJS”:null,“name”:“Hall PIR2”,“uuid”:“e1013cb5-7368-40ae-a013-181247b3d9ac”,“comment”:"",“slaveId”:10,“tagType”:72,“lastComm”:131208267938125849,“alive”:true,“signaldBm”:-71,“batteryVolt”:3.0406115538562908,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:0,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:17.039405822753906,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:62.18389892578125,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:-15217,“freqCalApplied”:20879,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.55,“enLBN”:true,“txpwr”:54,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.96},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Back Room PIR”,“uuid”:“dd2eb71c-d614-4697-a301-0b15a31ae0c1”,“comment”:"",“slaveId”:9,“tagType”:72,“lastComm”:131208262588594974,“alive”:true,“signaldBm”:-78,“batteryVolt”:2.9719723158651092,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:5,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:17.747262954711914,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:63.80133056640625,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:-16789,“freqCalApplied”:16081,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:72,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.93},{"__type":“MyTagList.Tag”,“notificationJS”:null,“name”:“Kitchen Thermostat”,“uuid”:“9c352334-3811-4bab-8295-6047a15407d8”,“comment”:"@Home",“slaveId”:-1,“tagType”:62,“lastComm”:131208266001540000,“alive”:true,“signaldBm”:-60,“batteryVolt”:3,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:5,“tempEventState”:1,“OutOfRange”:false,“lux”:0,“temperature”:19,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:50,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:{“nest_id”:“YucPu7ZCFhaC9-ezLcJTouwLnnHJaWv9”,“honeywell_device_id”:0,“th_low”:13,“th_high”:24,“threshold_q”:{"__type":“MyTagList.Tag+ThresholdQuantization”,“min”:9,“max”:32,“step”:0.1,“sample1”:13,“sample2”:24},“targetUuid”:“9c352334-3811-4bab-8295-6047a15407d8”,“turnOff”:false,“fanOn”:false,“disableLocal”:false,“issuedState”:0},“playback”:null,“postBackInterval”:600,“rev”:0,“version1”:3,“freqOffset”:-18153,“freqCalApplied”:0,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:0,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.94}]}
2016-10-13 11:08:47.246 [ERROR] [.script.engine.ScriptExecutionThread] - Rule ‘UnpackWirelesstagPayload’: cannot invoke method public int java.lang.String.length() on null

And here is the output from (2) when using the hard set variable

2016-10-13 11:18:06.713 [INFO ] [rg.eclipse.smarthome.model.script.wt] - Wireless Tag Payload arrived…
2016-10-13 11:18:06.713 [INFO ] [rg.eclipse.smarthome.model.script.wt] - {“d”:[{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Back Door”,“uuid”:“395eac08-3a39-4df0-9b32-8007a8d03712”,“comment”:"",“slaveId”:3,“tagType”:13,“lastComm”:131203733220625542,“alive”:true,“signaldBm”:-81,“batteryVolt”:2.8291962707054732,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:5,“eventState”:4,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:17.125207901000977,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:63.45037841796875,“capRaw”:0,“az2”:0,“capEventState”:1,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-15481,“freqCalApplied”:18424,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:255,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.88},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Front Door”,“uuid”:“a73fc3da-89b0-4537-8543-1e4c4eb417b4”,“comment”:"",“slaveId”:2,“tagType”:13,“lastComm”:131090996181611151,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.7126537052616704,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:5,“eventState”:4,“tempEventState”:0,“OutOfRange”:true,“lux”:0,“temperature”:18.304967880249023,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:59.25421142578125,“capRaw”:0,“az2”:0,“capEventState”:2,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-141,“freqCalApplied”:21337,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:255,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.24},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“My Keys”,“uuid”:“a84ea7f9-06fe-4fc7-8f6b-5bb03e37f3e3”,“comment”:"",“slaveId”:6,“tagType”:13,“lastComm”:131106038629255376,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.7408466488344163,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:10,“eventState”:3,“tempEventState”:0,“OutOfRange”:true,“lux”:0,“temperature”:18.1011905670166,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:56.84332275390625,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-13879,“freqCalApplied”:16122,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:111,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.38},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Tag 5”,“uuid”:“cb0f78db-e9f0-4cbe-9c84-c0d55774f061”,“comment”:"",“slaveId”:5,“tagType”:13,“lastComm”:130963036652188222,“alive”:false,“signaldBm”:-120,“batteryVolt”:2.47269217344349,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:1,“tempEventState”:1,“OutOfRange”:true,“lux”:0,“temperature”:15.8918209075928,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:57.34686279296875,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:14,“version1”:2,“freqOffset”:-239,“freqCalApplied”:4041,“reviveEvery”:24,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:255,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.12},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Front Room PIR”,“uuid”:“40eede82-bbbe-4e2f-961a-42ef27db8b46”,“comment”:"",“slaveId”:8,“tagType”:72,“lastComm”:131203734313750182,“alive”:true,“signaldBm”:-78,“batteryVolt”:2.9226575175410949,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:6,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:17.875965118408203,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:64.5718994140625,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:-17097,“freqCalApplied”:22141,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:66,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.92},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Hall PIR”,“uuid”:“c86b7a79-2b4a-4ba9-8811-22748f618c93”,“comment”:"",“slaveId”:7,“tagType”:72,“lastComm”:131203733075000440,“alive”:true,“signaldBm”:-72,“batteryVolt”:2.9884504750112115,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:6,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:18.455120086669922,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:63.92340087890625,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:215,“freqCalApplied”:3190,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:16,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.94},{"__type":“MyTagList.Tag”,“notificationJS”:"",“name”:“Back Room PIR”,“uuid”:“dd2eb71c-d614-4697-a301-0b15a31ae0c1”,“comment”:"",“slaveId”:9,“tagType”:72,“lastComm”:131203733380313102,“alive”:true,“signaldBm”:-75,“batteryVolt”:2.9714635900454036,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:6,“tempEventState”:0,“OutOfRange”:false,“lux”:0,“temperature”:18.905572891235352,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:62.41278076171875,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:null,“playback”:null,“postBackInterval”:900,“rev”:143,“version1”:2,“freqOffset”:369,“freqCalApplied”:-1250,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:57,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.93},{"__type":“MyTagList.Tag”,“notificationJS”:null,“name”:“Kitchen Thermostat”,“uuid”:“9c352334-3811-4bab-8295-6047a15407d8”,“comment”:"@Home",“slaveId”:-1,“tagType”:62,“lastComm”:131203734217940000,“alive”:true,“signaldBm”:-60,“batteryVolt”:3,“beeping”:false,“lit”:false,“migrationPending”:false,“beepDurationDefault”:15,“eventState”:5,“tempEventState”:1,“OutOfRange”:false,“lux”:0,“temperature”:20.5,“tempCalOffset”:0,“capCalOffset”:0,“image_md5”:null,“cap”:50,“capRaw”:0,“az2”:0,“capEventState”:0,“lightEventState”:0,“shorted”:false,“thermostat”:{“nest_id”:“YucPu7ZCFhaC9-ezLcJTouwLnnHJaWv9”,“honeywell_device_id”:0,“th_low”:14,“th_high”:24,“threshold_q”:{"__type":“MyTagList.Tag+ThresholdQuantization”,“min”:9,“max”:32,“step”:0.1,“sample1”:14,“sample2”:24},“targetUuid”:“9c352334-3811-4bab-8295-6047a15407d8”,“turnOff”:false,“fanOn”:false,“disableLocal”:false,“issuedState”:0},“playback”:null,“postBackInterval”:600,“rev”:0,“version1”:3,“freqOffset”:-18153,“freqCalApplied”:0,“reviveEvery”:4,“oorGrace”:2,“LBTh”:2.5,“enLBN”:true,“txpwr”:0,“rssiMode”:false,“ds18”:false,“batteryRemaining”:0.94}]}
2016-10-13 11:18:06.713 [INFO ] [rg.eclipse.smarthome.model.script.wt] - Wireless Tag Payload (name: Back Door, slaveId: 3, temp: 17.125207901000977, cap: 63.45037841796875, batt: 0.88, state: 4)
2016-10-13 11:18:06.729 [INFO ] [rg.eclipse.smarthome.model.script.wt] - Wireless Tag Payload (name: Front Door, slaveId: 2, temp: 18.304967880249023, cap: 59.25421142578125, batt: 0.24, state: 4)
2016-10-13 11:18:06.729 [INFO ] [rg.eclipse.smarthome.model.script.wt] - Wireless Tag Payload (name: My Keys, slaveId: 6, temp: 18.1011905670166, cap: 56.84332275390625, batt: 0.38, state: 3)
2016-10-13 11:18:06.744 [INFO ] [rg.eclipse.smarthome.model.script.wt] - Wireless Tag Payload (name: Tag 5, slaveId: 5, temp: 15.8918209075928, cap: 57.34686279296875, batt: 0.12, state: 1)
2016-10-13 11:18:06.791 [INFO ] [rg.eclipse.smarthome.model.script.wt] - Wireless Tag Payload (name: Front Room PIR, slaveId: 8, temp: 17.875965118408203, cap: 64.5718994140625, batt: 0.92, state: 6)
2016-10-13 11:18:06.791 [INFO ] [rg.eclipse.smarthome.model.script.wt] - Wireless Tag Payload (name: Hall PIR, slaveId: 7, temp: 18.455120086669922, cap: 63.92340087890625, batt: 0.94, state: 6)
2016-10-13 11:18:06.791 [INFO ] [rg.eclipse.smarthome.model.script.wt] - Wireless Tag Payload (name: Back Room PIR, slaveId: 9, temp: 18.90557289123535, cap: 62.41278076171875, batt: 0.93, state: 6)
2016-10-13 11:18:06.807 [INFO ] [rg.eclipse.smarthome.model.script.wt] - Wireless Tag Payload (name: Kitchen Thermostat, slaveId: -1, temp: 20.5, cap: 50, batt: 0.94, state: 5)
2016-10-13 11:18:06.807 [ERROR] [.script.engine.ScriptExecutionThread] - Rule ‘UnpackWirelesstagPayload’: cannot invoke method public int java.lang.String.length() on null

There’s some things that I have noted:
- When using the variable, I’ve had to put the string in single quote '
- Even with using the variable, I get the cannot invoke method public on null error at the end.

Anyone know whats going on???

So it throws the null error when giving it the hardwired test string as well?

Perhaps test with a smaller string, as if the get tag list call returned just one item?

Hi @Benhelps

Yes, it throws the null error when using the hardwired test string although it actually processes some values first - then throws it.

At your suggestion, I’ve tried with a single item and it processes the single item then throws a null…

Is it because you’re telling it to iterate over 999 tag id’s but it’s only finding 8or however many you have? And then on tag 9 all data is null? My code only iterates over the number of tags I explicitly have.

Are you using oh1? Have you used designer to see if you need to import anything to make the rule work? I use oh2 and don’t fwiw.

Ah, you are right, that’s why I get the end null.

Can’t work out why when using it in live mode is failing though. Perhaps
it’s down to quotes??

I’m using OH2

I’ve worked out what was going wrong…

When the batch file was executed the command line and payload was being added to the ‘payload’ variable.

Anyone else running windows needs their command to be

@echo off
curl -s -X POST -H “Content-Type: application/json; charset=utf-8” -H “Authorization: bearer XXXXXXXX-0fa9-4258-b8d0-98aa6157d21e” -d “” “http://mytaglist.com/ethClient.asmx/GetTagList

Bah - something so simple…but sorted now!

2 Likes

So is there a summary of this thread? From a quick scan it sounds like a curl command to harvest one or more tags, along with a slew of format errors. As a newbie, I’m not sure what the outcome of all this was, or if it applies to Raspbian. Any comments?

OH2? This is what I use with OH2 and Raspbian.

Items:

String		wirelesstagPayload  { channel="exec:command:getTagList:output" } 
Switch		wirelesstagPayloadRun "Grab latest sensor data" <play> { channel="exec:command:getTagList:run" }
Number		wirelesstagPayloadExit { channel="exec:command:getTagList:exit" }
DateTime	wirelesstagPayloadLastExecution	"Last grabbed: [%1$tH:%1$tM]" <clock> { channel="exec:command:getTagList:lastexecution" }

////Pro Wireless Sensor Tags
Number		sensorAvTemp			"AV Temp [%.1f °C]"				<temperature>		(gChart, gSensorAv)		[ "CurrentTemperature" ]
Number		sensorAvHumidity		"Humidity [%.0f %%]"			<humidity>			(gChart, gSensorAv)
Number		sensorAvBattery			"AV Battery [%d %%]"			<battery>			(gSensorAv, gBattery)

////PIR Wireless Sensor Tags
Number		sensorShedTemp			"Shed Temp [%.1f °C]"			<temperature>		(gChart, gSensorShed)		[ "CurrentTemperature" ]
Number		sensorShedHumidity		"Humidity [%.0f %%]"			<humidity>			(gChart, gSensorShed)
Number		sensorShedBattery		"Shed Battery [%d %%]"			<battery>			(gSensorShed, gBattery)
String		sensorShedPIR			"Shed [MAP(string.map):%s]"		<motiondetected>	(gSensorShed, gMotion)

Thing:

Thing exec:command:getTagList [command="/etc/openhab2/scripts/getTagList.sh", interval=900, timeout=30, autorun=true]

getTagList.sh:

#!/bin/bash

curl -s -X POST -H "Content-Type: application/json; charset=utf-8" -H "Authorization: bearer xxx-xxx-xxx-xxx-xxx" -d "" "http://mytaglist.com/ethClient.asmx/GetTagList"

Rule: In my case I specify the exct number of sensors I have and call them individually rather than using a loop to determine the number magically.

rule WirelessSensorRule
when
    Item wirelesstagPayload received update
then
	logInfo("Sensor", "Wireless Sensor Payload arrived...")
 	val String payload = (wirelesstagPayload.state as StringType).toString
	var i = -1
	while ((i=i+1) < 11){
		//extract the values we care about...
		val String xSlaveId = transform("JSONPATH", "$.d["+i+"].slaveId", payload)
		val String xTemperature = transform("JSONPATH", "$.d["+i+"].temperature", payload)
		val String xHumidity = transform("JSONPATH", "$.d["+i+"].cap", payload)
		val String xBatteryRemaining = transform("JSONPATH", "$.d["+i+"].batteryRemaining", payload)
		//logInfo("Sensor", "Wireless Tag Payload (slaveId: " + xSlaveId + ", temp: " + xTemperature + ", cap: " + xHumidity + ", batt: "+ xBatteryRemaining + ")")

		switch xSlaveId {
			case "0":{
				postUpdate(sensorShedTemp,new DecimalType(xTemperature)*1)
  				postUpdate(sensorShedHumidity,new DecimalType(xHumidity)*1)
  				postUpdate(sensorShedBattery,new DecimalType(xBatteryRemaining)*100)
  			}
			case "1":{
				postUpdate(sensorLaundryTemp,new DecimalType(xTemperature)*1)
  				postUpdate(sensorLaundryHumidity,new DecimalType(xHumidity)*1)
  				postUpdate(sensorLaundryBattery,new DecimalType(xBatteryRemaining)*100)
  			}
			case "2":{
				postUpdate(sensorBed3Temp,new DecimalType(xTemperature)*1)
  				postUpdate(sensorBed3Humidity,new DecimalType(xHumidity)*1)
  				postUpdate(sensorBed3Battery,new DecimalType(xBatteryRemaining)*100)
  			}
			case "3":{
				postUpdate(sensorBed1Temp,new DecimalType(xTemperature)*1)
  				postUpdate(sensorBed1Humidity,new DecimalType(xHumidity)*1)
  				postUpdate(sensorBed1Battery,new DecimalType(xBatteryRemaining)*100)
  			}
			case "4":{
				postUpdate(sensorBed2Temp,new DecimalType(xTemperature)*1)
  				postUpdate(sensorBed2Humidity,new DecimalType(xHumidity)*1)
  				postUpdate(sensorBed2Battery,new DecimalType(xBatteryRemaining)*100)
  			}
			case "5":{
				postUpdate(sensorLivingTemp,new DecimalType(xTemperature)*1)
  				postUpdate(sensorLivingHumidity,new DecimalType(xHumidity)*1)
  				postUpdate(sensorLivingBattery,new DecimalType(xBatteryRemaining)*100)
  			}
			case "6":{
				postUpdate(sensorCarportTemp,new DecimalType(xTemperature)*1)
  				postUpdate(sensorCarportHumidity,new DecimalType(xHumidity)*1)
  				postUpdate(sensorCarportBattery,new DecimalType(xBatteryRemaining)*100)
  			}
			case "7":{
				postUpdate(sensorSideDoorTemp,new DecimalType(xTemperature)*1)
  				postUpdate(sensorSideDoorHumidity,new DecimalType(xHumidity)*1)
  				postUpdate(sensorSideDoorBattery,new DecimalType(xBatteryRemaining)*100)
  			}
			case "8":{
				postUpdate(sensorBathTemp,new DecimalType(xTemperature)*1)
  				postUpdate(sensorBathHumidity,new DecimalType(xHumidity)*1)
  				postUpdate(sensorBathBattery,new DecimalType(xBatteryRemaining)*100)
  			}
			case "9":{
				postUpdate(sensorKitchenTemp,new DecimalType(xTemperature)*1)
  				postUpdate(sensorKitchenHumidity,new DecimalType(xHumidity)*1)
  				postUpdate(sensorKitchenBattery,new DecimalType(xBatteryRemaining)*100)
  			}
			case "10":{
				postUpdate(sensorAvTemp,new DecimalType(xTemperature)*1)
  				postUpdate(sensorAvHumidity,new DecimalType(xHumidity)*1)
  				postUpdate(sensorAvBattery,new DecimalType(xBatteryRemaining)*100)
  			}
		}
	}
end
1 Like

Thanks for this! So does this require the Eclipse development installation
or can I cut/modify/paste the code into magic location in the openhab tree?

I’m not sure what you mean. Install openhab and create the relevant items, thing, script, etc files. Then modify the code above to suit your situation. You’ll need to install at minimum the exec binding, and json transform also.

I guess I wondered whether it was necessary to install the compile
environment, etc., to get this to work. However, it sounds like you are
saying that I don’t have to, but I do have to create some objects (or
files, if you prefer) in the openhab tree.

All I’ve done so far is install openhab and some bindings using Paperui. I
haven’t tried the text file version of creating these objects.

Nah, don’t need to compile anything.

All the config files are easy to manage. I would recommend installing the latest Eclipse Smarthome Designer build. It helps track your items and general syntax. It’s not perfect, but gets the job done.

There’s more than enough info on getting the configuration files prepared on here or the official docs.

Hi there,
I am so wanting to get the wireless tag integrated, currently getting stuck right at the beginning.

I am using a browser and using the URL below, I understand than when I login I should be authorised and get returned a token, instead I get an error that state is causing an exception, not sure what to set it to as its supposed to be optional. Cn you advise?

https://www.mytaglist.com/oauth2/authorize.aspx?client_id=33e6387f-1234-5678-9daa-b9f788241234

My client id has been modified so as not to give anything away.
The response I get back is:

Server Error in '/' Application.

HTTP status string is not valid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: HTTP status string is not valid.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[HttpException (0x80004005): HTTP status string is not valid.]
   System.Web.HttpResponse.set_Status(String value) +4847500
   MyTagList.oauth2.authorize.Page_Load(Object sender, EventArgs e) in C:\z560_backup\MyTagList\MyTagList\oauth2\authorize.aspx.cs:38
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178


Thanks

Paul

From very vague memory the error doesn’t mean anything important. The token is returned in the address bar itself.

Have a look here. I gave a pretty detailed beginner’s step by step to get OAuth set up: https://groups.google.com/d/msg/wireless-sensor-tags/OSQeLHsE4W8/sfls9AUCEwAJ