I try to get the state from an item in a DSL Rule:
var String intentItem = transform("JSONPATH", "$.slots.value.value", ChangeLightState_ChangeLightState.state.toString)
var state = intentItem.state.toString //does not work
So I get the name of the item via MQTT.
Then I can change the state via sendCommand but I am not able to get the state. I get the following error: The method or field state is undefined for the type String
(I would assume the same error for sendCommand)
For others to see a working example in DSL Rule GUI:
var String intentItemString = transform("JSONPATH", "$.slots.value.value", ChangeLightState_ChangeLightState.state.toString)
val intentItem = org.openhab.core.model.script.ScriptServiceUtil.getItemRegistry.getItem(intentItemString)
var state = intentItem.state.toString //works
There are multiple openHAB versions in common use. This affects where you have to get imports from. Which are you using?
There are file based DSL rules, and UI based DSL rules. These behave differently so far as imports goes. Which are you using?