Automate your webcam light.
Project description
AutoCamLight
╔═══╗ ╖ ╔═══╕ ╖ ╖ ╖
║ ║ ║ ║ ║ ° ║ ║
╠═══╣╖ ╓╠═╛╔══╗║ ╒══╗╔═╦═╗║ ╖╔══╗╠══╗╠═╛
║ ║║ ║║ ║ ║║ ╔══╣║ ║ ║║ ║║ ║║ ║║
╜ ╙╚══╝╚═╛╚══╝╚═══╛╚══╝╜ ╙ ╙╚═══╛╙╚══╣╜ ╙╚═╛
╓ ║
AutoCamLight ╚══╝
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
Use of uv is highly recommended:
uv tool install autocamlight
Configure
Create a autocamlight.toml file in one of the following locations:
- $XDG_CONFIG_HOME (or ~/.config if unset), or
- $XDG_CONFIG_DIRS (or /etc/xdg if unset), read as a list of folder split by :, as per the XDG specification, or
- 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
[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:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autocamlight-0.2.0.tar.gz.
File metadata
- Download URL: autocamlight-0.2.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93f085bea65e8f13e00ac6c3b43f2291af6ca046e382039f6617c9a29fe0e5ba
|
|
| MD5 |
af880a11cb921b152561a79fa43b56a6
|
|
| BLAKE2b-256 |
c13afc1eeb7ce5d251dab5fd105fa82c5ac55784b1ec9ed6a8e1af9f04a0494b
|
Provenance
The following attestation bundles were made for autocamlight-0.2.0.tar.gz:
Publisher:
ci.yml on dries007/AutoCamLight
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autocamlight-0.2.0.tar.gz -
Subject digest:
93f085bea65e8f13e00ac6c3b43f2291af6ca046e382039f6617c9a29fe0e5ba - Sigstore transparency entry: 633374270
- Sigstore integration time:
-
Permalink:
dries007/AutoCamLight@69853537628ca8f0dbe3dab2a1d8a0e835f27d90 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dries007
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@69853537628ca8f0dbe3dab2a1d8a0e835f27d90 -
Trigger Event:
release
-
Statement type:
File details
Details for the file autocamlight-0.2.0-py3-none-any.whl.
File metadata
- Download URL: autocamlight-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8aeed85389c2356aef11570088ce79aebad074252b6e48fbb39a53d2b2119a5
|
|
| MD5 |
13eda3895c6467e1f36d706c4d8c3dd6
|
|
| BLAKE2b-256 |
24a9ae286d6125fbf8568f6e2dc744f38ff4a8d25bcaf3d8fff5f66a936a6391
|
Provenance
The following attestation bundles were made for autocamlight-0.2.0-py3-none-any.whl:
Publisher:
ci.yml on dries007/AutoCamLight
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autocamlight-0.2.0-py3-none-any.whl -
Subject digest:
c8aeed85389c2356aef11570088ce79aebad074252b6e48fbb39a53d2b2119a5 - Sigstore transparency entry: 633374288
- Sigstore integration time:
-
Permalink:
dries007/AutoCamLight@69853537628ca8f0dbe3dab2a1d8a0e835f27d90 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dries007
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@69853537628ca8f0dbe3dab2a1d8a0e835f27d90 -
Trigger Event:
release
-
Statement type: