Hello @Spaceman_Spiff, several post above, you wrote that it is possible to load / unload rules via posting particular events on the bus. I am really interested in this, but I cannot get it working. I would expect, that posting RequestFileUnloadEvent will unload the rule and RequestFileLoadEvent will load the rule. But both of them are ending in the rule reloading. My code is very simple:
event = RequestFileUnloadEvent("rules/operator_vents.py")
self.post_event("HABApp.Files", event)
and the output in the HABApp log (DEBUG severity):
[2024-05-10 11:54:24,811] [ HABApp.file.events] DEBUG | FileOpenedEvent(src_path='/habapp/config/rules/operator_vents.py', dest_path='', event_type='opened', is_directory=False, is_synthetic=False)
[2024-05-10 11:54:24,812] [ HABApp.files] DEBUG | rules/operator_vents.py added
[2024-05-10 11:54:25,102] [ HABApp.files] DEBUG | rules/operator_vents.py changed to DEPENDENCIES_OK
[2024-05-10 11:54:25,103] [ HABApp.Rules] DEBUG | Removing file: rules/operator_vents.py
[2024-05-10 11:54:25,108] [ HABApp] DEBUG | Removed event listener for "control/fans/set" (filter=ValueChangeEventFilter())
[2024-05-10 11:54:25,109] [ HABApp] DEBUG | Removed event listener for "control/fanexhaust/set" (filter=ValueChangeEventFilter())
[2024-05-10 11:54:25,109] [ HABApp] DEBUG | Removed event listener for "control/fanintake/set" (filter=ValueChangeEventFilter())
[2024-05-10 11:54:25,109] [ HABApp.Rules] DEBUG | File rules/operator_vents.py successfully unloaded!
[2024-05-10 11:54:25,112] [ HABApp.Rules] DEBUG | Loading file: rules/operator_vents.py
[2024-05-10 11:54:25,114] [ HABApp.file.events] DEBUG | FileOpenedEvent(src_path='/habapp/config/rules/operator_vents.py', dest_path='', event_type='opened', is_directory=False, is_synthetic=False)
[2024-05-10 11:54:25,117] [ HABApp.file.events] DEBUG | FileOpenedEvent(src_path='/habapp/config/rules/operator_vents.py', dest_path='', event_type='opened', is_directory=False, is_synthetic=False)
[2024-05-10 11:54:25,118] [ HABApp.file.events] DEBUG | FileOpenedEvent(src_path='/habapp/config/rules/operator_vents.py', dest_path='', event_type='opened', is_directory=False, is_synthetic=False)
[2024-05-10 11:54:25,127] [ HABApp] DEBUG | Added event listener for "control/fanintake/set" (filter=ValueChangeEventFilter())
[2024-05-10 11:54:25,128] [ HABApp] DEBUG | Added event listener for "control/fanexhaust/set" (filter=ValueChangeEventFilter())
[2024-05-10 11:54:25,129] [ HABApp] DEBUG | Added event listener for "control/fans/set" (filter=ValueChangeEventFilter())
[2024-05-10 11:54:25,129] [ HABApp.Rules] INFO | Added rule "OperatorVentsRule" from rules/operator_vents.py
[2024-05-10 11:54:25,131] [ HABApp.Rules] DEBUG | File rules/operator_vents.py successfully loaded!
[2024-05-10 11:54:25,132] [ HABApp.files] DEBUG | rules/operator_vents.py changed to LOADED
[2024-05-10 11:54:40,574] [ HABApp.files] DEBUG | Worker done!
Any advice how to dynamicly disable / enable rules?