This is a Python script to connect a Raspberry PI to a Zemismart Roller Shade. It listens to an MQTT topic and executes a close or open command based on that topic.
- Python 3+
- pip (to automatically install python dependencies)
- paho-mqtt
- bluepy
- Zemismart
- libglib2.0-dev
sudo apt-get install libglib2.0-dev
- Download or clone the repository:
- In the directory run
pip install -r requirements.txt
- Configure details in
rollshade.py
and then run withpython3 rollshade.py
Just add a MQTT cover:
...
cover:
- platform: mqtt
name: "Blinds Bedroom"
state_topic: "blinds/02:86:FA:AF:DD:9C/status"
command_topic: "blinds/02:86:FA:AF:DD:9C"
position_topic: "blinds/02:86:FA:AF:DD:9C/position"
set_position_topic: "blinds/02:86:FA:AF:DD:9C/set_position"
position_open: 0
position_closed: 100
qos: 0
state_open: "on"
state_closed: "off"
payload_open: "open"
payload_close: "close"
payload_stop: "stop"
retain: false
optimistic: false
Создайте файл
sudo nano /lib/systemd/system/rollershade.service
Добавьте в этот файл следующие строки:
[Unit]
Description=Rollshade
After=multi-user.target
[Service]
Type=simple
ExecStart=python3 /home/alex/blinds/zemirollshade/rollshade.py
Restart=on-failure
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=roll
[Install]
WantedBy=multi-user.target
Теперь нам нужно активировать сервис:
sudo chmod 644 /lib/systemd/system/rollershade.service
chmod +x /home/pi/zemirollshade/rollshade.py
sudo systemctl daemon-reload
sudo systemctl enable rollershade.service
sudo systemctl start rollershade.service