Skip to content

MQTT Integration

Document Context

  • Purpose: Comprehensive guide for configuring whatwatt Go MQTT client to publish energy data to MQTT brokers
  • When to use: Setting up home automation, IoT platforms, real-time messaging systems, local data integration without cloud dependencies
  • Prerequisites: Basic MQTT concepts (pub/sub, brokers, topics), MQTT broker setup (Mosquitto, etc.), network connectivity knowledge
  • Related to: MQTT payload templates, reading variables, secure MQTT with TLS, message queuing systems
  • Validates against: MQTT client configuration and message publishing with real energy meter data

Key Facts

  • Configuration endpoint: /api/v1/mqtt/settings (GET, POST, PUT)
  • Connection types: Unencrypted TCP (mqtt://) and encrypted TLS (mqtts://)
  • Authentication: Username/password broker authentication supported
  • Client requirements: Unique client_id per broker, meter connection required for publishing
  • Payload format: Customizable JSON templates with device variables
  • Topic configuration: User-defined MQTT topics for message routing
  • TLS options: Certificate validation with optional CN check skip
  • Publishing trigger: Only publishes when meter is connected and providing data

The device can be connected to an MQTT broker using the built-in MQTT client. The MQTT client supports both unencrypted and encrypted connections.

Note

whatwatt Go will only publish values if a meter is connected.

Configuration Overview

  • Endpoint: /api/v1/mqtt/settings (GET, POST, PUT)
  • Response content type: application/json
  • Full details and field reference: see MQTT Client page.

See: MQTT Client for complete configuration reference and examples.

Authentication

When a Web UI password is set, HTTP endpoints require HTTP authentication.

Firmware 1.10.X and later: Uses HTTP Digest authentication - Server challenges with WWW-Authenticate: Digest … (realm is the device hostname) - Algorithm: MD5-sess (device advertises MD5-sess; integrity variant supported) - qop: auth (and optionally auth-int for requests with body integrity) - Nonce and opaque are issued by the device; the client must include cnonce and increment nc - Expired nonce: server may return 401 with WWW-Authenticate: …, stale=true. In that case, retry the same request once using the new server challenge, a new cnonce, and reset nc=00000001.

Firmware before 1.10.X: Uses HTTP Basic authentication - Server challenges with WWW-Authenticate: Basic realm="..." - Credentials are base64-encoded in Authorization: Basic <encoded-credentials>

Recommended approach: Use --anyauth in curl to automatically detect and use the appropriate method:

curl --anyauth -u ":<password>" http://whatwatt-ABCDEF.local/api/v1/system

Payload Templates

  • Templates define the payload content published to MQTT using predefined variables.
  • See: MQTT Template for the full variable list and examples.

Report Interval

The default MQTT report period is 30s. If the meter reports less frequently, the effective period stretches. You can change this setting via WebUI in System > Interval to Systems.