Setting Reminders

Would you like to help?
Share your walkthrough tutorial with others
User avatar
Posts: 82
Joined: Tue Oct 08, 2013 8:22 pm
Location: Salt Lake City, UT
PostPosted: Sat Mar 14, 2015 9:39 am
Is there a tutorial for setting reminders? I would like to learn more about this.
Image

Posts: 121
Joined: Fri Jul 03, 2015 8:29 am
PostPosted: Thu Jul 23, 2015 5:36 am
i would also like to know if this is possible....anyone?
User avatar
Posts: 2732
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Thu Jul 23, 2015 11:18 am
what kind of reminders are you talking about? like general maintenance reminders?
if so, then you will need to do something yourself.
however, depending on what you want to do, you could code a function to send yourself a wifi alert to do something like you can when an error occurs. it gets harder though because you have to store stuff in the internal memory to keep values across reboots.

so more details are needed on what you want to do.


Sent from my iPad mini

Posts: 121
Joined: Fri Jul 03, 2015 8:29 am
PostPosted: Thu Jul 23, 2015 12:56 pm
I would like it for scheduled maintenance reminders, water changes and so on.

Sent from my SAMSUNG-SM-G900A using Tapatalk
User avatar
Posts: 2732
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Thu Jul 23, 2015 1:31 pm
fishflipper wrote:I would like it for scheduled maintenance reminders, water changes and so on.

Sent from my SAMSUNG-SM-G900A using Tapatalk

Ok. Well, if there was a set schedule that you perform things then that could be done. Say for example, every month on the first, you always do your monthly maintenance, you could setup a WifiAlert to be sent out at say 5pm (after work) on that day (or whatever time you wanted) and it could just say "Monthly maintenance reminder".
If you changed your water every 2 weeks or 4 weeks, you could setup another WifiAlert to check if the week of the year is divisible by 2 or 4 (mod 2 or mod 4), and on every Sunday (or whatever day you want), it could send out another reminder for your water change and say "Time for Water Change".

Does that sound like something you would want? If so, reply back with the schedule of alerts/reminders that you would like to have implement and we can get something started for you to tweak.

Posts: 121
Joined: Fri Jul 03, 2015 8:29 am
PostPosted: Thu Jul 23, 2015 1:41 pm
Yes, that is exactly what I want. I want it to send me a reminder for let's say every Monday and Thursday at 10pm to add my trace elements and every Wednesday at 8pm to do a water change. I would also like it to send a monthly reminder to change my filter pads.

Sent from my SAMSUNG-SM-G900A using Tapatalk
User avatar
Posts: 2732
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Fri Jul 24, 2015 6:43 am
fishflipper wrote:Yes, that is exactly what I want. I want it to send me a reminder for let's say every Monday and Thursday at 10pm to add my trace elements and every Wednesday at 8pm to do a water change. I would also like it to send a monthly reminder to change my filter pads.

Sent from my SAMSUNG-SM-G900A using Tapatalk

Here's a rough outline that is started for you. I added some comments to the functions but they are pretty straight forward. You may have to tweak the WifiAlert function call....I'm just not 100% on the exact syntax of it, but I think I have it correct.
All you have to do is inside your loop, add the "checkReminders();" function call and that will handle the rest.
This also assumes you are using the Portal and having it updated. Otherwise, the WifiAlert class does not know how or where to send the reminder.

If you want to adjust the times, then you just need to modify the values in the functions. Everything is hard coded but could be changed to be stored in Internal Memory to allow for changing without re-uploading new code.

Anyways, hope this helps.
Code: Select all
void checkReminders()
{
   // grab the current time and use it for processing the reminders
   // do it this way to prevent rollover errors...just in case
   time_t t = now();
   remindTraceElements(t);
   remindWaterChange(t);
   remindMonthly(t);
}

void remindTraceElements(time_t t)
{
   // Sunday = 1, Monday = 2, etc
   if ((weekday(t) == 2) || (weekday(t) == 5)) {
      // Every monday and thursday at 10pm
      if ((hour(t) == 22) && (minute(t) == 0) && (second(t) == 0)) {
         // send reminder, No Spaces Allowed in message
         sendReminder("Add+Trace+Elements");
      }
   }
}

void remindWaterChange(time_t t)
{
   if (weekday() == 4) {
      // Every wednesday at 8pm
      if ((hour(t) == 20) && (minute(t) == 0) && (second(t) == 0)) {
         // send reminder, No Spaces Allowed in message
         sendReminder("Water+Change+Time");
      }
   }
}

void remindMonthly(time_t t)
{
   // Every 1st of the month at 8pm
   if (day(t) == 1) {
      if ((hour(t) == 20) && (minute(t) == 0) && (second(t) == 0)) {
         // send reminder, No Spaces Allowed in message
         sendReminder("Change+filter+pads");
      }
   }
}

void sendReminder(char* msg)
{
   static WifiAlert r;
        // No delay, for immediate sending
   r.SetDelay(0);
   // No spaces are allowed in the msg
   r.Send(msg);
}

Posts: 121
Joined: Fri Jul 03, 2015 8:29 am
PostPosted: Fri Jul 24, 2015 7:34 am
This is awesome! Looks pretty straight forward too. I am leaving for vacation and won't be back for a week but will upload it as soon as I do. Thanks so much for this!

Sent from my SAMSUNG-SM-G900A using Tapatalk
User avatar
Posts: 5343
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Fri Jul 24, 2015 6:24 pm
Awesome work Curt, but there's a major flaw in your code that's easily fixable. Do NOT set the delay to 0. Especially as you wrote the code only using seconds which could cause that function to be called quite a few times during that second. The default delay for the WiFiAlert is 15 minutes to prevent spamming yourself. I would just remove the delay and send the message and it will only get sent once. I guess delay is misleading but its delay between sends. It will always send the first time. The other problem is that since you have three different messages i would have 3 different WiFiAlerts declared and they are at the same time then you may want the delay 0 but then you'd have to track if you sent yourself with a static boolean. You could also Set the delay to one minute and offset each reminder. Sorry if Im throwing you off...
User avatar
Posts: 2732
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Fri Jul 24, 2015 7:40 pm
lnevo wrote:Awesome work Curt, but there's a major flaw in your code that's easily fixable. Do NOT set the delay to 0. Especially as you wrote the code only using seconds which could cause that function to be called quite a few times during that second. The default delay for the WiFiAlert is 15 minutes to prevent spamming yourself. I would just remove the delay and send the message and it will only get sent once. I guess delay is misleading but its delay between sends. It will always send the first time. The other problem is that since you have three different messages i would have 3 different WiFiAlerts declared and they are at the same time then you may want the delay 0 but then you'd have to track if you sent yourself with a static boolean. You could also Set the delay to one minute and offset each reminder. Sorry if Im throwing you off...

makes sense.
the wifi alerts should never be sent out at the same time because the time for notification is always different (the exception is the monthly alert which could happen at the same time but then the time could be offset).
I suppose the best option would be to just remove the delay like you suggested.
thanks for the feedback. I did come up with this code in about 10 minutes this morning while working on some other stuff... :) I figured it would need a refinement.

Sent from my Moto X
Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests