Number home_temp "Living Room [%.1f °C]" <temperature> ["CurrentTemperature"] {mqtt="<[mosquitto:application/2/node/0000000000000013/rx:state:JSONPATH($.object.adc)]"}
Ok, so you are getting home temp from the binding as number already transofrmed and then you are trying to transform it again in the rule.
Create this item:
String JsonString { mqtt="<[mosquitto:application/2/node/0000000000000013/rx:state:default" }
Add a space it the {}
of the home_temp item just in case. It helps sometimes. And remove the tag. And comment out the binding temporarily.
Number home_temp "Living Room [%.1f °C]" <temperature> //{ mqtt="<[mosquitto:application/2/node/0000000000000013/rx:state:JSONPATH($.object.adc)]" }
Then change the rule to:
rule "Parse Room Temperature_1"
when
Item jsonString received update
then
val tem = transform("JSONPATH", "$.Object.adc", home_temp)
logInfo("TEST", tem.toString)
home_temp.postUpdate(tem)
end
I have done it like you said…
rule "Parse Room Temperature_1"
when
Item JsonString received update
then
logInfo("TEST", "running")
logInfo("TEST1", JsonString)
val tem = transform("JSONPATH","$.object.adc",JsonString)
logInfo("TEST", tem)
home_temp.postUpdate(tem)
end
That’s the rules file
Number home_temp "Living Room [%.1f °C]" <temperature>
String JsonString {mqtt="<[mosquitto:application/2/node/0000000000000013/rx:state:default]"}
That’s the items file
2018-08-14 12:43:03.948 [INFO ] [.eclipse.smarthome.model.script.TEST] - running
2018-08-14 12:43:03.949 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Parse Room Temperature_1': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.LogAction.logInfo(java.lang.String,java.lang.String,java.lang.Object[]) on instance: null
2018-08-14 12:43:04.923 [INFO ] [.eclipse.smarthome.model.script.TEST] - running
2018-08-14 12:43:04.924 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Parse Room Temperature_1': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.LogAction.logInfo(java.lang.String,java.lang.String,java.lang.Object[]) on instance: null
Thts log . I’n not sure what causes these errors… any help…
Try that:
rule "Parse Room Temperature_1"
when
Item JsonString received update
then
logInfo("TEST", "running")
logInfo("TEST1", JsonString.toString)
val tem = transform("JSONPATH", "$.object.adc", JsonString.toString)
logInfo("TEST", tem)
home_temp.postUpdate(tem)
end
2018-08-14 16:05:38.940 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'b.rules'
2018-08-14 16:05:44.621 [INFO ] [.eclipse.smarthome.model.script.TEST] - running
2018-08-14 16:05:44.622 [INFO ] [eclipse.smarthome.model.script.TEST1] - JsonString (Type=StringItem, State={
"applicationID": "2",
"applicationName": "",
"deviceName": "0",
"devEUI": "",
"rxInfo": [
{
"mac": "b827ebfffe0edf3b",
"rssi": -119,
"loRaSNR": 4.5,
"name": "wizsen-",
"latitude": ,
"longitude":,
"altitude": 40
}
],
"txInfo": {
"frequency": ,
"dataRate": {
"modulation": "LORA",
"bandwidth": 125,
"spreadFactor": 12
},
"adr": true,
"codeRate": "4/5"
},
"fCnt": 139,
"fPort": 11,
"data": "",
"object": {
"adc": "1071"
}
}, Label=null, Category=null)
2018-08-14 16:05:44.669 [ERROR] [ore.transform.actions.Transformation] - Error executing the transformation 'JSONPATH': Invalid path '$.object.adc' in 'JsonString (Type=StringItem, State={
"applicationID": "2",
"applicationName": "India-Lecture",
"deviceName": "0000000000000013",
"devEUI": "0000000000000013",
I’m able to get the entire data…
2018-08-14 16:05:45.339 [WARN ] [rthome.model.script.actions.BusEvent] - Cannot convert 'JsonString (Type=StringItem, State={
, Label=null, Category=null)' to a state type which item 'home_temp' accepts: [DecimalType, UnDefType].
I suppose i need to convert it into a decimal type… because it’s not updating in openhab… is there any command to do that?
Again. use .toString
rule "Parse Room Temperature_1"
when
Item JsonString received update
then
logInfo("TEST", "running")
logInfo("TEST1", JsonString.toString)
val tem = transform("JSONPATH", "$.object.adc", JsonString.toString)
logInfo("TEST", tem)
home_temp.postUpdate(tem.toString)
end
But now that we have established that
- mqtt works
- binding syntax is correct
You can try this directly and bypass the rule:
Number home_temp "Living Room [%.1f °C]" <temperature> {mqtt="<[mosquitto:application/2/node/0000000000000013/rx:state:JSONPATH($.object.adc)]"}
Cool that works!
Now are you sure that this is a temperature?
No temperature is not being sent, But Thank you , couldn’t have done it without your help