Skip to main content

Discord Gateway for MQTT

I have created a new organisation on Github today as a place to add automation scripts and the first one I will add is a gateway for Discord.

This core of this script was originally created when I needed to send crash alerts from an application I had written to my phone so that could act upon them quickly. This proved useful and I added it to additional scripts and applications, but found that it was a bit limited if I wanted the alert to be logged elsewhere so I updated my apps and scripts to send to MQTT.

Once my alerts were in MQTT I could pick them up from NodeRed and perform various actions; but I missed having them arrive in Discord, so last night I created an MQTT-2-DISCORD module that includes  support for multiple discord channels.

Installation is fairly simple and I have documented the process in the README.md file associated with the repository.

After installation, visit Discord and obtain a webhook for the channel you want to recieve messages into. You can name the webhook anything you like (mine is called "Home Alerts"). You then edit ~/modules/mqtt-2-discord/config.ini and add a section that contains a unique topic and your webhook:

[HomeAlerts]
topic=messages/alerts        webhook=https://discord.com/api/webhooks/AAAAAAAAAAAAAAAAAA/AAAAAAAAAAAAAAAAAA

Restart the daemon and simply publish to your topic (messages/alerts in this case) to receive a message in Discord.

sudo systemctl stop mqtt2discord
sudo systemctl start mqtt2discord



Comments

Popular posts from this blog

Fixing heated bed

Today I set about fixing the issue with my heated bed. Using a multimeter to test the thermistor that came pre-installed showed it was dead so I snipped it out and soldered in a replacement. In Pronterface I could see that it was connected, but it was reading -15C. The room is cool but not that cool. The new thermistor is "100K ohm NTC 3950 1% 1.8mm" and after a bit of googling I found it was a type 11. I edited my "configuration.h" file and set "#define TEMP_SENSOR_BED 11". After uploading Marlin; Pronterface was now reading a temperature of 16C. I was able to change the bed temperature from the LCD to 20C and watched as it warmed up. I checked it was warm (carefully with my hand) and then increased it to 60C.  So another job done. Next will be to fix the connector on the hotend thermistor and get that working: For now though, it's starting to look good:

LSP and JSON

I've taken on the challenge of writing an LSP for BlitzMax NG to help with the integration of the vs-code extension.  For those who don't know what an LSP is; it is simply a communications component that is used by any IDE to obtain information regarding your source code. It then uses this information to create outline views, hover, help and diagnostics etc. Rather than use the BlitzMax JSON module, I decided to write a JSON parser specifically for this application that gives me a little more control to transpose JSON directly into BlitzMax Types. I will publish this on GitHub shortly. With the JSON module almost complete, the LSP application can now read/write to/from StdIO and I'm currently working on getting the "initialize" and "shutdown" event handlers operational. Watch this space.