Skip to main content

Automate your webcam light.

Project description

AutoCamLight

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

License: MIT PyPI version

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.

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.0.tar.gz (4.5 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.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: autocamlight-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.4

File hashes

Hashes for autocamlight-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2f0be2b84dfeb01894a9b38006e22e7531533c84c3369e7c864fdbf229bad21
MD5 c5e618994d7a3eb5295cfdcb40aa8a2e
BLAKE2b-256 598fba8425e7918d78f9831ea07dad084ab2c43f624827f092dc32f5c1e4cd16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for autocamlight-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6b95d704ec2c516dbf46edb18fd8827f1394ccb1c222864d65ee12f837d4e25
MD5 28e0517994b9cfb190177d3e95718087
BLAKE2b-256 0f52f45fb5b94c12da6a2617d4f8bd02a8f4ccfb098f0a7f97e70b0dbb7db668

See more details on using hashes here.

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