A simple web page to control a single light.
yagami
uses the homeassistant
REST API to get the state of the light (on or off), and to toggle the state when the web page is clicked.
The following env vars need to be set:
LIGHT_ID
=<home assistant light ID, eg: light.foobar>
YAGAMI_TOKEN
=<home assistant API token>
YAGAMI_PUBLIC_PATH
=<path to the directory that contains html file and images>
HOME_ASSISTANT_URL
=<base URL of home assistant server, eg: 192.168.1.1:8123>
- Rust (https://www.rust-lang.org/tools/install)
- Cargo (comes with Rust)
- Clone this repository
- Run
cargo build --release
- The binary will be in the
target/release
directory.
You can run yagami
locally:
cargo run --release
A systemd unit file, yagami.service
, is provided to run yagami as a service.
To use it:
- Copy the binary
yagami
to/usr/bin/
(see Build instructions) - Create an environment file
/var/lib/yagami/yagami.env
that contains the necessary env variables (see Environment variables) - Copy the file
yagami.service
to/etc/systemd/system/
and enable it with:
sudo systemctl daemon-reload
sudo systemctl enable --now yagami.service