Skip to main content

EMQX smart home integration, free and open source

EMQX integration for Gladys Assistant

The health of your EMQX MQTT broker in Gladys: clients, message rates, alarms, outages.

Watches the health of your EMQX MQTT broker in Gladys: connected clients, subscriptions, message rates, dropped messages, alarms in progress, running nodes, uptime and outages, plus the MQTT clients you choose to follow (Zigbee2MQTT, a Shelly, a bridge…).

This integration is not affiliated with EMQ Technologies.

Overview​

Gladys already speaks MQTT: its MQTT integration connects to a broker to drive your devices. It shows nothing about the broker itself. This integration does: every 30 seconds it reads the REST API of EMQX (version 5 or 6) with an API key and turns what EMQX says into Gladys devices, nine scene triggers, a scene action and a dashboard widget.

It only reads: it never publishes a message, never connects as an MQTT client and never changes the configuration of EMQX. Everything stays on your local network.

For an Eclipse Mosquitto broker, install the Mosquitto integration instead: EMQX publishes other statistics.

Requirements​

  • Gladys 5.1 or later.
  • EMQX 5 or 6 (tested with 5.8.6 and 6.3.2), its dashboard port (18083 by default) reachable from Gladys.
  • An API key of EMQX and its secret key.

EMQX 4 is not supported: its API is different.

Create an API key​

  1. Open the EMQX dashboard (http://<address>:18083).
  2. Go to System → API Key, then Create.
  3. Give it a name (for instance gladys). If EMQX offers a role, pick Viewer: read access is enough.
  4. Copy the API Key and the Secret Key: EMQX shows the secret only once.

Configuration​

FieldDescription
Address of EMQXThe address of the dashboard: http://192.168.1.20:18083, or a bare host (port 18083 is added).
API keyThe API Key created above.
Secret keyIts Secret Key.
Accept a self-signed certificateFor an https:// address whose certificate Gladys cannot check.
MQTT clients to followClient ids, separated by commas, 20 at most. Each becomes a device. Leave empty to follow none.
Language of the textsFeature names of the devices when added, scene sentences and messages of the actions (French by default).

The Check the connection button reads EMQX at once and tells its version, its key numbers, its alarms in progress and how many followed clients are connected.

Then open the Discovery tab of the integration and add the broker and the clients you want.

The broker device​

FeatureMeaning
Reachable1 while the API answers, 0 during an outage.
Connected clientsMQTT clients connected right now.
SubscriptionsSubscriptions of all the clients.
TopicsTopics with at least one subscriber.
Messages received (/min)Messages published to the broker, per minute.
Messages sent (/min)Messages delivered to subscribers, per minute.
Messages dropped (/min)Messages EMQX threw away (often: nobody subscribed to the topic), per minute.
Retained messagesMessages kept by the broker for new subscribers.
Active alarmsAlarms of EMQX in progress (memory, CPU, congestion…).
Running nodesNodes of the cluster running (1 for a single broker).
UptimeIn days, since the youngest node started.
VersionVersion of EMQX.

The rates come from EMQX itself, which samples them every 10 seconds. During an outage only Reachable changes: the other values keep their last reading.

Followed clients​

Each client id of the MQTT clients to follow field becomes a device named after it, with two features:

  • Connected: 1 when the client is connected to EMQX, 0 otherwise (including when EMQX no longer knows it).
  • Last connection: date and time of its latest connection, in the time zone of Gladys.

The client ids are listed on the Clients page of the dashboard. Zigbee2MQTT, for instance, uses the client_id of its configuration (mqttjs_… when none is set: give it a fixed one first).

Dashboard widget​

The EMQX broker widget shows the state of the broker, its version, its uptime, the nodes of a cluster, the alarms in progress (up to three by name), and four live tiles: clients, messages received, sent and dropped per minute. Pick the broker in its settings.

Scene triggers​

TriggerWhen
Broker unreachableThe API has not answered for 1, 5, 15, 30 or 60 minutes (your choice).
Broker backThe API answers again after an outage of at least one minute.
Broker restartedThe uptime of a node went back to zero, even without a visible outage.
Alarm raisedEMQX raised an alarm. Variables: alarm name, message, node.
Alarm clearedAn alarm is no longer in progress. Variable: its duration in minutes.
Client disconnectedA followed client is no longer connected.
Client reconnectedA followed client is connected again. Variable: minutes disconnected.
Fewer connected clientsFewer clients than the chosen number for a minute.
Message spikeMore messages received per minute than the chosen number; at most every 30 minutes.

After a restart of the integration, the first reading is a reference: an alarm already in progress or a client already away fires nothing.

Scene action​

Broker summary gives a sentence ready for a message ("EMQX 5.8.6 has been running for 3 days, 12 clients connected, 64 messages received and 87 sent per minute, no alarm.") and its numbers: reachable, connected clients, messages received, sent and dropped per minute, alarms in progress and their names, uptime in hours, version.

Scene ideas​

  • Alarm raised → send yourself a message "EMQX alarm: {{message}} on {{node}}".
  • Client disconnected on Zigbee2MQTT → warn that the Zigbee devices no longer answer.
  • Every morning, Broker summary → send the summary sentence to Telegram.
  • Broker unreachable for 5 minutes → turn a light red.

Troubleshooting​

  • EMQX cannot be reached: check the address and the port (18083 by default, not the MQTT port 1883), and that Gladys reaches it (firewall, Docker network).
  • EMQX refused the API key: check the key and the secret, that the key is enabled and not expired. A key deleted in the dashboard must be created again.
  • No EMQX 5 API at this address: the address points to something else (MQTT port, another service) or to EMQX 4.
  • A client stays disconnected: check its exact client id on the Clients page of the dashboard (it is case-sensitive).
  • More details: set LOG_LEVEL=debug and read the logs of the integration.

Limits​

  • Read every 30 seconds: a disconnection shorter than that may go unnoticed.
  • Rates are averages computed by EMQX over 10 seconds, shown per minute.
  • 20 followed clients at most; a client id containing a space cannot be followed.
  • Only the alarms of EMQX are read, not the rules, bridges or plugins themselves.
  • EMQX 4 is not supported.

Configuration settings​

These are the settings EMQX asks for in its configuration screen in Gladys.

SettingTypeRequiredDescription
Connect EMQXsectionNoThe integration reads the REST API of EMQX 5 or 6 with an API key, every 30 seconds. It never changes anything. Create the key in the dashboard: System → API Key.
Address of EMQXstringYesThe address of the dashboard, port 18083 by default (http:// or https://).
API keystringYesRead access is enough: the Viewer role when EMQX offers one.
Secret keysecretYesShown once by EMQX when the key is created.
Accept a self-signed certificatebooleanNohttps:// only: the certificate of EMQX is then not checked.
MQTT clients to followstringNoClient ids separated by commas, 20 at most: each one becomes a device (connected, last connection). They are listed on the Clients page of the dashboard.
Language of the textsselectNoFeature names of the devices when they are added, scene sentences and action messages.

How to install EMQX in Gladys​

  1. In Gladys, open Integrations: EMQX appears in the catalog, next to the native integrations, with a community badge.
  2. Click Install. Gladys pulls the Docker image (ghcr.io/guim31/gladys-emqx:1.0.0), starts it in a sandbox isolated from the core, and generates the integration's interface (devices, discovery and configuration).
  3. Open the Configuration screen of the integration, fill in the settings, and save.
  4. You can also install it directly from its repository URL: https://github.com/guim31/gladys-emqx.

EMQX requires Gladys >=5.1.0. The catalog inside Gladys refreshes every hour, so a new version becomes available at most one hour after its release.

Not running Gladys yet? It is free and open source: follow the installation guide to get started.

About external integrations​

EMQX is an external integration: a community integration packaged as a Docker container and published on GitHub, that Gladys installs in one click and runs in a sandbox isolated from its core. It is published and maintained by guim31, not by the Gladys core team.

Subscribe to the Gladys Assistant newsletter

A few emails per month about new releases and project news. Sent by Pierre-Gilles Leymarie, founder of the project. Unsubscribe anytime 🙂