Hi everyone!
I wanted to share a small project I built that might be useful for your automations:
is-it-dark
a simple API service that analyzes images from your cameras to determine:
-
Whether the image is dark, medium, or bright
-
Whether the camera is in infrared (night vision) mode
-
It also returns the calculated brightness value (0–255)
This can be really helpful for automations that react to actual conditions in a room, not just time of day or motion sensors.
How it works
You send a POST request with an image (e.g. from a camera snapshot) to the /analyze endpoint. It responds with JSON like this:
{
"category": "dark",
"infrared": false,
"brightness": 72.4
}
category: One of dark, medium, or bright depending on the configured thresholds.
infrared: true if the camera appears to be in infrared/night vision mode.
brightness: A float value (0–255) indicating the image’s overall brightness.
Example Use Cases
Lighting Automation:
-
Turn on lights only if the room is truly dark (not just based on sunset time).
-
Adjust smart bulb brightness based on real light levels in a room.
-
Avoid turning lights on during the day if the room is already bright.
Security & Cameras:
-
If a camera switches to infrared, turn on nearby lights to bring it back to color mode.
-
Alert if a camera is stuck in infrared (e.g., lens covered).
-
Trigger recordings or notifications based on light level shifts.
Smart Nursery Example:
- If a baby monitor camera shows:
Infrared mode (it’s dark),
No motion is detected (baby is sleeping),
then:
Mute doorbell notifications,
Dim lights near the room,
Optionally set “quiet mode” for the household.
Energy Saving:
-
Turn off hallway lights if the room already has enough ambient light.
-
Optimize blind or curtain position based on brightness in the room, not just weather.
Deployment
-
Docker container
-
Kubernetes
-
Easy to run alongside Home Assistant or as a standalone microservice