This object is in archive! 

Exact function of Refresh All puzzle piece

David Pritchard shared this question 8 years ago
Need Answer

Could somebody explain in detail what the "Refresh all" piece does?


The only explanation I can find here is that it "refreshes the state of all used sensors/switches".


What does that mean? Why would the state need to be refreshed? What is updating what? Is there a sort of queue of pending state changes that "Refresh all" flushes?

Best Answer
photo

Here is the answer I received on a ticket about "Refresh All":

Refresh all will use the new state of the Device used in a Rule. If for example at the beginning of the Rule a

motion sensor had a "motion" state and you used a "wait" puzzle in your Rule and after that "Refresh all",

if the motion sensor later changed its state to "no motion" this is the state that you will get (that will be used)

in your Rule. If you do not use "refresh all" then the state of your Sensor will always be as it was at the

beginning of your Rule in this case "motion".

Enjoy your day.

Best regards,

Hrvoje

Replies (6)

photo
2

I have a follow-up question that I think is closely related. I am sorry if it interrupts your thread..

How long will an event "live" inside a rule. If I have the following rule

WHEN motionsensor.ANY

WAIT 20 seconds

IF motionsensor.MOTION THEN do_something

How long will the if statement be true?

Util I call REFRESH_ALL?


(my motion sensor is configured with a 10 sec delay before it reports NOMOTION)

photo
2

Here is the answer I received on a ticket about "Refresh All":

Refresh all will use the new state of the Device used in a Rule. If for example at the beginning of the Rule a

motion sensor had a "motion" state and you used a "wait" puzzle in your Rule and after that "Refresh all",

if the motion sensor later changed its state to "no motion" this is the state that you will get (that will be used)

in your Rule. If you do not use "refresh all" then the state of your Sensor will always be as it was at the

beginning of your Rule in this case "motion".

Enjoy your day.

Best regards,

Hrvoje

photo
1

Thanks, Henry. This is how I thought it was working, good to get it confirmed.

photo
1

Ok, excellent. So Refresh All would have no effect at all on virtual switches? Or might it have an effect if another rule running in parallel changes the value of the virtual switch during the execution of the rule? Does each rule in effect receive a copy of the states of the virtual switches as they were when the rule started execution?

photo
1

"Refresh All" will only have effect inside a rule to pick upp and use changed data that a test is depending on. Otherwise the routine will use the same old values inside the routine even when they are changed.

photo
1

David, I am just guessing, but if I were to program this rule engine, I would only copy the states of the devices used in that particular rule. Otherwise it would be a waste of memory (and not too elegant :) )


About the virtual sensor update: I think your assumption is right, that if a rule in parallel updates the virtual sensor, you would be able to get the fresh sensor state with a REFRESH_ALL. Without it, you would operate on the old state.

Leave a Comment
 
Attach a file