Tom's Homepage > Articles

2024-04-06: Automating Camera E-Mails with Reolink and HomeSeer


(This article is also available via the short link tomrei.ch/cam-email)

Background

It's been a few months so I thought I'd share a recent automation recipe. I've begun to integrate with Reolink cameras for home security purposes, but they also work great for automation thanks to some great "AI" features, as well as ONVIF integration. Reolink cameras also work great in an offline fashion and do not require the internet to function, sans the functionality you would expect to require the internet for, such as push notifications. However, thanks to HomeSeer, you can easily have the best of both worlds. Here's a recipe to configure an e-mail notification when the camera recognizes a person, complete with an attached image.

Configuring The Camera

To begin, you'll need to enable a few things in the admin site of the Reolink camera. Head on over to the website for the camera on your internal network, which should just be https:// (or http://) followed by the IP of the camera. Log in and navigate to the settings page, which in my case is found by clicking the settings cog in the upper right corner. Next up, go to the Network tab, then Advanced, then Server Settings. Make sure the checkbox for RTSP and ONVIF are checked, then click Save. I left the ports set to default, (554 for RTSP, and 8000 for ONVIF). Also note that this camera should be behind a firewall and, ideally, should not have access to the internet at all.

Configuring HomeSeer

The next step is to configure HomeSeer so that it can "see" the events from the camera. The magic hear lies in the plugin "ONVIF Events" which is available free and authored by HomeSeer. In HS4, navigate to Plugins > Add, then search for "ONVIF Events" and add it. When you enable the event, you'll need to provide some details for your camera, such as the IP address and name/location information for HomeSeer. Once complete, you should see a new Device in HomeSeer for your camera, with options for each of the different types of motion detection your camera supports. Each one exposes a boolean value which can be used to trigger events.

Next up, create a new Event and add a condition to monitor the desired camera detection type (like PeopleDetect) for changes, specifically when the device changes and becomes "true". I also added a few additional conditions to the list to fit my needs.

The Then clause is where things start getting tricky. The trick to capturing the image is, once again, going to be our old friend PowerShell. Add a step to launch an external program and select PowerShell. In this case I'm using some features that require a newer version than the one that ships with Windows, so I've installed PowerShell 7. The exe to select in my case is:

C:\Program Files\PowerShell\7\pwsh.exe

Note that you'd replace this with the path to pwsh if you're using a newer version of PowerShell, or if you're running in the Linux environment. Next, in the Parameters section, enter:

-Command "Invoke-WebRequest -Uri """https://192.168.0.0/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=username-here&password=password-here&width=640&height=480""" -OutFile C:\Temp\Porch.jpg -SkipCertificateCheck"

...making sure to replace the IP with the IP address of your camera, as well as the username and password. Notice how we are saving the snapshot to a temporary location on our local hard disk, so make sure this path exists and HomeSeer has permission to it as well. In this case we're using C:\Temp\Porch.jpg.

Finally, add a step to send the email to your desired location, pointing the attachment to the image that you saved in the previous step.

Note that, in addition, I added a few "Wait" steps to both give the person time to get a little closer to the camera, and a little bit of time for the PowerShell command to run and save the file. You may need to adjust these values to suit your environment, so play around with these numbers a little.

When it's all said and done, it should look like this:

Conclusion

HomeSeer and Reolink cameras make a perfect pairing thanks to ONVIF and the HomeSeer ONVIF plugin, with a little help from PowerShell. Even better that it can run entirely in an offline fashion, thereby not compromising the security of your network. I'll continue to share as a I find more useful automations centered around these tools.