Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mqtt2push

Website

mqtt2push is a lightweight Go daemon that subscribes to MQTT topics and forwards incoming messages as push notifications to iOS, Android, and web clients.

Features

  • Subscribe to multiple MQTT topics
  • MQTT wildcard support
  • MQTT QoS 0, 1 and 2
  • Username/password authentication
  • Plain MQTT
  • MQTT over TLS
  • Custom CA certificates
  • Automatic reconnect
  • Automatic re-subscription after reconnect
  • Lightweight standalone binary
  • No inbound ports required
  • iOS and Android push notifications
  • Open source

Installation

Go to /usr/src:

cd /usr/src

Download the current git repository:

git clone git@github.com:signalgridco/mqtt2push.git

cd into the mqtt repo:

cd mqtt2push

Build from source:

go mod tidy
go build -o mqtt2push

Done. Next, you need to configure the config.yml

Configuration

MQTT without TLS

mqtt:
  broker: "mqtt.example.com"
  port: 1883
  topics:
    - "alerts/#"
    - "servers/+/status"
  username: "mqttuser"
  password: "mqttpassword"
  qos: 0
  client_id: "mqtt2push"
  tls:
    enabled: false

signalgrid:
  client_key: "YOUR_CLIENT_KEY"
  channel: "YOUR_CHANNEL"
  type: "INFO"

When TLS is disabled, the connection is made using plain MQTT over TCP. If port is omitted, 1883 is used automatically.

MQTT with TLS

mqtt:
  broker: "mqtt.example.com"
  port: 8883
  topics:
    - "alerts/#"
    - "servers/+/status"
  username: "mqttuser"
  password: "mqttpassword"
  qos: 0
  client_id: "mqtt2push"
  tls:
    enabled: true

signalgrid:
  client_key: "YOUR_CLIENT_KEY"
  channel: "YOUR_CHANNEL"
  type: "INFO"

When TLS is enabled without a custom CA file, mqtt2push uses the operating system's normal trusted CA store. If port is omitted, 8883 is used automatically.

MQTT with TLS and a custom CA

mqtt:
  broker: "mqtt.internal.example"
  port: 8883
  topics:
    - "factory/alarms/#"
  username: "mqttuser"
  password: "mqttpassword"
  qos: 1
  client_id: "mqtt2push"
  tls:
    enabled: true
    ca_file: "/etc/mqtt2push/company-ca.pem"

signalgrid:
  client_key: "YOUR_CLIENT_KEY"
  channel: "YOUR_CHANNEL"
  type: "INFO"

The custom CA certificate is added to the operating system's existing trusted CA store.

Push Delivery

Push notification delivery is provided by Signalgrid.

A Signalgrid account and channel are required to obtain the client_key and channel values used in config.yml.

Once configured, mqtt2push receives MQTT messages from your broker and forwards them to the configured Signalgrid channel for delivery to your devices.

You can create your account here.

Topics

Multiple MQTT subscriptions can be configured:

topics:
  - "factory/alarms/#"
  - "servers/+/status"
  - "network/core/events"

Normal MQTT wildcards are supported.

Notification Mapping

mqtt2push does not interpret or transform the MQTT payload.

The MQTT topic:

factory/line1/alarm

is used as the notification title and displayed as:

factory · line1 · alarm

The MQTT payload:

Motor temperature exceeded 80°C

is used directly as the notification body.

Running

Place config.yml next to the executable:

mqtt2push
config.yml

Start the bridge:

./mqtt2push

Example output:

Connected to MQTT broker mqtt.example.com:1883
Subscribed to alerts/# with QoS 0
Topic: alerts/server1 | Message: Server unavailable | Response: 200 OK

About

A handy MQTT bridge for sending push notifications to iphone / android from subscribed topics

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages