Skip to main content

Automate your webcam light.

Project description

AutoCamLight

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

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

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:

  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.

Only a single toml file is loaded.

Example configuration:

log_level = "DEBUG"

[mqtt]
host = "homeassistant.local"
username = "mqtt"
password = "Correct Horse Battery Staple"

[entity]
name = "Webcam"
unique_id = "fe4bd497-7c2f-4f35-899f-f147f9f84738-capturing"

[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:

PayPal

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autocamlight-0.1.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autocamlight-0.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file autocamlight-0.1.1.tar.gz.

File metadata

  • Download URL: autocamlight-0.1.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for autocamlight-0.1.1.tar.gz
Algorithm Hash digest
SHA256 91dc668f1986718f894b15590da5e3f9b8d50e229b31e6ceefcfc12de0955073
MD5 98daf569b49013765f06035713d7ce07
BLAKE2b-256 a76361087662223841bc90e9f544c7850c8fc56168c3a1a962ad93c8c0021829

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocamlight-0.1.1.tar.gz:

Publisher: ci.yml on dries007/AutoCamLight

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file autocamlight-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: autocamlight-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for autocamlight-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e22e51c34fda23b59060751eeb9b3abe827fada5043970564be1f1c0b03e1e45
MD5 eebf5ed46f28f732639c9c5a96cdf117
BLAKE2b-256 af8317b581ffbd8501c108fe255c53ad0c2519f1d9718a36a06d4e812f24a82e

See more details on using hashes here.

Provenance

The following attestation bundles were made for autocamlight-0.1.1-py3-none-any.whl:

Publisher: ci.yml on dries007/AutoCamLight

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page