Hi ,
Is it possible to add time delay when I turn ON or OFF a generic power switch ? For example I want to press ON the switch and the connected Relay will be ON and after a few seconds OFF.
Can I have an example of the script please ?
Thanks !
Hi ,
Is it possible to add time delay when I turn ON or OFF a generic power switch ? For example I want to press ON the switch and the connected Relay will be ON and after a few seconds OFF.
Can I have an example of the script please ?
Thanks !
You can use a Timer for that.
ThingEvent {
thingId: "..." // Some button
eventName: "pressed"
onTriggered: timer.start()
}
Timer {
id: timer
interval: 5000
onTriggered: light.value = true
}
ThingState {
id: light
thingId: "..." // some light
stateName: "power"
}
Here are the docs for the timer: Timer QML Type | Qt QML 5.15.8
actually, if you just want to add a auto-off to a light you might also just do something like this:
ThingState {
id: light
thingId: "..." // some light
stateName: "power"
}
Timer {
interval: 5000
running: light.value === true
onTriggered: light.value = false
}
This would now auto-start the time every time the light goes on and turn it off again after 5 seconds, regardless of how the light was turned on (either via app, or some other rule, or anything else).
Very nice Thank you again !
what is the name of this programming language please ?