Hi all,
I didn’t know where to post this because it touches so many subjects but since I am trying to do it in a rule ill post it here.
So I have a MQTT item that receives a big payload of JSON formatted stuff
Item:
String Bluez “[%s]” {mqtt="<[happybubblesmqtt:happy-bubbles/presence/changes:state:default]"}
Payload:
{
"beacon_info": {
"name": "undefined",
"beacon_id": "c869cddcf85e",
"beacon_type": "",
"beacon_location": "",
"last_seen": 1500049168,
"incoming_json": {
"hostname": "happy-bubbles-ble",
"mac": "c869cddcf85e",
"rssi": -64,
"is_scan_response": "0",
"type": "0",
"data": "02011a0bff4c0009060319c0a80103",
"beacon_type": "",
"uuid": "",
"major": "",
"minor": "",
"tx_power": "",
"namespace": "",
"instance_id": ""
},
"distance": 0,
"Previous_location": "happy-bubbles-ble",
"Previous_confident_location": "",
"Location_confidence": 0
},
"name": "undefined",
"beacon_name": "undefined",
"previous_location": "",
"new_location": "happy-bubbles-ble",
"timestamp": 1500049168
}
I’ve created a rule that looks for a change to that item. What i am looking to do is to get the value of the “new _location” JSON item, but can’t seem to get it working and am totally lost. Any suggestions?
rule "Bluez"
when
Item Bluez changed
then
var String json = (Bluez.state as StringType).toString
var String type = transform("JSONPATH", "$.[new_location]", json)
BluezStatus.postUpdate(type)
end
BluezStatus is another item, mainly for debugging purposes
String Status “[%s]”