Cockpit trigger Action with a delay

I have a question about whether I can change a variable with a delay, e.g., 2s? Or sending a mavlink command with a delay?

There’s no built-in support for delays on Action calls yet. Interesting request :smiley:

I’ve opened an issue so we can put in our timeline at some point, but in the meantime what you can do is to use a Javascript Action as a man-in-the-middle. You would use the joystick button to call this Javascript action, which would have a code to call the desired MAVLink action after some time, like that:

const mavlinkActionId = 'abcdef' // Replace with the ID of your MAVLink action
const runMavlinkAction = window.cockpit.executeActionCallback(mavlinkActionId)
setTimeout(runMavlinkAction, 2000) // Run the action after 2 seconds

```
1 Like

Hi @KoBo,

I’ve moved this to its own thread, since it’s not relevant to the original one.

Could you explain more about why you want to do this / what it would help you to achieve? Understanding the value of suggestions helps us to prioritise development work :slight_smile:

If it’s relevant, it is already possible to trigger Actions at a minimum or maximum frequency, although those features are focused around repeated triggers rather than one-off event handling.