User chooses a refresh interval

0
I have a dropdown that has different time intervals ranging from 5 seconds to 2 hours, and when the user selects a time, the page or entities(not sure if there is an option for this) will refresh every time that interval is hit...lets say they select 5 seconds, every 5 secs it will refresh until they change it or go to a different page. Also not sure if it matters to use an enumeration input dropdown or a drop-down button where you create the options in the button properties. A microflow timer doesn’t as it has to have a preset interval unless you can change that somehow.
asked
2 answers
0

You still can do that in the microflow timer. In the microflow retrieve an entity that holds the latest refresh time and the interval enumeration. Based on those two values calculate the next refresh time and compare it with the actual time. If it is not the time yet just quit otherwise refresh the object. Do note that with 5 seconds interval I would use nanoflows because they run client side. Otherwise this setup will probably create problems for your server.

Regards,

Ronald

 

answered
0

The Microflow Timer widget has an optional integer attribute property that you can use to set the interval. So, you should be able to use an on-change nanoflow on the dropdown to set an integer to the appropriate interval value in milliseconds, and then use that same attribute in the widget.

 

UPDATE:

There was a bug in the MicroflowTImer widget that caused it not to work as expected. I’ve submitted changes to be merged and released on the app store. Until then, here is an updated widget file to be dropped in your project’s /widget/ directory.

Also, I made a working demo project that shows you show to use a dropdown to control the interval. You should be able to open this project archive by double-clicking.

answered