How to handle %device% in an IF/Else Block

Trying to re-use a concept I had in WC which was to notify if any windows were open after it detected that both my wife and I had left the house. In WC I used a for each to parse each window, and then using an IF/Else block, trigger when it detected no presence.

Here's what I have in HE, which works, but the notification variables do not. The message I receive just says "is". I suspect it's due to the way I have the IF (windows) structured.

I don't want to trigger off each window, but do I need an IF/Else block for each window separately? Is this something I should use a global variable for?

Note: I have the presence set to True for testing so I can run the actions and get the notification.

Sorry, that topic must be part of the "special people" area that the rest of us common folk are not allowed to see.

image

So, @bravenel, wanna tell me again how there aren't two separate classes of people here on Hubitat; those that matter, and then the rest of us? I was called paranoid for thinking that in the past. I'm starting to think I was right. Releases that aren't offered to everyone. Now topics in the forum that aren't for certain people?

could it not be more likely a broken link / deleted thread ?

I would think that would get a page-not-found error. This is definitely finding the page and saying I don't have access to it. This is that error:

It is in the beta section of the forum. I don't see it mentioned much. However I have never seen anyone denied access who has asked.

I've seen that error on other forums. Some forum technology just does a blanket, "It's a 404 or it's a private page... one of the two", kind of thing.

Could be what you're thinking though -- I have an extra tinfoil hat if you need one. :wink:

1 Like

I see no issue in having a limited access beta group.

Beta code should not be generally available, and often the discussions only apply to those who do have access to the code, so are not for general consumption either.

If someone has need to be in it, all they have to do is ask...

My apologies to all. This one is on me. I'm usually better at things. I was being lazy and pointed back to a previous posting (which was in the beta group), rather than putting up a new set of images here. Bruce has nothing to do with that. Again I am sorry for that.

1 Like

So back to the topic, here's what I came up with with a bit of help from @halfrican.ak . It's probably way overkill for what you are looking for, but it might give you a direction to go in.

Since I key off my windows for a few rules, it seemed a good idea to put all of it into one rule and then point to the variables as needed. This rule checks the open windows and sets the variable if they are okay to be open or not. It now also sets the room variables based on windows being opened or closed. If the window is open, a room variable is filled with it's room name, otherwise it's filled with a space. I'll explain the space insertion later. The screen is cut short, but the idea is pretty well demonstrated.

This allows a couple of other rules to work really nicely. The first is my HVAC rule. All I have to watch for is my win_open variable.
32%20AM

The second one is a bit more complex. I have three states outlined in it. The first is if all the windows are closed. The second ELSE-IF covers the windows that are covered by an alarm system. Sometimes I leave for a quick run to the store and I don't mind. The third state is if unmonitored windows are opened.

In the second and third case, it reads out which room I have to go check. The reason for the spaced insertion is that my chose of TTS notifiers (ALEXA) reads space as silence. So the sentence will read out only the rooms that have an open window.

Part of the clean up is the commas. I also use pushover, so if the bedroom window is open, I'll get something like "bla bla check the ,,Bedroom,, I use the commas in the sentence to give it a bit more of a human feel.

As I said, this is probably overkill for what you are looking for, but it's the only way that we could figure out how to emulate an array and then report back on a single or multiple elements of that array.

57%20AM

Interesting, thanks. Too bad there’s no limited array function like in WebCore. The ability to run a for-each loop is pretty clutch for this type of situation.

I’ll take a look at this and see if I can adapt it.

Thanks again, I went through defining some global variables for my windows and got it working. Here's the code if anyone cares to see.

Set Variables for each one

Run the notification

@mbaran, If all windows are closed ?

What do you mean?

If all windows are closed, what's the notify to the phone ? Nothing ?

If all the windows are closed, why would you need notification?

It wont. The 2nd IF block will only run when the global window open variable is set to open. Otherwise it just jumps to the else (blank) and ends.

I'm sure I could remove a few lines, but I was just troubleshooting a few things.

At night or I'm leaving my house, i want to known all my door, windows, fan, switchs... are closed ? are off ? why not ?

If you don't get an announcement, they are off/closed. Right? If all the variables are blank, you could make a different announcement that they are all closed.

Correct. I only wanted to be notified if open. If closed, or going to bed, I don't care (or at least, it not yet). I suppose I might add something at a future date to notify me if a window is open when my night time routine runs. Hadn't actually thought of that.

corrrect, when closed it does report that state

image