Help with status update rule

I go with you in the postings above, however the last one I can’t agree with.
Consider two states are ON and one is switched to OFF, what shall the StatusCommand be?

Looking at the rule you sent it would no longer check to see if other items are on and would still get changed if an item changed eg moviemode could be changed by anything other than testmode when movie mode is more important than weekend, disable amp, schoolholiday ect…

@opus I can see the rule starting too come together it just doesn’t seem to check if other items are on maby I’m wrong

Which one?

@vzorglub

rule "System Status"   
when
    Member of gStatus changed
then
    if(gStatus.state == OFF) {
        System_Status.sendCommand ("NORMAL") 
        return;
    }

    if(Test_Mode.state == ON  {
        System_Status.sendCommand ("TEST MODE")
        return;
    }

    var String statusCommand = ""
 
    if( Away_from_home.state == ON  ) {
        statusCommand = "AWAY FROM HOME"
    }

    if( In_Bed.state == ON ) {
        statusCommand = "BEDTIME"
    }

    if( Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == ON && Weekend.state == ON) {
        statusCommand = "SCHOOL HOLIDAY"
    }

    if( Weekend.state == ON ) {
        statusCommand = "WEEKEND"
    }

    if( Movie_Mode_Enabled.state == ON ) {
        statusCommand = "MOVIE MODE"
        }
    }

    if( Disable_Amp_Rule.state == ON ) {
        statusCommand = "AMP RULE DISABLED"
        }
    }

    if( Trigger_Tylers_TV.state == ON ) {
        statusCommand = "KIDS SLEEP"
        }
    }

    if( Trigger_PowerOffLR.state == ON ) {
        statusCommand = "LR POWER OFF"
        }
    }
    System_Status.sendCommand(statusCommand)
end

In my version away from home was more important than the weekend and holiday mode

if( Away_from_home.state == ON  ) { // ITEM CHANGED TO DISPLAY
        if( Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == ON || Weekend.state == ON ) { //IF ANY OF THESE ARE ON SET TO ON AT THE SAME TIME DISPALY TO TEST MODE AS THESE ITEMS ARE LESS IMORTANT
            System_Status.sendCommand ("AWAY FROM HOME")                            //
        }                                                                           // SAME THEORY FOR ALL RULES BELOW
    }

Right OK, Sorry I misread.

So ignore my post before last. I’ll delete that.

Here you go:

rule "System Status"   
when
    Member of gStatus changed
then
    if(gStatus.state == OFF) {
        System_Status.sendCommand ("NORMAL") 
        return;
    }

    if(Test_Mode.state == ON  {
        System_Status.sendCommand ("TEST MODE")
        return;
    }

    var String statusCommand = ""
 
    if( Away_from_home.state == ON  ) { // ITEM CHANGED TO DISPLAY
        if( Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == ON || Weekend.state == ON ) { //IF ANY OF THESE ARE ON SET TO ON AT THE SAME TIME DISPALY TO TEST MODE AS THESE ITEMS ARE LESS IMORTANT
            statusCommand = "AWAY FROM HOME"
        }                                                                           // SAME THEORY FOR ALL RULES BELOW
    }
    if( In_Bed.state == ON ) {
        if( Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == ON || Weekend.state == ON ) {
            statusCommand = "BEDTIME"
        }
    }
    if( Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == ON && Weekend.state == ON) {
        statusCommand = "SCHOOL HOLIDAY"
    }
    if( Weekend.state == ON ) {
        statusCommand = "WEEKEND"
    }
    if( Movie_Mode_Enabled.state == ON ) {
        if( Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == ON || Weekend.state == ON || Disable_Amp_Rule.state == ON ) {
            statusCommand = "MOVIE MODE"
        }
    }
    if( Disable_Amp_Rule.state == ON ) {
        if( Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == ON || Weekend.state == ON  ) {
            statusCommand = "AMP RULE DISABLED"
        }
    }
    if( Trigger_Tylers_TV.state == ON ) {
        if( Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == ON || Weekend.state == ON || Movie_Mode_Enabled.state == ON || Disable_Amp_Rule.state == ON ) {
            statusCommand = "KIDS SLEEP"
        }
    }
    if( Trigger_PowerOffLR.state == ON ) {
        if( Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == ON || Weekend.state == ON ) {
            statusCommand = "LR POWER OFF"
        }
    }
    System_Status.sendCommand(statusCommand)
end
1 Like

The questions is WHAT do you want to display when two or more states are on. We understood it for the Test mode (Show: Test Mode in any case), but what about the others?

1 Like

@opus
If you look at my rule in the first post it checks for each item changing and then lists other items that might be on at the same time just below where it checked what item was on the thing to display is just below that eg

if( Away_from_home.state == ON  ) { // ITEM CHANGED TO DISPLAY
        if( Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == ON || Weekend.state == ON ) { //IF ANY OF THESE ARE ON SET TO ON AT THE SAME TIME DISPALY TO TEST MODE AS THESE ITEMS ARE LESS IMORTANT
            System_Status.sendCommand ("AWAY FROM HOME")                            //
        }                                                                           // SAME THEORY FOR ALL RULES BELOW
    }

If away from home is on and kids Holiday or
Weekend is on then the thing to display is away from home

Another eg

if( Trigger_Tylers_TV.state == ON ) {
        if( Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == ON || Weekend.state == ON || Movie_Mode_Enabled.state == ON || Disable_Amp_Rule.state == ON ) {
            System_Status.sendCommand ("KIDS SLEEP")
        }
    }

If tylers tv on and anything below that is on send kids sleep

@vzorglub thanks for that it’s looking about right now I will try soon I’m using a mobile atm if that works I will easily be able too add more items too display in the future as this is for a main status pannel

Still don’t really understand what you want to achieve but if it clear for you that’s good enough.
I hope that rule works for you. Saved a few lines on code

Lets take the first one, you want to Display “AWAY FROM HOME” only when Kids_Holiday or Weekend or Movie_Mode or Disable_Amp is ON?

I want to dispaly away from home when away from home is on and nothing else is on

And also display away from home even if kids Holiday weekend or movie mode or disable amp are on or if they change to on while away from home is on

That makes no sense, sorry

Away from home could change to on at any time and it might not be a weekend or kids might not b on holiday so it needs to say away from home

But away from home could also change to on when it’s a weekend or the kids are not at school and then I want it to say away from home not weekend or kids Holiday

So Away from home prevails over any other condition.
Then

    if( Away_from_home.state == ON  ) { // ITEM CHANGED TO DISPLAY
        System_Status.sendCommand("AWAY FROM HOME")
        return;
    }

Exactly but not all items

Away from home prevails over kids Holiday and weekend

The other eg was the same tylers tv prevails over kids Holiday, weekend, movie mode, disable amp but still needs to say it if none of the others are on

Ok so as in post 1 or my last posted rule. Conditions haven’t changed.

You check for away from home and inside that you check for weekend=ON and set status for away from home
Then further down you check for weekend and set status for weekend
You need to re-order the conditions from the least important to the most important
So that the most important gets checked last and that’s the status returned

No nothings changed
certain items prevail other others,
I just couldent get my version working as I expected.

The errors in the code were from changes I did trying to fix the rule myself I just posted the rule for reference.

In my oppinion the rule you last posted seems the most promising

I will have a think about that I’m prob best waiting until I’m at one of my computers first I have deffinitly got enough brain food from this post to get something closer too working I will post an update

After the two first conditions with return; which overide everything, order your conditions from the least important to the most. This way any “unimportant” ones will get overridden by more important ones further down the rule leaving you with your chosen status at the bottom before sending the command
Good luck

1 Like

I think I will add the return; to a few more rules at the same time I think there’s a few places it may be us full thanks for that will post update soon

Thanks for your help on that i think i have got it sorted now using the tips from this post i have rewriten my rule and tested the switches and checked that it updated the string item for display how i expected

in the end i just used if statements and return; and ordered the items in order of importance

my final working rule posted for you here

rule "System Status"
when
    Item Test_Mode changed or
    Item Away_from_home changed or
    Item In_Bed changed or
    Item Trigger_Tylers_TV changed or
    Item Movie_Mode_Enabled changed or
    Item Disable_Amp_Rule changed or
    Item Trigger_PowerOffLR changed or
    Item Kids_Holiday_Mode_SCHOOL_HOLIDAY changed or
    Item Weekend changed
then
    if( Away_from_home.state == OFF && 
    In_Bed.state == OFF &&
    Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == OFF &&
    Weekend.state == OFF &&
    Test_Mode.state == OFF &&
    Movie_Mode_Enabled.state == OFF &&
    Disable_Amp_Rule.state == OFF &&
    Trigger_Tylers_TV.state == OFF &&
    Trigger_PowerOffLR.state == OFF ) {
            System_Status.sendCommand ("NORMAL") 
            return;
    }
    if(Test_Mode.state == ON) {
        System_Status.sendCommand ("TEST MODE")
        return;
    }
    if( Away_from_home.state == ON ) {
        System_Status.sendCommand ("NOT HOME")
        return;
    }
    if( In_Bed.state == ON ) {
        System_Status.sendCommand ("IN BED")
        return;
    }
    if( Trigger_PowerOffLR.state == ON ) {
        System_Status.sendCommand ("LR POWER OFF")
        return;
    }
    if( Trigger_Tylers_TV.state == ON ) {
        System_Status.sendCommand ("KIDS SLEEP")
        return;
    }
    if( Movie_Mode_Enabled.state == ON ) {
        System_Status.sendCommand ("MOVIE MODE")
        return;
    }
    if( Disable_Amp_Rule.state == ON ) {
        System_Status.sendCommand ("AMP RULE DISABLED")
        return;
    }
    if( Kids_Holiday_Mode_SCHOOL_HOLIDAY.state == ON ) {
        System_Status.sendCommand ("SCHOOL HOLIDAY")
        return;
    }
    if( Weekend.state == ON ) {
        System_Status.sendCommand ("WEEKEND")
    }   
end

Looks like the lesson for the day is how to use the return; function Thanks again