I try the following rule in order to catch user input from the basicui and trigger settings of an external device. The trigger works as expected, but I am not able to read the value of the Number type Item.
- Platform information:
- RPi with openhabian and openHAB 2.5.0~S1549-1 (Build #1549)
- Rules code related to the issue
rule "setPowerLimit"
when
Item PW_powerLimit changed
then
\\var String testString = PW_powerLimit.toString
logInfo("new powerLimit is ", PW_powerLimit.toString)
var Number newPowerLimit = PW_powerLimit.state
logInfo("new powerLimit is ", newPowerLimit)
end
Item:
Number PW_powerLimit "powerLimit [%d A]" { http="<[http://<IP:port>/powerLimit:30000:JSONPATH($.powerLimit)]" }
The first logInfo in this minimal rule show that the item is actually a Number Item, and also show that the item contains “State=26”. The second logInfo should print the number, but it throws an error. I have tried many different options suggested, but I am not able to read the value to a variable.
I hope anyone spot my silly mistake.
- Services configuration related to the issue
- If logs where generated please post these here using code fences:
2019-03-18 11:25:44.465 [INFO ] [home.model.script.new powerLimit is ] - PW_powerLimit (Type=NumberItem, State=32, Label=powerLimit, Category=null)
2019-03-18 11:25:44.471 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'setPowerLimit': 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