Advice needed: Prevent Sending Event Values at Interval Time

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Advice needed: Prevent Sending Event Values at Interval Time

#1 Post by ThomasB » 16 Jul 2018, 18:19

I'm working on a device plugin that has both standard Values and CustomTasks. During the Interval timer both Values and CustomTask events are processed/sent as expected. However, some users only want the Values sent during the initial trigger, but not at the timer interval. Instead, only the CustomTasks would be processed at the interval.

I searched existing device plugins for an example but it appears this is a unique requirement. Is it possible to do this in the plugin without any changes to other ESPeasy modules?

- Thomas

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Advice needed: Prevent Sending Event Values at Interval Time

#2 Post by grovkillen » 16 Jul 2018, 19:08

I'd say they should use rules for that.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Advice needed: Prevent Sending Event Values at Interval Time

#3 Post by TD-er » 18 Jul 2018, 22:03

Yep, do not connect a controller to that plugin, but use the rules to fetch the values and send them when needed.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Advice needed: Prevent Sending Event Values at Interval Time

#4 Post by ThomasB » 20 Jul 2018, 23:49

Thanks for the advice. I prefer using rules too, which is how I handle it. But suggesting this has not been received with much love.

I believe I have a solution for the customized plugin. Just waiting for user feedback.

I've added a test in PLUGIN_READ that checks the UserVar values. If they have not changed then they are ignored and not sent during the timer interval. Fingers are crossed that the feedback is overflowing with love.

- Thomas

TD-er
Core team member
Posts: 8644
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Advice needed: Prevent Sending Event Values at Interval Time

#5 Post by TD-er » 21 Jul 2018, 02:03

I just finished (Pull request is ready) moving the sensor timers to the new scheduler.
This allows a plugin to set its own schedule if you like.
By default the set delay is being used, but you could set a new one from within the plugin code itself.
This allows to set the delay to some near infinite value ("0") and the plugin may set a new value to make the scheduler handle the "PLUGIN_READ" as soon as there is something changed.

Just call

Code: Select all

schedule_task_device_timer(task_index, runAt);
"runAt" can be set to "millis()" or maybe "millis() + 10" to allow for some delay of 10 msec from now.
Task_index is set in the event and it represent the task (plugin) number in the list (note offset of 1)

This allows plugins to react much more responsive.
It also means the real work has to be done in the calls to 50/sec and 10/sec calls (or 1/sec).
And please do as little as absolutely needed in those time-critical calls, to help not to block the system.

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Advice needed: Prevent Sending Event Values at Interval Time

#6 Post by ThomasB » 21 Jul 2018, 02:36

@TD-er:
Brilliant. Thank you for the new functionality.

- Thomas

chunter1
Normal user
Posts: 82
Joined: 22 Jan 2016, 22:40

Re: Advice needed: Prevent Sending Event Values at Interval Time

#7 Post by chunter1 » 09 Nov 2018, 00:23

As far as i have seen, this functionality now needs "TimerOption = true" to work. (which i want to avoid)
Is there another way to get "PLUGIN_READ" triggered from inside a plugin?

Post Reply

Who is online

Users browsing this forum: No registered users and 41 guests