Enable / Disable Rules (SOLVED)

I have managed to transfer nearly all rules from paperUI rule engine to text based rules.

i have been stuck thinking about how to do the last few some input would be appretiated i just cant think about how to get this one working in the slightest

should i make multiple rules and use triggers ? should it be condensed into one rule that is worded better

when i created these rules i used the disable and enable rules option this is not available when using text rules thats where im stuck

my Leaving home routine is one of these rules its split into two parts part one runs from the button press and part two is enabled by part 1 after its run.

Shortened KARAF LOG BELOW


                                                //PART 1
12:53:03.214 [INFO ] [marthome.event.ItemStateChangedEvent] - Leaving_Home_Trigger changed from OFF to ON //HABPANNEL SWITCH
12:53:03.214 [INFO ] [marthome.event.ItemStateChangedEvent] - KodiHTPC2_Stop changed from OFF to ON //SEND STOP TO KODI
12:53:03.508 [INFO ] [marthome.event.ItemStateChangedEvent] - KodiHTPC2_SendSystemCommand changed from UNDEF to SHUTDOWN //SEND SHUTDOWN TO KODI
                                                //PART2
12:53:51.411 [INFO ] [marthome.event.ItemStateChangedEvent] - HTPC2_Online_Status changed from ON to OFF //WHEN OFFLINE 
12:53:51.414 [INFO ] [marthome.event.ItemStateChangedEvent] - Plug3_Switch changed from ON to OFF // TURN OFF ALL BELOW
12:53:51.450 [INFO ] [marthome.event.ItemStateChangedEvent] - Plug2_Switch changed from ON to OFF // OFF
12:53:56.488 [INFO ] [marthome.event.ItemStateChangedEvent] - Lamp1_Brightness changed from 94 to 0 //OFF
12:53:56.503 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'Lamp1_Brightness' received command OFF //OFF
12:53:56.509 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'BULB6LRMAIN1_Color' received command 64,3,0 //OFF
12:53:56.509 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'Bed_Trigger' received command OFF //TURN OFF TRIGGERS
12:53:56.509 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'Leaving_Home_Trigger' received command OFF //TURN OFF TRIGGERS
12:53:56.509 [INFO ] [marthome.event.ItemStateChangedEvent] - Leaving_Home_Trigger changed from ON to OFF //END RULE
12:53:56.509 [INFO ] [smarthome.event.RuleStatusInfoEvent ] - rule_2 updated: DISABLED

Use a virtual switch to enable/disable a rule?

1 Like

thats what i was thinking myself i have done that for a couple of rules already i was just wondering if thats the best solution


rule "Leaving Home Routine"
when
Item Leaving_Home_Trigger changed from OFF to ON
then
KodiHTPC2_Stop.sendCommand("ON")
KodiHTPC2_SendSystemCommand.sendCommand("SHUTDOWN")
Trigger_PowerOffLR.sendCommand("ON")
logInfo("Rule", " Leaving Home Routine Ran (Routines.rules)")
end

rule "Power OFF LR Routine"
when
Item HTPC2_Online_Status changed from ON to OFF
then
if (Trigger_PowerOffLR.state == ON) {
    Plug3_Switch.sendCommand("OFF")
    Plug2_Switch.sendCommand("OFF")
    Lamp1_Brightness.sendCommand("0")
    BULB6LRMAIN1_Color.sendCommand("64,3,0")
    Bed_Trigger.sendCommand("OFF")
    Leaving_Home_Trigger.sendCommand("OFF")
    Trigger_PowerOffLR.sendCommand("OFF")
    logInfo("Rule", " Power OFF LR Routine Ran (Routines.rules)")
}
end

the reason i had trouble with this rule was it kept turning stuff off when htpc went to sleep this was not what i wanted to happen i only want it to run when called by the button press

thanks i should have just done that in the first place was stressing for nothing lol

1 Like