|
@@ -6,7 +6,7 @@
|
|
[](https://pypi.org/project/systemctl-mqtt/#history)
|
|
[](https://pypi.org/project/systemctl-mqtt/#history)
|
|
[](https://pypi.org/project/systemctl-mqtt/)
|
|
[](https://pypi.org/project/systemctl-mqtt/)
|
|
|
|
|
|
-MQTT client triggering shutdown on [systemd](https://freedesktop.org/wiki/Software/systemd/)-based systems
|
|
|
|
|
|
+MQTT client triggering & reporting shutdown on [systemd](https://freedesktop.org/wiki/Software/systemd/)-based systems
|
|
|
|
|
|
## Setup
|
|
## Setup
|
|
|
|
|
|
@@ -26,10 +26,18 @@ Schedule poweroff by sending a MQTT message to topic `systemctl/hostname/powerof
|
|
$ mosquitto_pub -h MQTT_BROKER -t systemctl/hostname/poweroff -n
|
|
$ mosquitto_pub -h MQTT_BROKER -t systemctl/hostname/poweroff -n
|
|
```
|
|
```
|
|
|
|
|
|
|
|
+### Shutdown Report
|
|
|
|
+
|
|
|
|
+`systemctl-mqtt` subscribes to [logind](https://freedesktop.org/wiki/Software/systemd/logind/)'s `PrepareForShutdown` signal.
|
|
|
|
+
|
|
|
|
+`systemctl halt|poweroff|reboot` triggers a message with payload `true` on topic `systemctl/hostname/preparing-for-shutdown`.
|
|
|
|
+
|
|
## Home Assistant 🏡
|
|
## Home Assistant 🏡
|
|
|
|
|
|
### Sample Setup
|
|
### Sample Setup
|
|
|
|
|
|
|
|
+#### Send Poweroff Command
|
|
|
|
+
|
|
```yaml
|
|
```yaml
|
|
# https://www.home-assistant.io/docs/mqtt/broker/#configuration-variables
|
|
# https://www.home-assistant.io/docs/mqtt/broker/#configuration-variables
|
|
mqtt:
|
|
mqtt:
|
|
@@ -50,6 +58,19 @@ homeassistant:
|
|
icon: mdi:power
|
|
icon: mdi:power
|
|
```
|
|
```
|
|
|
|
|
|
|
|
+#### Trigger Automation on Shutdown
|
|
|
|
+
|
|
|
|
+```yaml
|
|
|
|
+automation:
|
|
|
|
+- trigger:
|
|
|
|
+ platform: mqtt
|
|
|
|
+ topic: systemctl/raspberrypi/preparing-for-shutdown
|
|
|
|
+ payload: 'true'
|
|
|
|
+ action:
|
|
|
|
+ service: switch.turn_off
|
|
|
|
+ entity_id: switch.desk_lamp
|
|
|
|
+```
|
|
|
|
+
|
|
## Docker 🐳
|
|
## Docker 🐳
|
|
|
|
|
|
1. Clone this repository.
|
|
1. Clone this repository.
|