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. For Home Assistant users please see our Home Assistant broker with bridge setup guide.

The example mosquitto configuration file below is used in your existing MQTT broker to pull messages from SolarAssistant. Note:

  • address should be the IP address of your SolarAssistant device instead of 10.0.0.100.
  • remote_username and remote_password should be uncommented if you configured MQTT authentication in SolarAssistant.
  • topic in is to pull all messages from SolarAssistant
  • topic out is to push solar setting change messages from your existing broker to SolarAsssistant.

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

connection SolarAssistant
#remote_username solar-assistant
#remote_password solar123
address 10.0.0.100
topic # in
topic solar_assistant/# out

Adjusting solar settings

See the example below for how to set the output source priority of an inverter via MQTT.

mosquitto_pub -h 10.0.0.100 -t 'solar_assistant/inverter_1/output_source_priority/set' -m 'Utility first'

SolarAssistant will post a response back on topic solar_assistant/set/response_message/state. You can view these messages with the command below:

mosquitto_sub -h 10.0.0.100 -v -t '#' | grep response_message

If you want to know which settings you can change via MQTT, please enable HomeAssistant discovery and then use the command below:

mosquitto_sub -h 10.0.0.100 -v -t '#' | grep command_topic

Adjusting solar settings - Examples with Voltronic inverter

Set charger source priority to solar and utility simultaneously:

mosquitto_pub -h 10.0.0.100 -t 'solar_assistant/inverter_1/charger_source_priority/set' -m 'Solar and utility simultaneously'

Set maximum AC charge current to 10A:

mosquitto_pub -h 10.0.0.100 -t 'solar_assistant/inverter_1/max_grid_charge_current/set' -m '10'

Set shutdown battery voltage 47V:

mosquitto_pub -h 10.0.0.100 -t 'solar_assistant/inverter_1/shutdown_battery_voltage/set' -m '47.0'

Adjusting solar settings - Examples with Deye inverter

Set the maximum AC charge current to 20A:

mosquitto_pub -h 10.0.0.100 -t 'solar_assistant/inverter_1/max_grid_charge_current/set' -m '20'

Set the work mode capacity point 1 to 15%:

mosquitto_pub -h 10.0.0.100 -t 'solar_assistant/inverter_1/capacity_point_1/set' -m '15'