[SOLVED] Problem with IHC push button, light toggles on/off

Hi there.

I have a little problems with my push-button to my IHC bindings.
When i use it from the iphone app, it turns the light on and off, but sometimes it toggles on and off multiply times.
I have to make push-buttons, because many of my functions in the IHC controller expects that.

My items :

Switch stue_skrivebord_switch 	(gStue_stue)		{ ihc=">5086481" }
Switch stue_skrivebord_state  	(gStue_stue, lys)	{ ihc="5087506" }

My rules:

rule "kip spisebord"
when
Item stue_spisestue_switch changed to ON  
	then
		stue_spisestue_switch.sendCommand(ON)
    Thread::sleep(1000)
       stue_spisestue_switch.sendCommand(OFF)
end

My sitemap:

Switch item=stue_skrivebord_switch label="Lampested skrivebord" icon="light-on" mappings=[ON="Sluk"]  visibility=[stue_skrivebord_state=="ON"]
Switch item=stue_skrivebord_switch label="Lampested skrivebord" icon="light-off" mappings=[ON="Tænd"]  visibility=[stue_skrivebord_state=="OFF"]

Snippet from my log:

2016-08-03 21:03:08 - stue_skrivebord_switch received command ON
2016-08-03 21:03:08 - stue_skrivebord_switch received command ON
2016-08-03 21:03:10 - stue_skrivebord_switch received command OFF
2016-08-03 21:03:12 - stue_skrivebord_state state updated to ON
2016-08-03 21:03:12 - stue_skrivebord_state state updated to OFF
2016-08-03 21:03:16 - stue_skrivebord_switch received command ON
2016-08-03 21:03:16 - stue_skrivebord_switch received command ON
2016-08-03 21:03:18 - stue_skrivebord_switch received command OFF

as you can se, it goes on and right af it turns off again. Kind of annoying.
I’am only using the iphone app, so i havent tried the webpage directly in a browser. Maybe it could be a problem in the app.

I’am running the latest version 1.8.3 on linux mint.

It looks like the switch is turning it on via the binding, and then your rule is also turning it on.

Try this, and see if you get the result you want.

rule "kip spisebord"
when
Item stue_spisestue_switch changed to ON
then
Thread::sleep(1000)
stue_spisestue_switch.sendCommand(OFF)
end

Thanks Chris, that worked.

No problem, glad I could help. Still learning this myself.