Centralizing Notification Logic?

Not sure this idea makes any sense, but here goes ....

Now that I have 30-40 rules, I've begun to notice that nearly every time I write a rule, there is some notification logic that I am writing. And so I retype the same stuff into RM4 over and over again with each rule....sending messages to various mobile devices and/or speaking those messages. What I wonder is why I have to reconstruct this logic into every rule. Couldn't I instead use global variables to set the parameters for a notification and then "call" on some other rule to execute the notification?

If doable, I picture the parameters for a generic Notifier would be something like this:

  1. Recipients: who receives the messages
  2. Message Channel: Text-based (SMS, HE App, Pushover) or Speech (Sonos, Echo)
  3. Priority (esp.for Pushover)
  4. Repetition
  5. (If Spoken) Time of Day restrictions to prevent making noise when people are sleeping

So, I'd picture each rule would set these 5 parameters appropriate to the use-case and pass them along to some kind of shared notification engine to execute the messaging. Except the code for that messaging is defined once and only once. Easier to maintain, easier to change.

I was thinking about using Global Variables, but what happens when multiple rules are setting different values for the same 5 GVs, not sure how HE would thread the activity. Is this possible? How would I approach it? Appreciate any feedback. Be gentle, I'm still a newbie. :grimacing:

If the recipients and message, among other things, are different for every notification, what does centralizing it accomplish? I'm not trying to question your motivation, just wondering what you would actually get out of this.

I created a notification "proxy" device that is one device I can use to send notifications to multiple "real" devices (making my apps and rules easier to manage if I ever add or remove devices of change my mind--only one place to worry about this), but I don't think that's quite what you're after. If Cobra re-releases Message Central or Speaker Central, the latter is basically a more powerful version of this that can handle restrictions on your virtual/proxy device (e.g., don't send to this speaker when sleeping).

If you're just tired of writing rules, the built-in Notifications app can handle a lot of things I see people using Rule Machine for with a lot less effort.

I had been trying to do something similar to do "notify if present". In WebCore I had a function to do this since you could specify inputs. In Hubitat I found it easier to just write a custom app: [RELEASE] Presence Aware Notification Wrapper

Depending on what you need to do you might be able to follow that pattern to have an App + Notification wrapper device.

One place to maintain the logic!

To use a historical example.... when I started using spoken messages for a bunch of my notifications, I thought I was all clever by adding a simple condition like so:
IF (it's between hours of waking up and bedtime)
THEN Speak
ELSE Don't Speak

Of course later I realized that was not very extensible. I should just replace "between waking up and bedtime" with a global variable that determines whether it's wake time. The value for the GV can then be managed separately through some rules, be overriden manually, etc. But making that change meant going back into 30 rules to execute the change. Ick.

Now I'm picturing all the other similar changes I'd like to make and I'm asking myself the meta-question about whether there's a way to codify once (continuing to maintain the logic in one place) and then have all rules reference it somehow.

Eric, yeah I saw that. Cool idea, but since it's only based on Presence, it doesn't quite have the parms that I'm looking for. And I don't have the skills to write a custom app. Maybe that's my dead end.

Makes sense! Speaker Central isn't available right now, but will likely be re-released soon. Still, the description in that thread may give you a good idea of whether it will meet your needs. (It handles both speakers and, per a request apparently made just by me that the author was gracious enough to include in an update, notification devices.)

You might be able to re-create something like that using your own logic in a Rule and a virtual notification device (not sure if one exists as a stock driver but it would be easy to create), then sending custom commands to that device, but I haven't tried this so there might be something you can't do that I'm not thinking of...

1 Like

Follow Me with What Did I say, controls where and how all my notifications are handled.

2 Likes

Thanks Bryan, I had the impression that What Did I Say was focused on Speak and that Follow Me was Speak and Pushover. I'm going to check it out, thanks!

@bertabcd1234 Can you please elaborate on how you did this? I got a new mobile and now have to remove my old phone and add my new phone to 84,691,423 rules!

It's not super-polished to set up since I basically just wrote it for myself, but what I did was:

  1. Create a virtual device using my "Notification Proxy Device" driver:

This is the device you'll actually send the notifications to in apps/rules.

  1. Use my corresponding "Notification Proxy" app to tie this device to one or more "real" devices:

(The UI should be straightforward: choose the "Proxy" device you created above, then choose zero, one, or more "real" devices for it to route to; the idea here is that if you ever swap mobile app devices or want a bunch of notifications to go to multiple devices, you can make those changes here instead of in every app.)

Long-term, I should probably make this friendlier by having the app create the device instead of having to do it manually first, but it works for me. :smiley:

Hi Robert @bertabcd1234 ,

I've been playing with this notification proxy device you roughed together and I just thought of something that might work well with a few other apps, such as Device Check app from Bryan @bptworld .

You've basically made a superior virtual presence device here that allows for notification redirection to wherever you want it to go. My thought is that other Apps could check to see if the notification proxy device is being used for notifications and then offer to check presence to see if the notification should be sent or not. We could then set your notification proxy as the output presence for one of the presence combiner apps.

So an example use would be when you want to send a notification to these people, but only if they're home. I think that might be handy for sure. Can you think about polishing this one up in your usual style and maybe add to HPM?

Cheers,

Glenn.

Have you looked at Follow Me ?

@bptworld Haven't looked at it yet as I haven't started doing voice/speech notifications, but I just installed it to take a quick look, and it does look like you can set presence for notifications, but does that allow a per message choice of if presence matters or not in other rules?

Example: I'm using your Device Check App to warn if windows are open for example, and I'd like it to notify both me and my wife, but skip whoever is not home at the time.

I envisioned an option that appears when building a rule when you select a notification device (that also has presence) that asks you to choose if to send when present/not present/all the time.