hicknotify icon indicating copy to clipboard operation
hicknotify copied to clipboard

consider adding webhooks

Open blysik opened this issue 7 years ago • 2 comments

Cool project! You should consider adding functionality to send a webhook if it detects motion. This will potentially let you integrate with more automation tools.

blysik avatar Jun 26 '17 20:06 blysik

I would like to see this as well, but will try myself first ;)

sossienl avatar Mar 21 '18 11:03 sossienl

So I worked with the code and was able to trigger my domotica webhook, instead of an email. Replace <YOUR_HTTP_WEBHOOK_URL> with your URL.

So this code will not send an email, just a simple HTTP request. Also I'm only triggering it when there is a "fielddetection" (Intrusion alarm) and not "VMD" (Motion detection). That is done somewhere else in the code.

` //fmt.Println("SENDING NOTIFICATION FOR", event, event.camera.Name, now) //m := gomail.NewMessage() //m.SetHeader("From", config.MailFrom) //m.SetHeader("To", config.MailTo...) //m.SetHeader("Subject", fmt.Sprintf("[NVR] Event in '%s'", event.camera.Name)) //m.SetBody("text/html", fmt.Sprintf("Event: %s
State: %s
Count: %d
At: %s
In: %s
Url: %s",event.etype, event.estate, event.ecount, now, event.camera.Name, event.camera.Url))

//d := gomail.NewDialer(config.MailServer, config.MailPort, config.MailUser, config.MailPassword) //err := d.DialAndSend(m) //if err != nil { // fmt.Println("ERROR SENDING NOTIFICATION", err) //} resp, err := http.Get("<YOUR_HTTP_WEBHOOK_URL>") if err != nil { fmt.Println("ERROR SENDING NOTIFICATION", err) } fmt.Println("Response:", resp) `

sossienl avatar Mar 21 '18 12:03 sossienl