Help with Raw Data to String [SOLVED]

I have a LightwaveRF switch with the following configuration:

String My_Switch { rfxcom="<15934579.1:RawData" }

And then the following rule:

rule "My Rule"
when
        Item My_Switch received update
then
         logDebug("My.rules", My_Switch.state)
end

However when I press the switch I get the following message in the debug logs:

18:36:40.970 [INFO ] [runtime.busevents             :26   ] - My_Switch state updated to 0A140086F38DEB010F0070
18:36:40.971 [DEBUG] [m.r.internal.engine.RuleEngine:305  ] - Executing rule 'My Rule'
18:36:40.971 [DEBUG] [o.o.i.m.i.MyOpenHABServiceImpl:262  ] - store(My_Switch), state = 0A140086F38DEB010F0070
18:36:40.975 [ERROR] [o.o.c.s.ScriptExecutionThread :50   ] - Error during the execution of rule 'My Rule': Could not invoke method: org.openhab.model.script.actions.LogAction.logDebug(java.lang.String,java.lang.String,java.lang.Object[]) on instance: null

So it is my understanding that it updates the state of the item but when I try and access it in the rule it returns null which causes the log to throw an exception.

What am I doing wrong?

Try logDebug("My.rules", My_Switch.state.toString)

The rules engine doesn’t know how to cast the state to a String which is what logDebug requires.

2 Likes

Thank you so much!