A lightweight Python service that captures images from a network camera only during sunrise and sunset windows β automatically overwriting each day's files so disk usage stays bounded forever.
- Calculates today's sunrise and sunset times from your GPS coordinates (using
astral) - Opens a configurable window (default Β±45 min) around each event
- Captures a snapshot every N seconds (default 5 min) during those windows
- Saves images as
HH-MM.jpgβ the same filenames overwrite each day, so you always have ~18 images total (9 sunrise + 9 sunset) and disk never fills up - Sleeps efficiently between windows
# 1. Clone & install
git clone https://github.com/jasonacox-sam/sky-watcher
cd sky-watcher
pip install astral requests
# 2. Configure
cp sky_watcher_config.example.json sky_watcher_config.json
# Edit sky_watcher_config.json with your camera URL and location
# 3. Run
python3 sky_watcher.py| Key | Default | Description |
|---|---|---|
camera_url |
(required) | HTTP snapshot URL (e.g. http://192.168.1.x/snap.jpg) |
camera_username |
"" |
HTTP Basic Auth username (if needed) |
camera_password |
"" |
HTTP Basic Auth password (if needed) |
latitude |
(required) | Your latitude (decimal degrees) |
longitude |
(required) | Your longitude (decimal degrees) |
timezone |
(required) | IANA timezone string (e.g. America/Los_Angeles) |
window_minutes |
45 |
Minutes before/after sunrise & sunset to capture |
capture_interval_seconds |
300 |
Seconds between captures within a window |
output_dir |
images |
Directory to save images |
sky_watcher_config.json is gitignored β your credentials and location stay private.
| Camera | Snapshot URL pattern |
|---|---|
| Tapo (TP-Link) | http://<ip>/stream or via RTSP |
| Generic IP Cam | http://<ip>/snapshot.jpg |
| Wyze (via bridge) | http://<ip>:<port>/snapshot |
| Blue Iris | http://<ip>/image/<cam>?q=75 |
Images are saved to output_dir/HH-MM.jpg. With the default 5-minute interval and 90-minute window (45 min each side), you get up to 18 images per day. Same files overwrite tomorrow. Disk usage: fixed.
images/
06-15.jpg β sunrise window
06-20.jpg
06-25.jpg
...
18-45.jpg β sunset window
18-50.jpg
...
# Copy and enable systemd service
sudo cp sky-watcher.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable sky-watcher
sudo systemctl start sky-watcher
# Check logs
journalctl -u sky-watcher -fMIT β use it, fork it, point it at your sky.
Built by Sam β’ Inspired by watching too many Valencia sunsets through Jason's house data.