Sleep

Any time I have Thread::sleep(1000) in a rule I get the following error…

Error during the execution of rule ‘test something’: feature was simple feature call but got receiver instead of null. Receiver: 1000

Any thoughts?

In my rules using a Thread::sleep I have the following imports:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.java.math.*
import org.joda.time.*

Maybe you are missing an import?

Thanks for the reply @sihui but I adjusted my imports to match yours and it still gives me the same thing.

Any other thoughts?

It can’t be a missing import issue because I am using
Thread::sleep(1000)
in a script as you see it above.

You may need to provide the full Rule defn to improve the answers. It’s possible that’s there’s something else in the Rule-def that’s causing the specific error you’re seeing.

Ok, here is the function that I made.

val org.eclipse.xtext.xbase.lib.Functions$Function1 hue_dimm_off = [
org.openhab.core.library.items.DimmerItem hueDimm |
	var Number Dimmer_old = hueDimm.historicState(now.minusSeconds(10)).state
	while (Dimmer_old>0)
	{		
		if(Dimmer_old<5)
		{	
			Dimmer_old=0
		else
			Dimmer_old=Dimmer_old-1
		}
		sendCommand(hueDimm, Dimmer_old)
		Thread::sleep(1000)
	}		
]

and here is how I call it.

hue_dimm_off.apply(Dimm_3)

Any help would be great.

Thanks

Missing brackets at the if-else-statement??

val org.eclipse.xtext.xbase.lib.Functions$Function1 hue_dimm_off = [
org.openhab.core.library.items.DimmerItem hueDimm |
var Number Dimmer_old = hueDimm.historicState(now.minusSeconds(10)).state
while (Dimmer_old>0)
{
if(Dimmer_old<5)
{
Dimmer_old=0
}

	else
                                {
		Dimmer_old=Dimmer_old-1
	}
	sendCommand(hueDimm, Dimmer_old)
	Thread::sleep(1000)
}		

]

I tried that but it gave me the same error.

Try replacing with this:

try { Thread::sleep(1000) } catch(Exception e) {}

Still get an error with that @Denis_Lambert

2016-04-12 18:34:54.153 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule ‘test something’: feature was simple feature call but got receiver instead of null. Receiver: 1000

Sorry Dan that it did not help.
Do you use OpenHAB Designer to write your code ? It can give you so much information …

I don’t, I did try it around the time I originally posted this issue but I feel like it gives a lot of false warnings/errors too. It’s fine for now but I do hope to resolve this at some point. The weather is getting nice and I will hopefully be spending less of my free time in front of a computer. Other than the new zwave thermostat that I need to install and get functioning in openhab I don’t have any major changes coming to my installation for at least the next month or two.

Anyone have any new thoughts. I’d like to be able to use this functionality.

Finally found the issue… silly me :confounded: I had an item with the name of ‘sleep’ which was interfering with the function.

I should’ve picked up on this before but everything worked fine with the item so it didn’t cross my mind.

1 Like