Skip to main content
1-Visitor
February 19, 2017
Solved

Auto refresh widget - turn auto refresh on without first time refresh

  • February 19, 2017
  • 7 replies
  • 6075 views

Hi All,

I have a mashup where I show the current status of the device.

In this mashup I also let the user change the status of it.

Because I want to show the user the most current status of the device I refresh the screen every 10 seconds.

The problem - if the user choose to change one of the properties and didnt save yet, the refresh will reset its choise.

The solution, every time the user click on a button it will reset the auto refresh so it start counting from the begining and only if 10 seconds passed since the last time the user click on a button it will refresh the mashup.

Is there any way to do it?

When I toggle the refresh button (Change from ON to OFF) it will immidiately trigger the refrsh and not wait to finish counting.

Best answer by qngo

To do what you want, I would need an auto refresh widget, a Validator widget, a session parameter of type DateTime and two services.

- Every time the user clicks on a button, if the auto refresh is stopped, start it. A service A is executed to set the current time to the session parameter.

- The auto refresh widget is updated every second and executes a service B. This service calculates and returns the different of time between the current time and the one set to the session parameter by the service A.

- The ouput (different of time, in second) of the service B is bound to an input of the Validator widget. This widget verifies if the different of time is more than 10 seconds. If true, the Validator executes the service to refresh the mashup and stop the auto refresh.

7 replies

5-Regular Member
February 19, 2017

Is the status of the device a property? If so, as of TWX 7.1 (if I remember correctly) you can use websockets to update the property value instead of the refresh widget. Use the service GetProperties on the Thing or the Dynamic ThingTemplate/ThingShape and select the service in the mashup. On the bottom right, select the check mark for "automatically update properties when able"

autoupdate.png

Now, when the user changes the property, it should not refresh the property before the update is complete.

aelgov1-VisitorAuthor
1-Visitor
February 19, 2017

Thanks, it is not a property

5-Regular Member
February 19, 2017

How are you storing the current status? Is this something like a service that returns a status from a remote system? How is this status being updated?

qngo1-VisitorAnswer
1-Visitor
February 20, 2017

To do what you want, I would need an auto refresh widget, a Validator widget, a session parameter of type DateTime and two services.

- Every time the user clicks on a button, if the auto refresh is stopped, start it. A service A is executed to set the current time to the session parameter.

- The auto refresh widget is updated every second and executes a service B. This service calculates and returns the different of time between the current time and the one set to the session parameter by the service A.

- The ouput (different of time, in second) of the service B is bound to an input of the Validator widget. This widget verifies if the different of time is more than 10 seconds. If true, the Validator executes the service to refresh the mashup and stop the auto refresh.