Skip to main content

AutoCamLight

╔═══╗    ╖      ╔═══╕         ╖         ╖   ╖  
║   ║    ║      ║             ║    °    ║   ║  
╠═══╣╖  ╓╠═╛╔══╗║    ╒══╗╔═╦═╗║    ╖╔══╗╠══╗╠═╛
║   ║║  ║║  ║  ║║    ╔══╣║ ║ ║║    ║║  ║║  ║║  
╜   ╙╚══╝╚═╛╚══╝╚═══╛╚══╝╜ ╙ ╙╚═══╛╙╚══╣╜  ╙╚═╛
                                    ╓  ║  
AutoCamLight                        ╚══╝  

PyPI version Python Versions Downloads License: MIT Ruff GitHub issues GitHub stars Last Commit PayPal

A small linux utility to automate your webcam light via Home Assistant.

Monitors /dev/video* and sends a state update to HA via MQTT when it detects that video is being captured.

Usage

Install, configure and run in the background.

After the first time the webcam is used, the device & entity will be created in Home Assistant, so you can set up your automations.

Install

The package is available on PyPI.

Use of uv is highly recommended:

uv tool install autocamlight

Update with:

uv tool update autocamlight

Configure

Create a autocamlight.toml file in one of the following locations:

  1. $XDG_CONFIG_HOME (or ~/.config if unset), or
  2. $XDG_CONFIG_DIRS (or /etc/xdg if unset), read as a list of folder split by :, as per the XDG specification, or
  3. the current working directory.

The files are read in the order they are listed, so you can override settings. But only top level keys can be overridden in their entirety, no table merging is performed.

Example configuration with some comments:

# Log level, one of: CRITICAL, ERROR, WARNING, INFO, DEBUG
log_level = "DEBUG"

# Time to wait for inotify events, in seconds.
# Longer times will reduce CPU usage, but will increase the delay and jitter of the state updates.
inotify_block_duration = 0.1

# Time to wait after before sending the state update, in seconds.
# If another event is received before this time, the timer is reset.
debounce_duration = 0.5

# MQTT settings from https://github.com/unixorn/ha-mqtt-discoverable
[mqtt]
host = "homeassistant.local"
username = "mqtt"
password = "Correct Horse Battery Staple"

# Entity settings from https://github.com/unixorn/ha-mqtt-discoverable
[entity]
name = "Webcam"
unique_id = "fe4bd497-7c2f-4f35-899f-f147f9f84738-capturing"

# Device settings from https://github.com/unixorn/ha-mqtt-discoverable
[entity.device]
name = "Webcam"
identifiers = "fe4bd497-7c2f-4f35-899f-f147f9f84738"

The file structure is dictated mostly by ha_mqtt_discoverable.

Auto-run on login

Create a new (user) unit file:

systemctl --user --force --full edit autocamlight

Add the following to the file, assuming uv is installed in /usr/bin:

[Unit]
Description=AutoCamLight
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/uv tool run autocamlight
Restart=on-failure
RestartSec=5
Environment=PYTHONUNBUFFERED=1
# Remove the next line to disable auto-updating the program.
ExecStartPre=/usr/bin/uv tool upgrade autocamlight

[Install]
WantedBy=default.target

Now enable & start the unit:

systemctl --user enable autocamlight
systemctl --user start autocamlight

You can monitor the service status with:

systemctl --user status autocamlight
journalctl --user -u autocamlight -f

Test

Open any program that uses the webcam, e.g. Cheese.

If you have the logs open, an INFO message should appear. The entity should be created in Home Assistant.

Support the Project

If you find this project useful, a tip is always welcome via PayPal:

PayPal

Metadata

Release files for autocamlight 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autocamlight 0.2.1
File Size Uploaded Provenance Actions
autocamlight-0.2.1.tar.gz 7.0 kB With provenance Details for autocamlight-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for autocamlight 0.2.1
File Interpreter ABI Platform Actions
autocamlight-0.2.1-py3-none-any.whl Python 3 none any Details for autocamlight-0.2.1-py3-none-any.whl

Total release size: 15.1 kB

Release files / autocamlight-0.2.1.tar.gz

Download URL autocamlight-0.2.1.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ed03eda92b2a28405c6baa3f42a756b689c52094521ee2c8d94d800408469433
BLAKE2b-256 checksum
How to use checksums
be36d97d4c9d60dd766ed51b93ca86a1a28818089afc920fe3783ebc7706bd16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / autocamlight-0.2.1-py3-none-any.whl

Download URL autocamlight-0.2.1-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04cb36fb91ac2f0d092762b838e1fcd990514d095c4082097ff48af28210874e
BLAKE2b-256 checksum
How to use checksums
1b5a1124292663104200cef7ef8b04245efe142f76a40c8795c65a288c4c20ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for autocamlight 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for autocamlight-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page