Note
This is a random personal project shared publicly. It is no longer actively maintained but is published in case it might be useful to someone else!
Originally, this API was used to integrate TV and PC controls with Home Assistant. The provided Docker configuration is fully ready to be deployed on any home server (like a Raspberry Pi or local server) for Home Assistant or any other home automation system.
A lightweight FastAPI application designed to control LG WebOS TVs and wake local PCs using Wake-on-LAN (WoL).
- Wake-on-LAN (WoL): Power on your TV and configured PCs remotely.
- LG WebOS Control: Turn off (standby), turn on screen, and adjust volume using the
pywebostvlibrary. - REST API: Simple POST endpoints for integration with home automation tools (e.g., Home Assistant, custom widgets, or shortcuts).
- Dockerized: Easy to build and deploy as a Docker container.
| Endpoint | Method | Description |
|---|---|---|
/wake-tv |
POST |
Sends a Wake-on-LAN magic packet to turn on the TV. |
/wake-pc |
POST |
Sends a Wake-on-LAN magic packet to turn on your PC. |
/wake-pc-dad |
POST |
Sends a Wake-on-LAN magic packet to turn on your dad's PC. |
/turn-on-tv |
POST |
Turns on the TV screen and sets volume to 70. Fallbacks to WoL if connection fails. |
/turn-off-tv |
POST |
Puts the TV in standby mode. |
/set-volume/{volume} |
POST |
Adjusts TV volume to the specified percentage (e.g., /set-volume/30). |
This application is configured entirely via environment variables. Copy the example template to create your .env file:
cp .env.example .envOpen .env and fill in the values for your devices:
# TV Configuration
TV_IP=192.168.0.95
TV_MAC=E0:51:63:73:A7:EF
TV_KEY=your_tv_client_key_here
# My PC Configuration
MY_PC_IP=192.168.0.83
MY_PC_MAC=1C:BF:CE:E9:5D:C1
# Dad PC Configuration
DAD_PC_IP=192.168.0.44
DAD_PC_MAC=00:A5:54:56:54:91Note
The TV_KEY is the pairing key registered with your LG WebOS TV. If you don't have one yet, when you first run the server and trigger an endpoint, follow the pairing prompt on your TV screen.
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
uvicorn main:app --host 0.0.0.0 --port 8080
-
Build the Docker image:
docker build -t tv-control-api . -
Run the container, passing the environment variables:
docker run -d --name tv-control -p 8080:8080 --env-file .env tv-control-api
This project is open-source and available under the MIT License.