Page 1 of 1
Analog/Dummy min interval
Posted: 10 Jan 2022, 09:56
by Koivutie7
Hi, I have a rule that sends data to the relay card according to the potentiometer, the problem is that I don't get the mini interval set to 0, so send the data to the relay card even though the situation hasn't changed. I tried to put a dummy device, but here is the same problem, the min interval is not allowed to zero.
Now it's kind of useless to send data ...
Can this be fixed in any way?
Re: Analog/Dummy min interval
Posted: 10 Jan 2022, 10:24
by Ath
The simple solution would be to disconnect the task from the controller (unchecking that checkbox), and add an event for sending out the data.
Code: Select all
on Analog#value do
// Send out the data, as it has changed
endon
I guess there are more plugins that could do without the minimal interval. Could do with some discussion, but currently the internal setting for this is called "TimerOptional", and the default value is "false". I don't think that default should change, but, as said, some plugins could have that option changed to "true".
Candidates:
- Analog
- Dummy
Re: Analog/Dummy min interval
Posted: 10 Jan 2022, 10:31
by Koivutie7
That's how I have it, but if the interval is 10s. It sends a value every 10s ...
on Analog#Value do
taskvalueset,2,1,[Analog#value]
endif
endon
on Dummy#value do
if [Dummy#value]>1019
SendToHTTP 192.168.4.11,80,/control?cmd=event%2C0001
else
if [Dummy#value]>980 and [Dummy#value]<1019
SendToHTTP 192.168.4.11,80,/control?cmd=event%2C0002
endif
endon
And the situation doesn’t change because the dummy device does the same
Re: Analog/Dummy min interval
Posted: 10 Jan 2022, 10:51
by Ath
You can check the analog value against the stored value in the dummy task, and only send if it has changed
Code: Select all
on Analog#Value do
if %eventvalue1% <> [Dummy#value]
taskvalueset,Dummy,value,[Analog#value]
if %eventvalue1%>1019
SendToHTTP 192.168.4.11,80,/control?cmd=event,0001
else
if %eventvalue1%>980
SendToHTTP 192.168.4.11,80,/control?cmd=event,0002
endif
endif
endif
endon
(Please use [ code ] and [ /code ] tags around your code for readability, it's hiding behind the "</>" button in the toolbar)
Re: Analog/Dummy min interval
Posted: 10 Jan 2022, 13:35
by Koivutie7
Now got to work as desired, no more code to clean up ,,, thanks
on Analog#value do
if %eventvalue1% <> [Dummy#value]
taskvalueset,2,1,[Analog#value]
if %eventvalue1%>944
SendToHTTP 192.168.4.11,80,/control?cmd=event%2c0001
else
if %eventvalue1%>864 and %eventvalue1%<944
SendToHTTP 192.168.4.11,80,/control?cmd=event%2c0002
else
if %eventvalue1%>784 and %eventvalue1%<864
SendToHTTP 192.168.4.11,80,/control?cmd=event%2c0003
endif
else
if %eventvalue1%>704 and %eventvalue1%<784
SendToHTTP 192.168.4.11,80,/control?cmd=event%2c0004
endif
else
if %eventvalue1%<704
SendToHTTP 192.168.4.11,80,/control?cmd=event%2c0005
endif
endif
endif
endon
On ledon do
LongPulse,13,1,4
endif
endon
Re: Analog/Dummy min interval
Posted: 10 Jan 2022, 14:02
by Ath
Koivutie7 wrote: ↑10 Jan 2022, 13:35
Code: Select all
if %eventvalue1%>944
SendToHTTP 192.168.4.11,80,/control?cmd=event%2c0001
else
if %eventvalue1%>864 // -->> No need to check second condition, it will slow down the processing of rules and always be true if it gets here // and %eventvalue1%<944
SendToHTTP 192.168.4.11,80,/control?cmd=event%2c0002
else
if %eventvalue1%>784 // and %eventvalue1%<864
See note, don't execute code that doesn't add anything useful, will only slow down processing, the first 'if' guarantees the second condition will always be true, that's why I already removed it in my previous example
Re: Analog/Dummy min interval
Posted: 10 Jan 2022, 16:47
by Ath
And even the "else if" statements can be collapsed into "elseif" to eliminate a couple of "endif"s
So, on recap:
Code: Select all
on Analog#value do
if %eventvalue1% <> [Dummy#value]
taskvalueset,Dummy,value,%eventvalue1%
if %eventvalue1%>944
SendToHTTP 192.168.4.11,80,/control?cmd=event%2c0001
elseif %eventvalue1%>864
SendToHTTP 192.168.4.11,80,/control?cmd=event%2c0002
elseif %eventvalue1%>784
SendToHTTP 192.168.4.11,80,/control?cmd=event%2c0003
elseif %eventvalue1%>704
SendToHTTP 192.168.4.11,80,/control?cmd=event%2c0004
else
SendToHTTP 192.168.4.11,80,/control?cmd=event%2c0005
endif
endif
endon
On ledon do
LongPulse,13,1,4
endon