Openhabian 1 Chl Relay Switch with multiple variables

Hi, I’m using the latest Openhabian on RPI3.

I have managed to setup an item and sitemap for one project and it works fine, but this project needs to switch a pump on for different time periods and also to setup up a scheduled pump time for particular days.

I have setup the items with different expire periods and the buttons work as required but only one of the items will operate the relay switch. Here is my coding:

Items:

//Relays

Switch channel1 "Pump for 2 Hours" { gpio="pin:26 force:yes activelow:no", expire="2s,command=OFF" }

//Relays
Switch channel2 "Pump for 1 Hour" { gpio="pin:26 force:yes activelow:no", expire="4s,command=OFF" }

//Relays
Switch channel3 "Pump for 1/2 Hour" { gpio="pin:26 force:yes activelow:no", expire="6s,command=OFF" }

Sitemap:

sitemap home label="Bore Pump to Tank"

{


	Frame label="Pump for 2 Hours"
	{
		Switch item=channel1


		

	
}

	Frame label="Pump for 1 Hour"
	{
		Switch item=channel2
	
	
}


	Frame label="Pump for 1/2 Hour"
	{
		Switch item=channel3



	
}


}

Times in the code are only in seconds for testing, once working I will change them to the correct values.

Any help would be appreciated.

Mark

Whilst your idea should work in theory, I’m not very convinced that GPIO binding ( a version 1.x binding) is going to properly handle several Items linked to same output pin.
I think you’ll have to abandon that, and go with one Item and rules starting Timers. You can still have your longest time as an expire action, for safety.

Thanks rossko57,

I had not played around with rules before, after looking around for different types of examples I finally got something to work for me and it all works great, I even managed to set a regular schedule to run the pump at required times.

I wasn’t able to leave the expire action in the switch that was set as for the GPIO binding, once I removed it then the other switches I setup to run with the rules worked.