![]() |
%!s(int64=4) %!d(string=hai) anos | |
---|---|---|
.github | %!s(int64=4) %!d(string=hai) anos | |
systemctl_mqtt | %!s(int64=4) %!d(string=hai) anos | |
tests | %!s(int64=4) %!d(string=hai) anos | |
.gitignore | %!s(int64=4) %!d(string=hai) anos | |
.pylintrc | %!s(int64=4) %!d(string=hai) anos | |
CHANGELOG.md | %!s(int64=4) %!d(string=hai) anos | |
COPYING | %!s(int64=4) %!d(string=hai) anos | |
Pipfile | %!s(int64=4) %!d(string=hai) anos | |
Pipfile.lock | %!s(int64=4) %!d(string=hai) anos | |
README.md | %!s(int64=4) %!d(string=hai) anos | |
mypy.ini | %!s(int64=4) %!d(string=hai) anos | |
setup.py | %!s(int64=4) %!d(string=hai) anos |
MQTT client triggering shutdown on systemd-based systems
$ pip3 install --user --upgrade systemctl-mqtt
$ systemctl-mqtt --mqtt-host HOSTNAME_OR_IP_ADDRESS
Schedule poweroff by sending a MQTT message to topic systemctl/hostname/poweroff
.
$ mosquitto_pub -h MQTT_BROKER -t systemctl/hostname/poweroff -n
# https://www.home-assistant.io/docs/mqtt/broker/#configuration-variables
mqtt:
broker: BROKER_HOSTNAME_OR_IP_ADDRESS
# credentials, additional options…
script:
poweroff_raspberry_pi:
sequence:
service: mqtt.publish
data:
topic: systemctl/raspberrypi/poweroff
homeassistant:
customize:
script.poweroff_raspberry_pi:
friendly_name: poweroff pi
icon: mdi:power
systemctl-mqtt --mqtt-username me --mqtt-password secret …
# or
systemctl-mqtt --mqtt-username me --mqtt-password-file /var/lib/secrets/mqtt/password …