If anyone is interested, I will copy/paste my code here for my solution. It builds on the initial "Reactor Ex Machina" from 2021 but incorporates the changes made to MSR since then. I also modified it in such a way to have the OFF switching done individually for each light with definable delays. A bathroom light that way can go OFF after a random 1-5m while the kitchen stays on for longer for example. I made some other changes as well to suit my needs. It works for me, it might not for you.
You need four "Global Expressions":
- REM_lights
#list of all DeusExMachina (now ReactorExMachina REM) lights to control
#this is an array [ ]
#every entity in ' ' (apostrophes) separated by , (comma) in new line
#check entity list to get canonical ID to be used
#comments start with hash and are ignored
[
'hass>input_boolean_testlight', #Test
'hass>input_boolean_testlight2', #test2
'hass>input_boolean_testlight3', #Stephan
'hass>input_boolean_testlight4', #Stephan
'hass>input_boolean_testlight5', #Stephan
'hass>input_boolean_testlight5', #Stephan
'hass>input_boolean_testlight5' #Stephan
]
-
REM_dummy (leave empty)
-
REM_cycler_stimulus (leave empty)
-
REM_status (leave empty)
If you want a light to be more frequently "ghosted" add it multiple times into the list. In my case light5. If you are on HA, you can add via the helper section some virtual toggles as I did to test your setup. Probably also possible on other platforms.
Start & Stop rule (via set/reset reaction), the ghost switching on the lights and then for each light a ghost which switches off so I can manage the individual behavior per light.
The reset code bit, hard to read/copy from screenshot:
${{ each light in REM_lights: performAction( light, 'power_switch.off', {} ); 0 }}
The ghost for switching ON a random element/light from the list:
Code:
${{ performAction( REM_lights[ floor( random() * len( REM_lights ) ) ], 'toggle.toggle', {} ) }}
${{ random()*600 + 600 }}
${{ REM_cycler_stimulus + 1 }}
${{ random()*600 + 300 }}
Some explanation for random function and the values used with it. It randomly generates number between 0 and 1 (example: 0.4739302) The delay time is in seconds. So the above example will create a delay of 300s minimum plus anything between 0 to 10m, effectively a random time of 5m-15m. See what works for you.
This REM is working well for me and I am now finally ready to migrate it all to HA after many years on my trusty Vera Lite which is about to die of flash memory degradation.