A Socket.io server for controlling an official 7" RaspberryPi Touchscreen Display, using the rpi_backlight library.
Currently used to control my Pi's touchscreen from HomeAssistant using ha-rpi-backlight.
-
Install Python
-
Create a virtual environment:
python3 -m venv env
thensource env/Scripts/activate
(orsource env/bin/activate
on Unix) -
Run
pip3 install -r requirements.txt
-
Run
python3 main.py
to start the server!
The default port is aiohttp's default port, which is 8080. To change it, create a settings.json
file in the root of the project, and provide a port
key with the value of the port that is desired.
For example:
{
"port": 3000
}
-
set_screen_power
: Takes boolean and sets the screen power accordingly -
get_screen_power
: Returns a boolean indicating the screen power -
set_brightness
: Takes an integer (or float, which is cast to an int) and sets the brightness accordingly -
get_brightness
: Returns an integer of the current brightness -
shutdown
: No arguments, callsshutdown
on the Pi.