Rule Machine - need help to send list of devices (e.g., contacts that are open) to string variable

I have a WebCore piston that I'd like to see if I can move over to Rule Machine.

It's an evening door/window contact check. The piston:

  1. Captures the current open doors/windows to a variable {deviceList}
  2. Sends that {deviceList} to a Speak command to Google Home so that Google can tell me what's open before we go to bed.

I've found how to create a string variable, but am not sure how to get RM to send the list of open doors/windows to the variable.

Also want to use this in rules that tell me which leak sensor has a leak (I have a WebCore piston that turns off our water valve and announces the location of the leak), etc,

You should be able to do that with the Notifications app. Try that and I can post an example tomorrow if you need it.

1 Like

Thanks, I'll take a look at it. I run the nightly check via request to Google Home, which triggers a virtual switch which runs the piston.

Can I do the same w/the Notifications app, have it run a specific notification at ad hoc times based on a virtual switch that I trip?

Looked at the app, and I don't think that it will work for my ad hoc use-case.

You could do this with a rule, but I got tried of doing that and wrote a custom app to do exactly what you want instead:

The Notifications app would likely not work well here, since it's designed to respond to events in real time (or with a delay if the condition the event caused to be true is still true), not really check on demand like this.

That being said, if you prefer a rule over custom code, I have an example of the rule I used to use in that post, too. :slight_smile: So that should give you one idea of how you could do this in RM. Hope this helps!

2 Likes

I tried to give you a dozen likes, but it keep stopping at one. :wink:

So very very cool. Do you ever stop coding?! :slight_smile:

Off to look at your app...

I haven't stopped since I decided to rid my hub of any code but stock apps or my own (plus HubConnect but only because that would be a lot of work) and have it finally do exactly what I'm after instead of settling for "close enough," but some day I'll get there. :rofl:

(Along those lines, something I want to add to the above app is a way to combine/associate locks and contact sensors and/or assign nicknames besides the device name, so it would be able to say something like "Front door is open and unlocked" instead of "Front door lock is unlocked and front door contact sensor is open." Some day...)

Your app is very cool, it's what I would have written if I could write apps. :slight_smile:

There is one gap for me, however, that may send me back to a rule, unfortunately.

I have a second part of my piston that:

  1. Turns off lights/TV, etc., in our family room and back yard, etc.
  2. Turns on bedside lights in our bedroom

I figure I can take care of those actions via Rule Machine by using my virtual "good night" switch as the trigger for a rule.

Not sure if this would work for you, but I have a similar "Good night" switch I trigger from a voice assistant (or button) that runs a series of things, and one of those actions is turning on the "Or any time this switch is turned on" switch in the app's settings at the end so I get a TTS announcement. Here, I only want TTS, not a notification, and I still want the TTS even if everything is OK, so here are some of my settings for that:

1 Like

Thanks, I'll look at it.

One interesting thing I noticed thanks to your app...my virtual switch turns on but doesn't turn off. So the second time I ran the good night routine w/your app it didn't respond, since the virtual switch was already on. :slight_smile: I set it up now so that the virtual switch turns off immediately after being turned on.

1 Like

Oh, and generally I am still interested in how to send a list of devices to a string variable in RM and then use it. I am starting to get into RM a little to see how it works, and if I like working in it. :slight_smile:

In that case, hopefully you saw the rule (which I replaced with my app) in the other post. That should give you a starting point. It's a bid awkward, since RM doesn't have the ability to natively iterate over a list of devices (or any concept of collections like that in the first place), so a series of conditionals is the best way I could think of. Good luck!

1 Like

Don't know if you noticed this, as I didn't for a long time. There is an option on the device page in almost all switches that allows you to have them automatically turn off after a preset time up to 5 seconds. No need for a rule.

1 Like

Thanks, I had missed that. Makes a lot easier to auto turn off the switch, I was using a simple automation to turn it off, now I can just have it done in the device.

Decided it wasn't worth the effort to force RM to do the device stuff.

I set up my leak detection/response in HSM (which is probably where it belongs anyway), and used your cool Device Status app for the goodnight door and window checks/announcements, combined w/a very simple RM rule to turn off kitchen/fam room, etc., lights, and turn on bedroom lights. All working nicely together.

On to the next adventure/learning opportunity. :smiley: Thanks for your presence here in the community and for your apps.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.