Action with period of time conditions

Hello,

I would like to execute an action when a condition is true for at least a certain period of time.
How can I achieve this king of rule/magic (by script or directly with magic) ?

Thanks

Hi,

so for that I’d suggest going with a script:

ThingState {
    id: someState
    thingId: ...
    stateName: ...
}

Timer {
  interval: 5000
  running: someState.value == 5 // or whatever the condition should be
  repeat: false // set to true if it should be repeated every "interval" while the condition stays to true
  onTriggered: {
    console.log("Condition is true for 5 seconds")
  }
}

In order to achieve this with rules, you’d probably have to create a timer thing (from the datetime plugin) which is started by a rule when the condition is met and a second rule to do whatever you want when the timer thing triggeres the timeout signal… If you’re not struggling with scripting in general, the script certainly seems the easier/more manageable approach.

Hi,

Thanks a lot.
No worries with scripts from my side.