Analog/Dummy min interval

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Koivutie7
Normal user
Posts: 11
Joined: 10 Jan 2022, 09:41

Analog/Dummy min interval

#1 Post by Koivutie7 » 10 Jan 2022, 09:56

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?

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Analog/Dummy min interval

#2 Post by Ath » 10 Jan 2022, 10:24

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
/Ton (PayPal.me)

Koivutie7
Normal user
Posts: 11
Joined: 10 Jan 2022, 09:41

Re: Analog/Dummy min interval

#3 Post by Koivutie7 » 10 Jan 2022, 10:31

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

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Analog/Dummy min interval

#4 Post by Ath » 10 Jan 2022, 10:51

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)
/Ton (PayPal.me)

Koivutie7
Normal user
Posts: 11
Joined: 10 Jan 2022, 09:41

Re: Analog/Dummy min interval

#5 Post by Koivutie7 » 10 Jan 2022, 13:35

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

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Analog/Dummy min interval

#6 Post by Ath » 10 Jan 2022, 14:02

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
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Analog/Dummy min interval

#7 Post by Ath » 10 Jan 2022, 16:47

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
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 24 guests