Any way to get a timed button?

For my planned project it is mandatory to be able to turn a gpio to high for say 15 seconds.
As I’ve read there is no widget that features this, do you guys know any work around?

edit: Any kind of pulse to trigger a relais would be enough.

Thanks a lot in advance.



Marius, welcome to the Cayenne Community!

I was needing something very similar. I have a light that is controlled by a motion sensor and I would like the light to stay on for 15 or so minutes after the last motion was detected. I haven’t figured out a work around.

How about we move this to the Ideas/Suggestions group and see if we can get it implemented in an upcoming build? I can move it in a couple clicks, let me know if you’re ok with that idea.

Again, welcome,


Sure please move it, I wasn’t sure where to post it.

I have this setup already working using webiopi. Did you look into that?

It’s the basis of cayenne and while a bit more complicated in use, it is a much more powerful tool for the same purpose.

I’d be happy to get you started using it, if you want. I’m sure we can find a solution for your light with very few lines of code.


1 Like


Marius, thanks so much for the offer! My vision is that I can do all the things that I would like to as it relates to IoT without having to do a single sudo nano anything. And the nice thing about the folks at Cayenne is that they are receptive to the requests of the community.

Thanks again for the offer,


No problem, I share your vision.

Seeing that such a basic funktion is not included in cayenne curbed my enthusiasm a bit though.

I have an idea for a workaround for your problem using cayenne only:

You could wire the output used for activating the light to an input pin.
Now create a rule that turns the output pin off when said input is activated.
This should result in the output only sending a small pulse. You can use this to trigger a timed relais that turns on your light for a set period of time.

If you prefer to wait for the feature to be implemented i can totally understand that!

I look forward to some sort of a logic small python script sand box where tasks like this one can be set up almost like a patch bay from a list of examples. E.g. a method of generating py scripted ‘one shots’ or R/S type latch logic coupled with some code such as Delay ON or OFF

If this system can also grab local, weird wired home brew local variables and transfer them via any number format shifting and then poke them INto and OUTof the local Pi then that would make things really exciting…

Apologies to those who have heard me already on this idea…

For now my creative solution to the above would be large-ish capacitors, spare input pins and 100k / 1 Meg resistor connected to a pin that goes high when the capacitor charges… May even get around to this water clock level of technology just for a hoot… A flip flop a-stable between NZ and the West Coast… Wild eh ?

~ Andrew

1 Like

More parts and wires, and less code!

I like it!

That’s what I was thinking, too. You worded it much better.

It’s a wild solution for such a small problem that only needs a few lines of code.

For now, I will stick with webiopi, as it lets me use my own python scripts. Sadly I have to use my own, horrible ugly Webinterface instead of the eye candy that Cayenne delivers.

I would like to see some WebIOPi type ideas at least being able to to be patched into Cayenne. There are a lot of cross links there already and seems the engine is already pretty closely coupled… Perhaps a few variables in a table added to the bottom of the GPIO page ?

  • System variables
  • Table of input and output variables
  • Within WebIOPi we carry on being creative with a pretty good system

Ideas ?

  • A function WebIOPi passes data to and from Cayenne
  • Function when called in a py script / used causes variable to appear in Cayenne and or be examined in say a table at the bottom of the GPIO page tab

~ Andrew

I have no idea how we could implement it in Cayenne by patch.

Essentially you only need the option to run a python function instead of triggering a output, and handle the callback.

But I think the UI does not run on the RPi but on Cayenne-Server, so I see no way of fiddling with it.

We’ll be discussing how to best do this here: Online Meetup - 03/24/16 12pm - 1pm PDT - #17 by picaxe

If you have some time, would love if you could join to give some input.


1 Like

Hey Andrew,

Do you think you could expand a little bit with some use cases, or post some mock-ups / diagrams etc. of how you’d envision this python script sand box to work in Cayenne?

Right now, I’m sort of mentally separating customization abilities into three categories: Triggers, device drivers, and custom widgets.

  1. Triggers customization would allow for people to create a THEN trigger that fires off some script when the IF part of the statement is activated.

  2. Device drivers would allow people to bring on any device they’d like, as long as they provided their own code for it. Of course, it would be up to the user to make sure the device driver functioned correctly.

  3. Custom widgets would allow for code to be inserted into a widget, whether that widget be a button, input state, slider, etc. (note that these widgets could also appear in the THEN dropdown of trigger statements)

Adding a few more people here who have voiced interest. @Lynx @Ian @jhovak @mac_ha @derikj @etienne.villedieu @jennasys @kreggly @mat_oldaker @ats1080s @will @dzachareas @maurifree @eptak

Hi bestes,

The integration of python scripts sounds great!

However, will you also possibly add the pulse-function to the output-dropdown with a field to enter the duration?

This could be used to send short pulses or turn e.g. a light on for a couple of hours easily.

1 Like


User code raises another interesting thought.

Why not create a user store for drivers, procedures, etc.

Would be a good way to build a public community around MyDevices and allow projects to be shared.

Outside goal. Outside goal :slight_smile:

Arguably though, I think drivers, etc. should require a certain framework, and include test hooks for automated software testing.


1 Like

All of these sound like they’d be very useful.

In regards to the OP, would it be possible to either add a time parameter to a trigger, or maybe even have “Timer” be an available “device” in the tool chain on the Cayenne side, where an event could trigger a timer to turn on, that then triggers another event when it times out. Ideally this could be set up as a one-shot or repeating event.

For custom device drivers, I would like to see a Python API that could be used on the RasPi side to communicate with a “User Device” Cayenne widget. To start with, the widget(s) wouldn’t necessarily having to be directly modified by the user, they’d just respond to data coming from the API.

For custom widgets, having a JavaScript API to access data and a user accessible frame or div in the widget where HTML/JS could be inserted would be great. This would then also open up the possibility to work with arbitrary data sent directly from the RasPi (text information, or raw data that has been collected).

I realize that the more you open things up the more careful you have to be with implementation for security and reliability reasons, but these type of features also move the Cayenne product up to a whole new level of application applicability. They will also allow those that start using Cayenne for simple applications with little code, to stay with the platform as their applications grow in complexity.

1 Like

Hey Lynx,

I definitely want to add timer functionality. Do you think you can provide some thoughts? (Others chime in too please :slight_smile: )
See the “Set a Timer” section near bottom:

Is this what you were envisioning? It’s still in development, but you would be able to set the high state of the output for a specific duration and then (optionally) set the low state for a specified duration. And how important would it be to include an option for the ‘pulse’ to occur only for a specified number of pulses? For example, turn high for 15 seconds, low for 5 seconds, and repeat this 3 times.

Of course now there is the question of how to integrate timers into triggers, as @Ian mentioned earlier: [quote=“Ian, post:2, topic:350”]
I would like the light to stay on for 15 or so minutes after the last motion was detected

So there could be two use cases (1. a dashboard timer, and 2. a trigger timer) that could be different, and may overlap each other. @Ian would you want to be able to set different timer settings on the dashboard widget for your light, and then also in the trigger for the motion detector and light?

Furthermore, there can be timer functionality used in the trigger itself…IF temperature is below 65 degrees F for 20 minutes, THEN send me a text. (this is likely lower priority than the above two, but probably should still be considered when designing for the above).


Looks good, but I hope the duration will allow to select second/minutes/hours?.. The same at the trigger level would be useful too - your example is exactly to the point!..

1 Like


It hadn’t occurred to me to have timers in both the triggers and widgets, but why not?

Lets apply the ‘Field of Dreams’ rule-
“If you build it, he will come.”



Totally, seconds/minutes/hours should be included, although the mock-up doesn’t show it.


Lovely! Exactly how i imagined it. I really have nothing to improve here.

To the pulse:
I think it would be great to be able to:

-send specified pulse (like 100ms)

-wait specified time (eg 15 minutes

-send the same pulse again

This would be able to trigger common pulse relais, in addition to the classic relais that we can use with the normal timer you are implementing.