Assuming its for a use like you mentioned, you want to do a scheduled check. There are different ways to do it, since we have all of the flexibility of JavaScript. But one way would be to check the date in onSyncStart:
ie.
Code:
function onSyncStart(forced, timestamp) {
var date = new Date(timestamp);
if(date.getHours() == 21 && date.getMinutes() == 0) {
if(controller.zoneWithName("Garage Door").isNotReady) helper.sendNotification(controller, "Garage door left open!");
}
}
You could also use a range check, but then you might want to use a var to store the last time the notification was sent so you don't constantly get these notifications every minute. Or you could make it check every hour:
Code:
if(date.getHours() >= 21 && date.getHours() <= 0 && date.getMinutes() == 0) {
if(controller.zoneWithName("Garage Door").isNotReady) helper.sendNotification(controller, "Garage door left open!");
}
However if you want to check it when an event happens, then your check would be more like:
Code:
function onZoneNotReady(zone) {
if(zone.name == "Garage Door") {
var date = new Date();
if(date.getHours() >= 21 && date.getHours() <= 7) {
if(controller.zoneWithName('Garage Door').isNotReady) helper.sendNotification(controller, "Garage door opened after 9!");
}
}
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.