Hey
I’m working with a HappyBubbles presence detect which sends json objects like this one:
Client mosqsub/9758-raspberryp received PUBLISH (d0, q0, r0, m0, 'happy-bubbles/presence/ha/happy-bubble', ... (99 bytes))
{"id":"e2c56db5dffb48d2b060d0f5a71096e0_0000_0000","name":"iBeacon","distance":0.06810391947790942}
to the broker. I have already set up an Item to read out the distance and display it in a sitemap:
String distance "Distanz[%s]" <line> {mqtt="<[broker:happy-bubbles/presence/ha/happy-bubble:state:JSONPATH($.distance)]"}
which works reliably. Now I want to set up a rule which acts depending on the distance, i.e. when the distance is greater than 10, do x and when the distance is smaller, do x.
For some reason, I cannot get the distance into the rule. I have tried printing it with logInfo, but it always says the variable is empty.
Rule:
rule "test 2"
when
Item motion_sensor changed from OFF to ON
then
var String stringo = distance.state
logInfo("log", stringo)
end
Logging output:
16:22:33.804 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'test 2': 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
What am I doing wrong and how can I get the value?
Also, any other pointers in this regard? I’m really struggling with the documentation.