turnerj42 wrote:Hey Martin,
Wondering how complicated it would be to make this code send an email any time a zone is faulted? And then closed. Just wanting to set up zone follower type behaviour without loading down the eyez-on's servers so I think this program is on the right track but I am useless with this level of programming. THe running a service is quite the touch as well. Impressed!
Thanks
Thats quite easy, the ZoneHandler example included pretty much does the trick (almost).
Created a quick ZoneFollower; Get the .zip file and extract the .dll file to your plugin-directory (and remove the plugin.dll, thats for testing/demostration) and restart the service, if the mail function worked before, this one should mail you when someone opens and/or closes a section.
Note; wireless IR-detectors, goes into sleep mode when trigger to often, and will not send any events during their "sleep".
Quick look at the code; Included tamper, alarm and fault as well.
Code: Select all
public override void EventOccured(IResponse response, IReciever r)
{
if (response.Command == ResponseCommand.ZoneOpen)
{
_mailSender.SendMail("Alarm - ZoneOpen", response.Date + "\r\nZone opened: " + response.Data.Substring(1));
}
else if (response.Command == ResponseCommand.ZoneRestored)
{
_mailSender.SendMail("Alarm - ZoneRestored", response.Date + "\r\nZone restored (closed): " + response.Data.Substring(1));
}
else if (response.Command == ResponseCommand.ZoneAlarm)
{
_mailSender.SendMail("Alarm - ZoneAlarm", response.Date + "\r\nAlarm at zone: " + response.Data.Substring(1));
}
else if (response.Command == ResponseCommand.ZoneTamper)
{
_mailSender.SendMail("Alarm - ZoneTamper", response.Date + "\r\nTamper at zone: " + response.Data.Substring(1));
}
else if (response.Command == ResponseCommand.ZoneFault)
{
_mailSender.SendMail("Alarm - ZoneFault", response.Date + "\r\nFault at zone: " + response.Data.Substring(1));
}
}