Change this device handler to be momentary

hi all, i think my last post was too confusing . to make it simple i need to change this below virtual switch device handler to act as a momentary virtual switch , is that possible ?

i really would appreciate some help on this my guess is i just need to replace a couple of lines in this handler, but maybe its much more difficult than i understand ?

Does the example in the SmartThings GitHub work?

Hi, thanks for the quick reply. i did try it and it doesnt work . im using it with zigbee relay that has 3 relays . im using a DH that somone else made and it works fine, but to access the child devices directly i need the simulated / virtual DH and only the one from erocm123 seems to work, but its on / off not momentary…

If you are trying to control a relay, how do you suppose it’s going to work with a momentary switch? One press for on. Then press again for off? Or are you looking for something that will turn it off and then turn it right off. If so, I would suggest using a SmartApp to turn it off immediately. You could use SmartLights or WebCore. You could also use the momentary button tile tied to WebCore to turn the relay on and then off, holding it on for however long you want. I think, in the end, that will be a lot easier than trying to figure out how to re-write the DTH you mentioned.

1 Like

hi there, im using it with a curtain motor. so there is 1 for open 1 for close and 1 for stop. they just need to connect the active wire to common for 1 second each time then disconnect ( momentary connection to common) it works great with the DTH another user put together however no direct access to the child switches so i cant schedule the curtains to close or open at a particular time

I agree there are a lot of ways to add extra apps etc to turn it off again quickly but i really would like to do it properly and keep it simple so it doesn’t break in the future if one of the smart aps no longer works etc. and i found out that if the relay stays on or off too long the motor gets very very hot then shuts down so i didn’t want to start a fire.

i guess i misunderstood the implied simplicity of editing DTH to change from on / off to momentary with just a few lines.

maybe ill just go back to the handheld remotes and give up on smartthings for this one.

But that’s not the way the system works. You would have to rewrite the code for the relay DTH not the virtual switch.

1 Like

Hi Ryan, but the DTH I use for the relay already acts as a momentary switch… it’s only when trying to control the child devices directly with a virtual switch that I’m having the problem with the relay staying on or off after activation

Then why do you need a virtual switch?

i cant access the 3 relays directly for timing tasks etc so need virtual switch to do that.

getting close to smashing it all to bits and throwing it out the window …

back to KNX , its more expensive but many more years of use in the real world so it works.

I’m confused. How will a virtual device help? What DTH are you using for the relay? And what are you trying to use to automate it?

its for an orvibo zigbee relay

im following this old thread. they also stopped before getting it to work as momentary