Python script to send discord webhooks when receiving MQTT messages
259
small python script to send you a discord webhook for MQTT events Environment variables:
MQTT_BROKER_IP IP for MQTT brokerMQTT_PORT Port for the MQTT brokerMQTT_TOPIC MQTT topic to listen forMQTT_DC_WEBHOOK URL for the discord webhookMQTT_DC_MESSAGE Message to send when webhook is triggeredMQTT_PASS Password for MQTT broker (highly reccomended to set up)MQTT_USER Username for MQTT broker (highly reccomended to set up)A .env file can be used or the environment variables can be passed.
If running in a swarm cluster, it is reccomended to use secrets for the password instead of env variables.
The built container is available at https://hub.docker.com/r/angrypig555/mqtt-discord-webhook?tag=latest but it is not required to use a container. Example compose.yaml file for swarm deployment:
services:
webhook:
image: angrypig555/mqtt-discord-webhook
restart: unless-stopped
environment:
- MQTT_BROKER_IP=BROKER_IP_HERE
- MQTT_TOPIC=TOPIC_HERE
- MQTT_DC_WEBHOOK=/run/secrets/dc_webhook
- MQTT_USER=USER_HERE
- MQTT_PASS=/run/secrets/mqtt_pass
- MQTT_DC_MESSAGE=MESSAGE_TO_SEND_HERE
- MQTT_PORT=PORT_HERE # usually 1883
secrets:
mqtt_pass:
external: true
dc_webhook:
external: true
Code can be found at https://github.com/angrypig555/mqtt-discord-webhook
Content type
Image
Digest
sha256:386d1e5bb…
Size
396.5 MB
Last updated
about 2 hours ago
docker pull angrypig555/mqtt-discord-webhook