Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pfichtner/mqtt-machine-state
Send messages to mqtt broker on machine startups/shutdowns
https://github.com/pfichtner/mqtt-machine-state
automation mqtt
Last synced: about 2 months ago
JSON representation
Send messages to mqtt broker on machine startups/shutdowns
- Host: GitHub
- URL: https://github.com/pfichtner/mqtt-machine-state
- Owner: pfichtner
- License: apache-2.0
- Created: 2023-12-12T13:48:54.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-19T10:05:39.000Z (about 1 year ago)
- Last Synced: 2023-12-19T15:59:39.673Z (about 1 year ago)
- Topics: automation, mqtt
- Language: Shell
- Homepage:
- Size: 91.8 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Go](https://github.com/pfichtner/mqtt-machine-state/actions/workflows/go.yml/badge.svg)](https://github.com/pfichtner/mqtt-machine-state/actions/workflows/go.yml)
# mqtt-machine-state
Send messages to mqtt broker on machine startups/shutdowns
This program does noting more than connecting to a mqtt broker, publishs a message ("online") and blocks until it gets killed (e.g. by ctrl+c).
Before gettting stopped it publishes another message ("offline"). Additionally it registers this message as last will testament (LWT) for the case the connection get's interrupetd.## Ok, what's that for!?
I added this tiny program to the startup of my machines so each machine getting up and down publish their states to the mqtt broker, so you know which machines are up and which not. But the real value is that you can run automations on that. I have a server to which my workstations and servers can do their backups to. This backup server is not powered on permanently. When this server comes up the workstations should start doing there backups which now easily can be done by them by subscribing to the topic of the backup server (wait for the topic nameOfThisMachine/status to be "online")
```
./mqttmachinestate -h
Usage of ./mqttmachinestate:
-c, --config string Config file name
-b, --broker string MQTT broker host (default "localhost")
-p, --port int MQTT broker port (default 1883)
-t, --topic string MQTT topic (default "nameOfThisMachine/status")
-r, --retained Whether messages should be retained
-q, --qos int Quality of Service (QoS) level
pflag: help requested
```