Debugging rules: set item state

Hi,

when I am writing rules for OpenHAB I frequently run into this problem and assume I am missing something:

Assume I am writing a rule that depends on the state of an item:

rule "XY" when Item someItem changed to ON then doSomething someItem.sendCommand(OFF) end

Now let’s assume I made a mistake in this rule and someItem will not be set back to OFF in the end. Then, in the next run, the rule will of course not fire. The only way I am able to set someItem back to OFF is by creating another dummy rule with a cron item triggering in the next minute that does nothing but set its state back to OFF. I guess this is not the way how to properly do that, right? Is there no way to change the state of an item from the GUI or something?

Thanks a lot, Torsten

Either use received command or use received update as trigger.

If it’s only to make sure that the same item turns off, you could use the expire binding

@Udo: yes, in this example this would solve the issue but the general issue is not addressed. I still cannot changed the item’s state for debugging purposes.

@Sascha: yes, but then I have to foresee that I make this mistake. :slight_smile:

You can actually, using the REST API or the Karaf console.

Thank you, that looks like what I was looking for:

What about having a seciton in your UI that allows overrides for some items? (still no automatic solution, and I believe that’s not exactly what you’re looking for)

I have a sitemap that shows me the current state of my smoke detector alarms (truncated here in this example):

Frame label="Feueralarm"
{
	Text item=FireAlarm_SmokeDetector_Bedroom_Attic	label="Schlafzimmer (DG)"
}

At the time i haven’t had set up persistence to restore states upon startup, i also had the need to override those - otherwise i would get different/wrong values since the smoke detectors report only an alarm if there is one. So i was implementing an override section in my UI:

Text label="Overrides"
{
	Frame label="Feueralarm"
	{
		Switch item=FireAlarm_SmokeDetector_Bedroom_Attic
	}
}

So once i was finishing with any stuff related to those items, I was just getting back to the UI and used the override section to set the correct state…