Hi,
is it possible to set the task interval by mqtt or http command? Usually i need the measurements once a hour, but sometimes i like to set a shorter interval. I can change the interval for every device in the web-interface, but it would be easier to use commands. Also it would then possible to automate it, e.g. "set the measurement interval to 5 minutes for the next hour and then back to the old value".
Thanks in advance.
Setting task interval by mqtt or http
Moderators: grovkillen, Stuntteam, TD-er
Re: Setting task interval by mqtt or http
You can force an extra interval by issuing the 'TaskRun' command. You can send that command either from MQTT or HTTP, best would be to add an event in the rules
this would need a command like `event,TriggerTaskNow=3` when the intended task to trigger/run is 3.
This will run it only once.
If you want to change the frequency you would have to do something with a LoopTimerSet command. Please be aware that the normal interval will still be running as well.
NB: There is no command available to change the interval of a task.
Code: Select all
on TriggerTaskNow do
if %eventvalue1% > 0
TaskRun,%eventvalue1%
endif
endon
This will run it only once.
If you want to change the frequency you would have to do something with a LoopTimerSet command. Please be aware that the normal interval will still be running as well.
NB: There is no command available to change the interval of a task.
/Ton (PayPal.me)
Re: Setting task interval by mqtt or http
I had a little more time now, so I took a stab at that repeating option:
This way you can send from a couple of sources (Tools page, html, MQTT) the command 'event,TaskTimerLoop=3,600' and this will trigger task# 3 every 10 minutes.
Disclaimer: Untested code
Code: Select all
on TriggerTaskLoop do // argument 1 = task number, argument 2 = interval in seconds, minimum = 10 else the loop is stopped
if %eventvalue1% > 0
if %eventvalue2% >= 10
Let,88,%eventvalue1% // 88 is just a random variable number
LoopTimerSet,1,%eventvalue2% // Start repeating timer
else
LoopTimerSet,1,0 // Stop timer
endif
endif
endon
on rules#timer=1 do
if %v88% > 0 // Valid?
TaskRun,%v88%
endif
endon
Disclaimer: Untested code
/Ton (PayPal.me)
Re: Setting task interval by mqtt or http
Thank you very much for your answers.
I have implemented your first version. For now the automation takes place in the hub. There i have a script which runs the http-command every 10 seconds. It would be better, if the repeating takes place on the microcontroller to reduce the traffic. So i will try your new version too.
I have implemented your first version. For now the automation takes place in the hub. There i have a script which runs the http-command every 10 seconds. It would be better, if the repeating takes place on the microcontroller to reduce the traffic. So i will try your new version too.
Who is online
Users browsing this forum: No registered users and 29 guests