Refreshing conditional settings

I have an issue with my Conditional Controller: when I analyse the logs, I have some times unexpected “Refreshing conditional settings” which relaunch the class object and so run again the class init method, which is catastrophic.

Any idea please what could happen ?

You are pressing “Save” for that Conditional Controller. There is no other way to use the new settings without restarting the controller thread with the new settings you just saved.

I disabled the controller, changed the code, then pressed “Save”, and finally enable the controller again. Is there something else to do?

If the controller is deactivated, the system can’t “relaunch the class object” because it doesn’t exist. Can you better explain your issue?

Sure, I have a conditional controllers with states as self.loop_count in your example, in particular a counter for watering. When I enable the controller, it loops on this counter.

But for unknown reason, the init method of the class is runned again in the middle of the execution of the run method.

Here are an extract from my cusomized logs:

2023-08-11 15:28:39,095 - INFO - mycodo.controllers.controller_conditional_5c2007ba - mesCuveArrosNivBas "7b60d44e" = 0.0
2023-08-11 15:28:42,143 - INFO - mycodo.controllers.controller_conditional_5c2007ba - EtatPomMélange "2397b35d" = off
2023-08-11 15:28:46,461 - INFO - mycodo.controllers.controller_conditional_5c2007ba - Ferme EV Arrosage "804b4820"
2023-08-11 15:28:48,709 - INFO - mycodo.controllers.controller_conditional_5c2007ba - Ouvre EV Pompe de relevage "a8384a45"
2023-08-11 15:28:51,747 - INFO - mycodo.controllers.controller_conditional_5c2007ba - Refreshing conditional settings
2023-08-11 15:28:52,085 - INFO - mycodo.controllers.controller_conditional_5c2007ba - Initialise loop_count à 0
2023-08-11 15:28:55,235 - INFO - mycodo.controllers.controller_conditional_5c2007ba - Initialise les variables state, qt-arrosage, derniers, courriel, echeance, fait
2023-08-11 15:28:55,236 - INFO - mycodo.controllers.controller_conditional_5c2007ba - Arrosage x2 - Etat = {'init'}
2023-08-11 15:28:55,679 - INFO - mycodo.controllers.controller_conditional_5c2007ba - Allume 12V "09fae106"
2023-08-11 15:28:56,567 - INFO - mycodo.controllers.controller_conditional_5c2007ba - Mélange péristaltique "3b6b1a87"
2023-08-11 15:28:57,548 - INFO - mycodo.controllers.controller_conditional_5c2007ba - Ferme EV Pompe Relevage "56367b47"
2023-08-11 15:28:59,050 - INFO - mycodo.controllers.controller_conditional_5c2007ba - Ferme EV Arrosage "804b4820"
2023-08-11 15:29:09,110 - INFO - mycodo.controllers.controller_conditional_5c2007ba - Changement d'état : {'init'} --> {'debut cycle'}
2023-08-11 15:29:10,121 - INFO - mycodo.controllers.controller_conditional_5c2007ba - **** ARROSAGE NO 2 **** REEL ****************
2023-08-11 15:29:10,522 - INFO - mycodo.controllers.controller_conditional_5c2007ba - Ouvre EV Admission "e572750c"

At 2023-08-11 15:28:51,747, there is the - INFO - mycodo.controllers.controller_conditional_5c2007ba - Refreshing conditional settings

Does this occur with the default example code when you create a controller? If not, this is something occuring because of the code you’re using.

Sure, but it looks very tricky. I have loaded the last 100,000 lines of log ang grep -i -C 4 refreshing logfile to figure out where it happens, but actually it happens any time, there is no pattern.

Do you have an idea what kind of misuse of Mycodo could lead to this behaviour?

The code only permits it to happen when “Save” is pressed, so I wouldn’t be able to tell you how it could happen otherwise, because it shouldn’t.

I have doubled checked my UUIDs and found two errors. I hope it is that.

That wouldn’t cause the behavior. The only thing in the code that calls a conditional refresh is pressing “Save” while it’s running. You may just not remember pressing save, but you can see that if you press save, you’ll see that log line appear.