Page 1 of 1
Dummy TaskValueSet from examples not working
Posted: 28 Apr 2023, 04:36
by thalesmaoa
Hello, I've read a lot of posts with related topics. Also checked from docs. However, I can't understand why I'm not able to check dummy var.
Code: Select all
on Rules#Timer=3 do
if [dummy#var1]=0
TaskValueSet dummy,var1,1
else
TaskValueSet dummy,var1,0
endif
timerSet,3,2
endon
It always set zero.
Code: Select all
590457: EVENT: Rules#Timer=3,1
590472: TIMER: disable timer
590504: ACT : TaskValueSet dummy,var1,0
590512: ACT : timerSet,3,2
592514: EVENT: Rules#Timer=3,1
592529: TIMER: disable timer
592561: ACT : TaskValueSet dummy,var1,0
594670: ACT : timerSet,3,2
Re: Dummy TaskValueSet from examples not working
Posted: 28 Apr 2023, 08:27
by dr.zorg82
your third timer starts the third timer? i.e. itself?
Do you also have the setting enabled : tools>Advanced Settings>Allow TaskValueSet on all plugins ?
Re: Dummy TaskValueSet from examples not working
Posted: 28 Apr 2023, 08:52
by Ath
dr.zorg82 wrote: ↑28 Apr 2023, 08:27
your third timer starts the third timer? i.e. itself?
That's the 'old' way of having a LoopTimerSet command
dr.zorg82 wrote: ↑28 Apr 2023, 08:27
Do you also have the setting enabled : tools>Advanced Settings>Allow TaskValueSet on all plugins ?
That's
not needed for changing a Dummy Device
The Devices page is only updated every Interval seconds, taking into account the lowest Interval, of enabled tasks, that is > 0. By default the Dummy Device has an Interval of 0... and if there are no other tasks, there will be no refresh of the page, or only after 1 minute, if a default Interval of 60 seconds is active.
It might be helpful to add a SysInfo task with an Interval of 1 second to get quick updates.
Re: Dummy TaskValueSet from examples not working
Posted: 28 Apr 2023, 09:22
by dr.zorg82
Ath wrote: ↑28 Apr 2023, 08:52
That's not needed for changing a Dummy Dev
I will know thanks

Re: Dummy TaskValueSet from examples not working
Posted: 28 Apr 2023, 12:36
by thalesmaoa
Ath wrote: ↑28 Apr 2023, 08:52
That's the 'old' way of having a LoopTimerSet command
Thanks, I will look into it.
Ath wrote: ↑28 Apr 2023, 08:52
It might be helpful to add a SysInfo task with an Interval of 1 second to get quick updates.
Let me see if I get it right. You mean that I need to add a device like this one:
https://www.letscontrolit.com/wiki/index.php/SysInfo
After your tips and some more reading, I found:
Code: Select all
TaskValueSetAndRun
ScheduleTaskRun
TaskRun
TaskRunAt
I suppose that they are all related.
If I replace my code by:
Code: Select all
on Rules#Timer=3 do
if [dummy#var1]=0
TaskValueSetAndRun dummy,var1,1
else
TaskValueSetAndRun dummy,var1,0
endif
timerSet,3,2
endon
Will it work?
Re: Dummy TaskValueSet from examples not working
Posted: 28 Apr 2023, 13:03
by TD-er
Please refer to the ReadTheDocs for up-to-date documentation:
https://espeasy.readthedocs.io/en/latest/index.html
TaskValueSetAndRun is a combination of TaskValueSet and TaskRun.
A TaskRun will trigger a task to "take a sample", which is a nul-operation on a Dummy task.
But it will also send out the collected data to any connected controller of that task and generate event(s) with the task values.
By default there will be an event per task value, unless you checked the checkbox to send out a single event with all task values at once. (the event will then be named "taskname#All=123.4,567.8,...")
You should also set the initial rules timer. (e.g. at boot)
See for some examples:
https://espeasy.readthedocs.io/en/lates ... rset#timer
The old way was to set a timer and set it again when handling the timer event.
But now we also have the "looptimer" which will be much more consistent and not showing any drift.
For example when you would set the timer again when handling the timer event, it would take some time to parse the commands and also the timer event might be slightly longer in the event queue before it is being handled.
This would then cause a drift in when the next timer would be set.
The loop timer would set the next timer based on the current set time and thus show no drift.
Re: Dummy TaskValueSet from examples not working
Posted: 28 Apr 2023, 16:46
by thalesmaoa
I see great improvement from the last time I've built a ESPEasy device. I can get a small glimpse of the usage. However, it is better to share my application. From those new features, perhaps there is a better way of performing it.
I have a pump which I remotely turn on. But I want to turn it off after some time using rules.
My problem is that I use
Code: Select all
On Relay#Switch do
If (timer_not_set)
Timer set, 3, 180
Endif
Endon
My problem is that I send one event every 5 seconds. On relay#switch is called every 5s. Thus I'm using Dummy to check (timer_not_set) to not reset timer again.
Is there a better approach?
Re: Dummy TaskValueSet from examples not working
Posted: 28 Apr 2023, 19:23
by Ath
I don't see why there is a problem in resetting the 3-minute timer, if you enable the pump every 5 seconds?
Maybe you can explain why the Relay#Switch event is fired every 5 seconds, and what effect it should have on the timer or the pump?
Re: Dummy TaskValueSet from examples not working
Posted: 28 Apr 2023, 21:49
by thalesmaoa
Right! Sorry.
I have a extremely poor wifi connection. I've looked for OpenHab (MQTT plugin), but I couldn't find a way to enable QoS = 1. In order to guarantee a message delivery, I keep sending the value every 5s. Dumb workaround.
Sometimes I get, others, don't. This is why I need ESPEasy self powerdown the pump.
The problem is that every publish generates an event. This event, in turn, call my routine. I should only start timer when it latches from zero to one. To work-workaround, I was planning to use the dummy#var1.
Thinking louder, I perhaps should publish only inside rules and stop generating events. Any ideas?
Re: Dummy TaskValueSet from examples not working
Posted: 29 Apr 2023, 10:18
by TD-er
You don't need to use a Dummy, you can also store a state in a variable.
Code: Select all
On Relay#Switch do
If [int#1]=0
let,1,1
Timerset,3,180
// Maybe also set some state/pin???
Endif
Endon
on Rules#Timer=3 do
if [int#1]=1
let,1,0
// Do whatever else is needed here
endif
endon
Re: Dummy TaskValueSet from examples not working
Posted: 29 Apr 2023, 13:59
by thalesmaoa
Perfect! Thank you.