Hello everyone! I’m excited to share my recent journey into automating my security cameras to switch between day and night modes based on sunrise and sunset. ![]()
![]()
My Scenario:
I have several cameras set up around my property, and I wanted to optimize their performance by automatically switching to night mode at sunset and back to day mode at sunrise. This would save me from manually adjusting each camera every day.
The Challenge:
I came across the HTTP GET method as a potential solution, but I was a bit overwhelmed by how to implement it in Home Assistant. Each camera has a unique IP address and specific URL codes for switching modes. I needed a way to trigger these commands automatically based on the sun’s position.
The Solution:
After some research and trial and error, I figured out how to set this up using Home Assistant’s automation feature. Here’s a simplified version of what I did:
-
Identify the URLs:
Each camera has a specific URL to switch to day or night mode. For example:
plaintext
Day Mode: http://admin:password@192.168.55.156/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].TimeSectionV2[0][0]=00:00:00-24:00:00 Day
Night Mode: http://admin:password@192.168.55.156/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].TimeSectionV2[0][0]=00:00:00-24:00:00 Night -
Set Up Automation in Configuration.yaml:
I added the following automation to myconfiguration.yamlfile:
yaml
automation:
-
alias: “Enable Day Mode”
trigger:
platform: sun
event: sunrise
action:
service: http.get
data:
url: “http://admin:password@192.168.55.156/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].TimeSectionV2[0][0]=00:00:00-24:00:00 Day” -
alias: “Enable Night Mode”
trigger:
platform: sun
event: sunset
action:
service: http.get
data:
url: “http://admin:password@192.168.55.156/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].TimeSectionV2[0][0]=00:00:00-24:00:00 Night”
- Repeat for All Cameras:
I repeated the above steps for each camera, adjusting the IP addresses and URLs accordingly.
The Result:
Now, my cameras automatically switch modes based on the time of day, providing optimal surveillance without any manual intervention. It’s a small but significant improvement that saves me time and ensures my cameras are always operating efficiently.
Tips for Others:
- Test URLs First: Before setting up automation, test the URLs in your browser to ensure they work as expected.
- Use Correct Credentials: Make sure the username and password in the URLs are correct to avoid authentication errors.
- Check Time Zones: Ensure your Home Assistant instance is set to the correct time zone to avoid synchronization issues.
I hope this helps anyone looking to automate their camera settings. Happy automating! ![]()