Files

23 lines
1.3 KiB
Markdown
Raw Permalink Normal View History

# ha-monitor-brightness
Makes the PC monitor's brightness controllable from Home Assistant: the monitor appears as
`light.pc_monitor` (MQTT discovery) and its brightness is set over DDC/CI.
- Home Assistant 1-255 maps onto monitor brightness `min_level`..`max_level` (default 5-100).
- "Off" sets the minimum brightness and the light stays reported as on (1%), so Adaptive Lighting keeps adapting it; the monitor itself stays on.
- Brightness changed with the monitor's own buttons is reported back every `poll_seconds` (default 30).
- When the PC is off the light shows as unavailable.
## Setup
1. In Home Assistant create a user for the service (Settings → People → Users → Add user,
e.g. `pc-monitor`, "Can only log in from the local network"). The Mosquitto add-on accepts
Home Assistant users.
2. Create the virtual environment and install the dependencies:
`py -m venv .venv` then `.venv\Scripts\pip install -r requirements.txt`
3. Copy `config.example.json` to `config.json` and put that user's name and password in it.
`config.json` is ignored by git, so the credentials stay out of the repo.
4. Run once to test: `.venv\Scripts\python.exe pc_monitor_mqtt.py` (Ctrl+C to stop).
5. Start it at login (no console window): `start.vbs` in the Startup folder or a scheduled task.
The log is written to `pc_monitor.log` next to the script.