Secure room if home alone and announce

Hi All,

I setup a rule to secure the house if someone is home and is using the shower. I also set it up to announce it via follow me (awesome app).

Just wondering if this is an efficient way to build this app and does it looks right? i was going to make a sep rule for each user been home alone... easier to manage. This is the first user.

essentially if that user is the only one home
and they are in ensuite for 5 mins
the rule should run and either lock back door/ front door and announce accordingly.

Both doors closed - lock both and announce both locked
one door open - lock door and announce one is open
both doors open - announce both are open

If ensuite goes inactive within 5 mins the rule should not fire.

Thank you

updated the rule to include end if before based on advice from another thread.

hopefully this is right.

You're not using Else and If correctly. You can only have one ELSE statement per rule. Because it happens whenever any of the if's are not true.

What you want to replace your else's with is Else IF. All in one statement. I doubt this rule will even fire correctly.

1 Like

ah right. so if i replace the else's with else if

and leave the last else in there

do i have the end ifs in the right spot?

thanks Ryan

No....you have way too many End-If's. I would start all over again. You only need one End-if at the end of the rule.

ok cool thanks will update it.

what is the main dif between doing:

if then
else
if

or

if then
else if

It seems both methods will work but the rule will keep firing through even if the first if (both doors closed) is found to be true - hence been inefficient. is that right?

this cleared it up for me a bit java - Difference Between If and Else If? - Stack Overflow

EDIT:
updated rule hopefully this is looking good.

thanks for the help. this is making sense (I think). Only thing i may have wrong is the
else
if

at the end.

Also if i nitpicked i could put the order of contacts the same in each statement and also fix up wording to match. :slight_smile:

You can only have one ELSE in a Rule. Your rule still has an ELSE followed by another IF. You need to understand how ELSE and ELSE IF work to better understand how to write a rule. An ELSE happens whenever the IF part of the rule is not true. So, whenever the IF is false the ELSE will happen. This means that you can only ever have one ELSE statement in a rule. You cannot have 2 or more. The ELSE IF happens if the previous IFs are False and the conditions listed are true. You can have as many ELSE IFs as you want but only 1 will ever run per rule execution.The rule you have above still has one that is incorrect. Plus, you are missing an END-IF at the end of your rule.

So it seems the last statement
else
if

Wont fire as it will never get there

So do I need to replace the else with and end if and leave the if statement for checking if ensuite is active and cancelling delayed actions?

so this rule works but the only issue is it is not cancelling if motion is inactive.

so it will run 5 or more versions of the rule. Today it triggered correctly where both doors were closed.

But then announced it 5 times so it ran 5 times.

should I add a sep if statement outside of the first if to cancel delayed if inactive?

I think j might need to set a variable so this can only run once a day. Not sure how to do that but will read up. I need to alternatively add a check of the status of the door lock as well. As it's not checking that. I removed it originally as I thought it wasn't triggering but it was due to presence sensor check (one was new and had no state)

thank you

You are missing ELSE and END-IF at the end of your first IF statement. Also, Cancel Delayed Actions should go in the top level ELSE.

IF(Ensuite Motion Active) THEN
    Delay 0:05:00 (cancel)
    //Other actions
ELSE
    Cancel Delayed Actions
END-IF

Hey thanks. Don't I already have else and ENDIF?

So should it be:
IF(Ensuite Motion Active) THEN
Delay 0:05:00 (cancel)
//Other actions
ENDIF
ELSE
Cancel Delayed Actions
END-IF

Correct. Sorry about the delay responding.

Ok cool. Mate you're helping me all good.

Not sure if I need an if then instead of else