How to check if all locks are locked and change "HouseIsLocked" variable to true. Else false

Hi all!

I have three house locks. One is garage, so nix that. Two (Lanai and Foyer) are in-house. I want to test each time a lock status has changed and set HouseIsLocked variable to true or false depending on the following:

If both locks are locked AFTER the action, then HouseIsLocked should be set to locked. Otherwise it should be set to unlocked if both or one is set to not locked.

I can't figure out the logistics that won't create a loop-effect. ie: one status change causes the other to change and fire the rule which will make the variable wrong.

Any help is appreciated. NOT using HPM please. I use only first-party rules and apps.

Thanks!

Jann

Easiest way is to create a grouped device and let its status drive any automation logic.

This screen shot is from a Sensor Groups+ lock group device:

1 Like

This simple rule would probably do the job.

I don't know how you plan to use the variable afterwards, but I think summarizing the multiple locks into a Virtual Lock, would be more useful to me.

2 Likes

OMG! Perl programmer of 40 years here...and I didn't REALIZE you could have two actions, the second overriding the first...cos I didn't know they were:

A: guaranteed to be atomic
and
B: actually DID operate one after the other!

If the previous statements are true, I am THRILLED!

I was VERY wary cos opening/closing and on/off of devices didn't SEEM to operate according to instruction order on Actions.

ie: i've had "close this blind" and "open that curtain" in the same rule, but open curtain would execute BEFORE close this blind. So i didn't trust rule order.

Thanks!

1 Like

Ummm. I don't believe I asked for a third party messy solution. Rule Manager is the way I work. HPM is not the way I would ever want to go. I want control of any packages I install.

Thanks, tho.

geez ok.. your title and first message say NOTHING about using rule machine just asking for help..

2 Likes

Well I liked your suggestion. I currently have a long series of if/thens that check all my locks and contact sensors before finally announcing the status on my Google Speaker.

I wasn't aware this app existed, but I plan to have a deeper look into it.

2 Likes

Actually the OP did mention this:

I’ve moved the thread into the rule machine forum category.

Although I do have to say I find this to be a little curious.

Custom code written by community developers is open source, whereas all the apps and drivers in the hub firmware are closed and can’t be reviewed by anyone.

So many people would probably argue that third party code gives the user the most ā€œcontrolā€ over what’s actually running on the hub.

ETA: driver or app code can be installed manually on the hub, avoiding the use of HPM, if that’s a specific concern.

For full transparency here, OP edited the post to add that blurb well after the fact. It wasn't there originally.

4 Likes

Correct. I added it cos I assumed that most people would give solutions - as @user5298 did - which used hubitat-only device drivers, etc.

The reason? I just updated from C7 to C8 pro and NO MATTER DEVICES WORK ... nor do many of my third-party installed device drivers (non-HPM).

I want something that will work update-to-update...and C7 to C8 Pro, etc... I don't think that's too much to assume - when I'm posting in a hubitat "get help" forum.

I don't want things that will give me spousal nightmares if i decide to update my hardware!

So, high-horse and all, but yeah... I go for hubitat-only ... or I won't expect it to work cross-migration. That's not too much to ask.

ps: about an hour after the fact is NOT "well after". I just saw a screenshot of a HPM app - with NO OTHER DETAILS or help!

Thank you for clarifying that, Chris.

1 Like

(nitpick) you can OR multiple devices as part of the same trigger (select "any").

I am not sure what you anticipated might create a loop. Triggers are locks, action sets a variable - no loop possible, unless I'm missing something. Do you plan to operate the locks from within the rule?

Yes, in general, when it comes to the rule itself and its actions (although there are exceptions, such as adding a delay directly to the action).

That's surprising. Do you have logs showing the execution order was wrong?

Note that rule execution order doesn't always match observations in real life, mainly due to different devices having different delays and reaction times.

Well, that app would have solved your problem, and it was suggested by just about the most helpful person on this forum (and also the app's maintainer). They've even been known to write apps for people just to help them out.

1 Like