MQTT Desktop Notification is a lightweight Windows desktop application written in Java that can be used to send notifications to the Windows desktop via MQTT. The tool is ideal for displaying notifications from platforms like Node-RED, Home Assistant, or any other system that utilizes MQTT.
- Real-time Notifications: Receive and display desktop notifications sent via an MQTT message.
- Icon Integration:
- Allows users to represent the status of their smart home systems using a tray icon.
- Users can update the tray icon dynamically via an MQTT message.
- Customizable: Easily configure MQTT broker settings, topics, and notification preferences via a
settings.json
file. - Windows Only: Specifically designed for Windows OS.
- Lightweight: Minimal system resource usage, designed to run in the background.
-
Download the latest release from the Releases page.
-
Extract the downloaded zip file to your desired location.
-
Run the application by double-clicking on
mqtt-desktop-notification.jar
or by running the following command in the terminal:java -jar mqtt-desktop-notification.jar
- Initial Configuration: Upon the first launch, the application will automatically generate the
settings.json
file in its directory before closing.
- Initial Configuration: Upon the first launch, the application will automatically generate the
-
Edit Configuration: Customize settings by opening the
settings.json
file in a text editor. Ensure therun
value is set totrue
. -
Restart Application: After adjusting the settings, relaunch the application by running the
mqtt-desktop-notification.jar
file. -
Receive Notifications: Once restarted, the application will seamlessly operate in the background, delivering desktop notifications for incoming MQTT messages.
To enable the application to run automatically at startup:
-
Copy the JAR file: Right-click on the
mqtt-desktop-notification.jar
file and select "Copy". -
Insert Link: Navigate to the Windows startup folder by pressing
Win + R
, typingshell:startup
, and pressingEnter
. Once in the startup folder, right-click and select "Paste Shortcut" to insert a link to themqtt-desktop-notification.jar
file. -
The application will now run automatically every time you start your computer.
Upon first startup, a settings.json
file is automatically created in the application directory. This file has the following structure:
{
"run": false,
"brokerUrl": "tcp://127.0.0.1:1883",
"username": "sampleUser",
"password": "samplePass",
"lastWillTopicPrefix": "client",
"notificationTopic": "notification/json",
"iconTopic": "notification/icon"
}
- run: Boolean to control whether the application should run.
- brokerUrl: The URL of your MQTT broker.
- username: The username for connecting to the MQTT broker.
- password: The password for connecting to the MQTT broker.
- lastWillTopicPrefix: The prefix for the Last Will and Testament (LWT) topic.
- notificationTopic: The MQTT topic to subscribe to for notifications.
- iconTopic: The MQTT topic to subscribe to for icon updates.
- Open the
settings.json
file in a text editor. - Modify the fields as needed.
- Save the file and restart the application for changes to take effect.
-
Notification Message: Create a JSON object / String with the following structure:
{ "flag": "info", "topic": "Title", "message": "Message" }
- Flag: Represents the urgency of the notification in the Windows message system. Allowed values are
none
,info
,warning
, orerror
. If the flag is set toerror
, an additional popup will be opened. - Topic: Describes the header or title of the notification message.
- Message: Contains the body or content of the notification.
- Flag: Represents the urgency of the notification in the Windows message system. Allowed values are
-
Send Notification: Publish the JSON message to the MQTT topic specified in the
notificationTopic
setting configured in thesettings.json
file. -
Receive Notifications: Once the message is sent, the application will process it and display the desktop notification accordingly.
-
Select Icon: Choose the desired icon from the available options. The icons are located in the icons directory of the project repository.
-
Prepare Icon Message: Create a MQTT message string containing the name of the selected icon. For example, to select
circle-black.png
, pass the stringcircle-black
without the.png
extension. -
Send Icon Message: Publish the icon message string to the MQTT topic specified in the
iconTopic
setting configured in thesettings.json
file. -
Receive Confirmation: Once the message is sent, the tray icon will change to the selected icon, providing visual feedback to the user.
Click to display the Node-Red flow
[
{
"id": "7844d8f9af265613",
"type": "inject",
"z": "72a5755d1a09f75e",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "{\"flag\":\"info\",\"topic\":\"Title\",\"message\":\"Message\"}",
"payloadType": "json",
"x": 150,
"y": 160,
"wires": [
[
"2a204a526163c784"
]
]
},
{
"id": "2a204a526163c784",
"type": "mqtt out",
"z": "72a5755d1a09f75e",
"name": "",
"topic": "notification/json",
"qos": "2",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "",
"x": 440,
"y": 160,
"wires": []
},
{
"id": "d65e8bbf4616a272",
"type": "mqtt out",
"z": "72a5755d1a09f75e",
"name": "",
"topic": "notification/icon",
"qos": "2",
"retain": "false",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "",
"x": 440,
"y": 280,
"wires": []
},
{
"id": "b93cb4703ceffb06",
"type": "inject",
"z": "72a5755d1a09f75e",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "circle-green",
"payloadType": "str",
"x": 170,
"y": 280,
"wires": [
[
"d65e8bbf4616a272"
]
]
},
{
"id": "3ebeb5e8cf65a91e",
"type": "inject",
"z": "72a5755d1a09f75e",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "circle-red",
"payloadType": "str",
"x": 160,
"y": 320,
"wires": [
[
"d65e8bbf4616a272"
]
]
},
{
"id": "384e3690f53064ec",
"type": "comment",
"z": "72a5755d1a09f75e",
"name": "Send notification",
"info": "",
"x": 180,
"y": 120,
"wires": []
},
{
"id": "5de93b05d4e750c5",
"type": "comment",
"z": "72a5755d1a09f75e",
"name": "Change icon",
"info": "",
"x": 170,
"y": 240,
"wires": []
},
{
"id": "f7323a730795d4de",
"type": "comment",
"z": "72a5755d1a09f75e",
"name": "/~https://github.com/marcel-domke/mqtt-desktop-notification",
"info": "",
"x": 310,
"y": 60,
"wires": []
}
]
To build the application from source, follow these steps:
-
Clone the repository:
git clone /~https://github.com/marcel-domke/mqtt-desktop-notification.git cd mqtt-desktop-notification
-
Compile the project using your preferred Java IDE or build tool (e.g., Maven or Gradle).
-
Run the application:
java -jar target/mqtt-desktop-notification.jar
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
- Gson - For handling JSON.
- Eclipse Paho MQTT - MQTT client library.
For any questions or suggestions, please open an issue.