Haiku Notification or Email when Zone is Not Ready for Duration

jeremyg

Member
I have never scripted anything in HH before. I am looking for a way to send a push notification and/or email when a specified zone (e.g. Automatic Garage Door) is left open for a certain amount of time. The notification should include the name of the zone and the duration. 
 
This should be close to what you want:
Code:
var garageDoorCheckTimer;

function onZoneNotReady(zone) {
	if(zone.name == "Garage Door") {
		garageDoorCheckTimer = setTimeout(function () {
			helper.sendNotification(controller, zone.bestDescription + " was left open for 1 hour!");
			// optionally you can reassign garageDoorCheckTimer to a new timeout here to remind again
		}, 60*60*1000);
	}
}

function onZoneSecure(zone) {
	if(zone.name == "Garage Door") {
		garageDoorCheckTimer.clearTimeout();
	}
}
 
Thanks, this is awesome! Just to be clear, other than adding this script, and making sure the zone name matches my controller, nothing else needs to be configured?
 
Also can you show me what to change to set it for 30 minutes, or 2 hours?
 
Also, i got this error: Unhandled exception in script on line: 15 in function "onZoneSecure": 'undefined' is not a function
 
The 60*60*1000 is 60 minutes X 60 seconds X 1000 microseconds

So for two hours you can do 2*60*60*1000. 30 minutes would be 30*60*1000.

Make sure you have var garageDoorCheckTimer; at the top of the script. Also check that the quotes are regular double quotes. Sometimes copy and pasting copies them as fancy directional quotes.
 
var garageDoorCheckTimer;

function onZoneNotReady(zone) {
if(zone.name == "Motion Kitchen") {
garageDoorCheckTimer = setTimeout(function () {
helper.sendNotification(controller, zone.bestDescription + " was left open for 1 hour!");
// optionally you can reassign garageDoorCheckTimer to a new timeout here to remind again
}, 60*60*1000);
}
}

function onZoneSecure(zone) {
if(zone.name == "Motion Kitchen") {
garageDoorCheckTimer.clearTimeout();
}
}

That's what i have. (i am using the motion sensor for testing). The error is on line 12.
 
I'm not getting any error when I paste that in. Make sure you click Run Script. Do you have some other code perhaps along with this code that is throwing things off?
 
That's the only code I have in there. And I hit run script and there is no error. The error pops up when the zone becomes not ready I beleive.

Note, the functions actually work and I do get the notifications. But when I look at the Mac, there are many of these error notifications on the screen that I then need to close.
 
this is the error i get when the door is closed, even if it is within the timeout period:
[sharedmedia=gallery:images:757]
 
THis is the code I have. There is nothing else:
[sharedmedia=gallery:images:759]
 


Since the error occurs when the door is closed, the timeout timer is not resetting. So I still get the notifications even if the door is shut in time.
 
Try changing the clearTimeout part to:
Code:
if(garageDoorCheckTimer != undefined) garageDoorCheckTimer.clearTimeout();
Its possible that error occurs because the door goes secure before ever going not ready.
 
like this? Same error...
Code:
function onZoneSecure(zone) {
	if(zone.name == "Kitch/Pool Door") {
		if(garageDoorCheckTimer != undefined) garageDoorCheckTimer.clearTimeout();
	}
}
 
i have tried leaving the door open for various lengths, both shorter and longer than the timeout period. But every time i close the door, the error pops up. And i get the notification no matter what. In fact if I open/close the the door 5 times in a minute, I will then get 5 notifications.
 
try replacing the content of the onZoneSecure function with just:
Code:
alert(zone.name);
It should alert with the name of the zone, does that work?
 
do you mean replace this entire function? 

function onZoneSecure(zone) {
if(zone.name == "Kitch/Pool Door") {
if(garageDoorCheckTimer != undefined) garageDoorCheckTimer.clearTimeout();
}
}
I am not so familiar with scripting. Can you clarify exactly what I should replace?
 
i am guessing this is what you meant...will try it when I get a chance later today.
 
Code:
function onZoneSecure(zone) {
	alert(zone.name);
}
 
Back
Top