Notification if something hasn't happened

Hi,

Can I get a little help? I just can't figure out how to do this.

I have this vitamin jar. I try to eat my vitamins every day but I don't remember to do it every day.

So, I've put Aqara contact sensor to jar's lid. Idea is to get a notification (text and/or audio) if the lid has not been open by a certain time of a day. And if it has been open, no notification needed.

I already tried Rule Machine ans Notifications but I really don't know where to start.

1 Like

While Rule Machine would ultimately give you more flexibility, it seems like everything you want is also easily doable in the Notifications app. Here's something that will let you know if the sensor stays closed (i.e., hasn't been opened) for more than a day (24 hours times 60 minutes = 1440):

You'll have to configure the "Text Notifications" section (not shown) to select your notification device and the message you want to send, but that part should be easier. :slight_smile:

Do note that with this app configured in this way, you'll have to "kick off" the timer by opening (and then closing) the contact sensor once; that's what will start the timer for the first (and any) time.

1 Like

Thank you very much!

The answer seems to be much simpler that I thought.

What if I open the jar lets say six hours before the notification time. Will the timer start from there and next day notify me earlier than it should?

Also I would like to have this custom audio notification and I believe that is not possible with Notification app?

The countdown starts when the contact sensor reports that it is closed. Then, if it remains closed for more than exactly 24 hours (as I've configured it; you can change that time), it will send a notification. That isn't at a specific time of day, just 24 hours since a "closed" event was reported. I'm not sure if this exactly answers your first question, but I think this is what you meant?

Notifications can do TTS, but if you have a specific file you want to play, you'll probably need RM. That rule wouldn't be too bad to write. Re-reading your original request, I suppose you might actually want this instead if you do want a "specific time of day" thing, but then you'll also have to decide how long it's OK for the sensor to have been closed, too.

Thanks for help! I try to add some more info.

Lets say I want to be notified every night at 8 pm only if the jar has been opened. If it has been opened at some point on the day, there should not be any notifications.

So I think that the countdown doesn't work in this case.

I want a rule to check every night at 8 pm if the lid has been opened on any time on that day. If it has been open, all good. If it's not, then a notification.

TTS doesn't work yet because my kids doesn't understand English. Thats why I have custom audios. I've just downloaded Google Translations speech from English to Finnish.

The way I would do this is probably more complex than it needs to be... I’ll be curious to see what others recommend!

  1. Setup a virtual switch called something like ā€œJarOpenedTodayā€
  2. Setup a simple rule that turns on JarOpenedToday when the sensor is opened.
  3. Setup a Rule Machine rule that runs every day at 8PM that checks if JarOpenedToday is on. If so, it notifies you and then turns it off.

That's about what I was thinking, though you could just use Private Boolean in the "main" rule instead of a virtual device unless you need a device for Dashboard purposes or something (or you could use a global variable with or without a connector, depending again on whether you want a device, if that's clearer). But you definitely need something like that to "track" the sensor, since you can't just evaluate as a single action in a rule whether X happened in the list Y minutes or whatnot.

For the speech, if you have a device that supports the "Play Track" command (check the device page), you can host an audio file on the hub--or anywhere on your network or even the Internet if you prefer. Here's something I have going to a Sonos in this manner (irrelevant things blocked out), hosted from the hub:

Thank you very much! I will try that one!

Thanks a lot! I will try @Sebastien's method. I need to have the exact time to be notified. By that I will learn the routine by myself.

I already found that hosting and audio and "Play track" -thing. Need to add it to this somehow.

If I/we someday get this thing work, I'm applying for the Nobel prize of health care to everyone who participated in this.

If you have a Google Home or an Amazon Echo, you can use also use them to notify you. I have both setup and it works great!

There is a built in app for Google called ā€œChromeCast Integration (Beta)ā€. It is very easy to setup.
There is a community app for Amazon Echo called ā€œEcho Speaksā€ which is a bit more complex to setup and which is currently quite resource intensive, so will slow down your hub a bit (the developer is working on a less resource intensive version...).

This is how I would do it no Booleans or virtual devices.

5 Likes

Wow! That is impressive!

2 Likes

Thanks for the tip.

I already have Echo Speaks installed and in use. It works perfectly.

1 Like

Can you please open up this a bit?

When sensor is or has been open, happens action "timeout: 16:00".
IF sensor stays closed, I'll get a notification?

That "timeout"-part is where I get lost.

The ā€œtimeoutā€ means that after a certain number of hours/minutes/seconds (16 hours in this case), it will timeout on the waiting - it will stop waiting and execute the next line.

So, essentially what this absolutely awesome code is doing is: At 4am, is starts monitoring your sensor. If you trigger it by opening the jar, it executes the next line where it will find that the jar is not closed and hence it will skip the associated action and the program ends until tomorrow at 4am. (No notification required today since you opened it.)

If 16 hours after 4am - at 8pm - the open even hasn’t been received, it will execute the next line and as long as you don’t open it just at that moment, it will send the notification.

Does that help?

2 Likes

Thank you for the clarification.

My god, that sounds absolutely brilliant!

I try to put together the code myself.

1 Like

Could this work?

This is so out of my expertise that I'm not sure what I just did.

It looks good to me! I don’t think it’s necessary, but I would add an ā€œEndifā€ command at the last line.

If you want to test it, you can always set the timeout to something like 1 minute and manually execute the rule.

Like this?


I'm gonna test it tomorrow when holidays starts.

Thank you very much @Sebastien, @at9 and @bertabcd1234!

2 Likes

Yup!