Disable rule when another rule has been executed

Hi all,

I have 2 rules for mu Hue lights:

  1. a rule that resets the color and intensity when state changes from OFF to ON (normal operations)
  2. a rule that sets the lights to a specific scene (colorfull party mode :slight_smile: )

But now when I call rule 2, rule 1 immediatly resets the pary mode tot the default settings. After that I need to run the party mode again, to keep the colors (at that point the state doesn’t change).

How can I make sure that rule 1 doesn’t kick in when rule 2 is called when the lights are off?

Hi,
how do you trigger rule 2? With an item?
If yes then add to your first rule as a condition (“but only if”) your party mode item is OFF. So when your item state changes to ON, but the party mode item is ON too, then the rule 1 won’t get fired.

Hi,

I trigger the rule by tapping a button on the home screen.
This is the code of that ‘button’.

                          - component: oh-list-item
                            config:
                              action: rule
                              actionRule: e7a0c59957
                              icon: oh:colorlight
                              title: Kleurrijk

I would try to solve this problem with an additional Item. Add a switch Item eg “party mode”.

Rules like this:
Rule 1: When Hue state changes = send command depending on state. If item is OFF send ON, if item is ON send OFF. BUT only if “party mode” = OFF.

Rule 2: When item “party mode” changes to ON = send command COLOR to HUE. When item “party mode” changes to OFF = send command OFF to HUE.

Thanks for that. You put me on the right trail…
Next challenge…

Next tot colorfull, I also have a rule ‘movienight’. I want to implement your solution as well.
But there is an overlap in lights for partymode and movienight.
So, Rule 1 would have 2 exceptions, but only if partymode is off OR movienight is OFF.

But it seems the ‘but only if’ is always an AND operator?

conditions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: colorfull
      state: OFF
      operator: =
    type: core.ItemStateCondition
  - inputs: {}
    id: "4"
    configuration:
      itemName: movienight
      state: OFF
      operator: =
    type: core.ItemStateCondition

Yes, if you add it with the rule editor it is an AND operator.
But you can do it with blockly.

Something ike this:

I now have this script:

if (itemRegistry.getItem('colorfull').getState() == 'OFF' || itemRegistry.getItem('movienight').getState() == 'ÒFF') {
}

But it’s not working. shouldn’t there be anything between the { }?

Yes, you need to add what should happen. For now you only set the condition. Now add an event.
Something like this:

Just to be clear here because I’m not sure it’s apparent.

The if statement @dirkdirk shows would need to be inside the Script Action.

If you want to set it as a Script Condition, you need to skip the if part. The last line executed by the Script Condition (Blockly or any other language) needs to evaluate to a boolean (i.e. true or false).

itemRegistry.getItem('colorfull').getState() == 'OFF' || itemRegistry.getItem('movienight').getState() == 'OFF')

Assuming you are using ECMAScript 5.1 that could be simplified to:

items['colorful'] == OFF || items['movienight'] == OFF

NOTE: 'OFF' is not the same as 'ÒFF'