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?
Analog/Dummy min interval
Moderators: grovkillen, Stuntteam, TD-er
Re: Analog/Dummy min interval
The simple solution would be to disconnect the task from the controller (unchecking that checkbox), and add an event for sending out the data.
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
Code: Select all
on Analog#value do
// Send out the data, as it has changed
endon
Candidates:
- Analog
- Dummy
/Ton (PayPal.me)
Re: Analog/Dummy min interval
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
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
You can check the analog value against the stored value in the dummy task, and only send if it has changed
(Please use [ code ] and [ /code ] tags around your code for readability, it's hiding behind the "</>" button in the toolbar)
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
/Ton (PayPal.me)
Re: Analog/Dummy min interval
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
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
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 exampleKoivutie7 wrote: ↑10 Jan 2022, 13:35Code: 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
/Ton (PayPal.me)
Re: Analog/Dummy min interval
And even the "else if" statements can be collapsed into "elseif" to eliminate a couple of "endif"s
So, on recap:
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
/Ton (PayPal.me)
Who is online
Users browsing this forum: No registered users and 0 guests