.state problems

Hi All,

I’m having a difficult day with OpenHab!

I simply can’t get the .state command to work for me.

I have a rule that runs when an item called setpos is updated.

rule “Timer Transformation”

	Item setpos received update
	logDebug("rule_debug","Timer Transformation Rule Starting")		
	logDebug("rule_debug", setpos.state)					
	val String payload = setpos.state
	logDebug("rule_debug", payload)	
	val String payload = payload.substring(1,3)	
            logDebug("rule_debug", payload)					
	postUpdate(setpos1, payload)		

This doesn’t work and the only log I get is the first one. To note is that setpos is a mix of text and numbers.

Does this problem have anything to do with formatting of strings?


If you explicitly convert the state to a String, like

logDebug("rule_debug", setpos.state.toString)

does that work any better?

Yes thanks!


logDebug(“rule_debug”,“blah blah” + setpos.state)

You are doing string concat here so you need the + operator