Haiku Custom Push Notification

Hey all, trying to figure out how to send a push notification on a specific day of the week at sunset, essentially like a reminder. (Feed Fish, Feed Dog, Take Out Trash, Test Smoke Alarms, Change Airfilters, Happy Anniversary! :) , etc...) Anyways, first off I would assume this is possible as I can do notifications based on zones etc, so I think I'm close, I just don't spend much time in code and am trying to give myself the lighting crash-course. Here is my code:

// Trash Day

function TrashDay(zone) {
if(dateDescription == Thursday && isDark == True) {
helper.sendNotification(controller, 'Take out Trash');
}
}
// End Trash Day

Any pointers, what am I missing? I would think this would be a common want or ask, but didn't see anything really like this in the past posts.

Thanks in advance.
 
The reason your code isn't working is because TrashDay() would never get called. You are trying to use it like a "callback", but there is no such callback.

Instead you can use something like this:

Code:
function onSyncStart(forced, timestamp) {
    var date = new Date(timestamp);
    var sunsetDate = new Date(controller.sunsetDate);

    if(date.getDay() == 1 && date.getHours() == sunsetDate.getHours() && date.getMinutes() == sunsetDate.getMinutes()) {
        helper.sendPushNotification(controller, 'Take out Trash');
    }
}

This will work because onSyncStart gets called every minute, otherwise you can also use a JavaScript timer or similar. You can change the comparison to getDay() to whatever day of the week you want (1 is Monday).

Also, keep in mind there may be a better way to do this: set up a message on your controller that is scheduled and displayed with a beep and HaikuHelper will automatically forward the message to your push devices, this way you will get the notification system wide, including touch panels and keypads.
 
lupinglade you are a rockstar, responses and answers to my questions in less than 15 minutes, awesome. Thanks a ton. I'll take a look at setting up a message on the controller, and decide the best way for me. I currently don't have any touchscreens, only 2 keypads, and I never use those, always the device in my pocket. I do however want to setup a nice high resolution screen in the wall for a wallboard of data though. Up until this point I had just considered using an ipad recessed in the wall, running Haiku all the time, but I still have a lot of research to do on what I want for that.
 
Back
Top