Python3 middleware for KMTronic USB 8 channel relay boxes to control the relays remotely with HTTP requests.
This middleware has been developed for the KMTronic USB Relay Controller Eight Channel model to control the relays remotely and to make it controllable by various home automation systems, such as Home-Assistant.
It contains a lightweight web-server (based on Bottle) and makes it possible to turn on/off the relays with simple HTTP GET and POST requests.
-
Install the requirements:
python -m pip install -r requirements.txt
-
Copy
config.sample.py
toconfig.py
and fill the variables. -
Run the middleware:
python main.py
Method | URI | Content-Type | Purpose |
---|---|---|---|
GET | / | text/text | General info how the API works |
GET | /relays | application/json | Status of all relays in JSON format |
GET | /relays/{id} | text/text | Status of one specific relay (ON/OFF) |
GET | /relays/{id}/on | application/json | Turns ON the relay and returns output of /relays |
GET | /relays/{id}/off | application/json | Turns OFF the relay and returns output of /relays |
GET | /relays/{id}/toggle | application/json | TOGGLEs the relay and returns output of /relays |
POST | /relays/{id} | text/text | Turns ON or OFF (depending on the body) the relay and returns output of /relays/{id} - ideal for Home-Assistant RESTful switches |
Create a new issue at GitHub and I will do my best with.
No.