Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mqtt alerts #538

Merged
merged 9 commits into from Oct 20, 2020
Merged

feat: mqtt alerts #538

merged 9 commits into from Oct 20, 2020

Conversation

xninjax
Copy link
Contributor

@xninjax xninjax commented Oct 18, 2020

Description

MQTT-Client implementation. Send alerts to an MQTT Broker. 🤖

Using MQTT to publish alerts allows for endless alerting flexibility and possibilities.
example uses for MQTT:

  • Pair with Node-red https://nodered.org/ to build instantly flexible alerts and custom actions (home automation, etc)
    eg. flash my smart lights when an alert is published 🚨
  • Send alerts to Cloud based MQTT Brokers to build a centralized hub of notifications
  • etc. etc...

Features

Publish to local MQTT Brokers on private networks, or to cloud based MQTT Brokers.

A built-in safety check will only allow credentials on private networks as TLS not implemented here, yet. However, many cloud-based MQTT brokers do not require authentication to publish - therefore lower priority.

Create dynamic MQTT topics
Use any of the following tags within the topic string (defined in .env)
%store% , %series% , %brand% , %model%

example (.env):
MQTT_TOPIC=nv/%store%/%series%/alert
results:
image

Message is formatted as a JSON object
image

===

discord yarrpirate#8807

Testing

  1. Tested with free cloud MQTT service http://www.mqtt-dashboard.com/
  • Set MQTT_BROKER=broker.hivemq.com
  • Set MQTT_TOPIC=nvidia-test/%store%/%series%/alert
  • Get MQTT-Client application to test with (e.g http://mqtt-explorer.com/)
  • Point MQTT-Client application to broker.hivemq.com
  • Subscribe to nvidia-test/# (under advanced options if using mqtt-explorer)
  • Trigger an alert from nvidia-snatcher (either using test:notification -or- set a test card for a particular store)
  • See MQTT message arrive in MQTT-Client application (e.g mqtt-explorer) ✔️
    image
  1. Tested with local MQTT broker
  • Repeated test above but using local MQTT Broker (https://mosquitto.org/)
  • Added user authentication to server, testing with username and password
  • Success ✔️
  1. Tested with local Node-RED instance on HomeAssistant server to flash my house lights - 🚨 SUCCESS 🚀
    https://www.home-assistant.io/
    snippet from node-red flow to flash lights on MQTT topic (example usage of MQTT)
    image

New dependencies

mqtt

@xninjax xninjax requested a review from jef as a code owner October 18, 2020 21:15
@jef
Copy link
Owner

jef commented Oct 19, 2020

Fix these conflicts and I will get this in! Thanks @xninjax

@xninjax
Copy link
Contributor Author

xninjax commented Oct 19, 2020

conflicts now un-conflicted 😄

@xninjax xninjax marked this pull request as draft October 19, 2020 17:09
@xninjax xninjax marked this pull request as ready for review October 19, 2020 17:26
Copy link
Owner

@jef jef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thank you very much! Kind of an edge feature, but I hope someone uses 😄

@jef jef merged commit 68ff5bf into jef:main Oct 20, 2020
@xninjax xninjax deleted the xninjax/mqtt branch October 21, 2020 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants