Integration - MQTT

Introduction

MQTT is used by hobbyist and developers to integrate and extend the functionality of SolarAssistant into their projects.

Enable MQTT output

Navigate to the "Configuration" tab and start MQTT:

Enable MQTT output in SolarAssistant

Determine SolarAssistant local network IP

Also on the "Configuration" tab, determine what it's wlan0 (WiFi) or eth0 (LAN) IP is.

Finding your SolarAssistant local IP

The IP is allocated by your network router and can usually be configured to be static in your router configuration. If your router supports mDNS then SolarAssistant will register the hostname below:

solar-assistant.local

Connect to MQTT

There are various utilities available to consume MQTT messages. In the example below, we will use the mosquitto client.

mosquitto_sub -h 10.0.0.100 -p 1883 -v -t '#'

The result will be a continous stream of MQTT messages. To exit, press ctrl-c.

Running log of SolarAssistant MQTT messages

MQTT Bridge

If you already have an MQTT broker where you would like to consume SolarAssistant messages then you need to set up an MQTT bridge. Using a bridge is considered best practice for reliability and latency as message delivery, network disconnects, etc. is handled by the MQTT brokers.

Below is example mosquitto configuration to use in your existing MQTT broker to pull messages from SolarAssistant. In this example the SolarAssistant IP is 10.0.0.100. A better alternative would be to use solar-assistant.local as described above.

File: /etc/mosquitto/conf.d/solar-assistant.conf

connection SolarAssistant
address 10.0.0.100
topic # in

For an example of how to edit your HomeAssistant MQTT config, see the approach discussed here