This Python script is intended to be run as a service and allows you to control a screen/touchscreen via MQTT. It can directly be added as an MQTT Light in Home Assistant, allowing it to be used in automations and scripts.
- Raspberry Pi connected to a screen or touchscreen (official 7" touchscreen for example).
- python-multitouch
- xscreensaver installed
- rpi-backlight
- Install python-multitouch, installation instructions
- Install xscreensaver,
sudo apt-get install xscreensaver
- Install rpi-backlight ,
pip install rpi_backlight
- Clone this repository on your raspberry pi
- Edit rpi-touchscreen.py, replace BROKER_URL, MQTT_USER, MQTT_PASSWORD
- Run sh start-touchscreen.sh
rpi-touchscreen can be run as a service on boot:
Create a new file in /etc/systemd/system, for example (adjust path to start-touchscreen.sh):
sudo nano /etc/systemd/system/touchscreen.service
[Unit]
Description=Touchscreen service
Requires=network-online.target
Wants=network-online.target
After=network-online.target
[Service]
ExecStart=/path/to/start-touchscreen.sh
StandardOutput=null
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=IMS
User=pi
[Install]
WantedBy=multi-user.target
Alias=touchscreen.service
sudo systemctl daemon-reload
sudo systemctl enable touchscreen.service
sudo systemctl start touchscreen.service