MQTT interface ============== Homebattery can be controlled and monitored over MQTT. Only MQTT v5 is supported. For configuration of MQTT, see the :doc:`configuration page `. General messages ---------------- ```` is the MQTT topic root set in the configuration. +------------------------------------+------------+-----------+---------------------------------------------------------------------------+ | Topic | Datatype | Direction | Description | +====================================+============+===========+===========================================================================+ | ``/mode/set`` | ``utf-8`` | W | Requested operation mode. | | | | | | | | | | Possible values are ``charge``, ``discharge``, ``idle`` and ``protect``. | +------------------------------------+------------+-----------+---------------------------------------------------------------------------+ | ``/mode/actual`` | ``utf-8`` | R | Current operation mode. | | | | | | | | | | Possible values are ``charge``, ``discharge``, ``idle`` and ``protect``. | +------------------------------------+------------+-----------+---------------------------------------------------------------------------+ | ``/locked`` | ``utf-8`` | R | Reason for system lock. Payload is JSON and contains a list of all locks. | | | | | | | | | | An empty list means that there is no lock. | +------------------------------------+------------+-----------+---------------------------------------------------------------------------+ | ``/reset`` | ``utf-8`` | W | Writing the value ``reset`` to this topic will lead to a system reset. | +------------------------------------+------------+-----------+---------------------------------------------------------------------------+ Device class data ----------------- For all device classes, two types of messages are sent: * ``sum`` messages, containing aggregated measurement data of a whole device class * ``dev`` messages, containing measurement data of a specific device The device class ``sensor`` does not send ``sum`` messages. All messages use a JSON payload: .. code-block:: json { "capacity": "", "current": "", "energy": "", "power": "", "status": "", "voltage": "" } The content of a message may vary, not all measurands are present in every message. ``energy`` contains the energy since the last message containing an ``energy`` value, which means to get the energy of a longer period, the values of the ``energy`` messages need to be accumulated. All other measurands contain the average value since the last message with the same measurand. A measurand is sent with a minimum interval of ~ 6s when a value changed. In addition to that, it is sent every ~ 300s, even if no value changed. The device class ``battery`` sends messages every time the battery data is read, no matter whether a value changed or not. Battery dev messages ~~~~~~~~~~~~~~~~~~~~ ``battery`` ``dev`` messages use a different payload format: .. code-block:: json { "v": "", "i": "", "soc": "", "c": "", "c_full": "", "n": "", "temps": "", "cells": "" } Measurands are not sent if they are not supported by the battery. Device class messages --------------------- ```` is the MQTT topic root set in the configuration. ```` is the device name set in the configuration. +------------------------------------+------------+-----------+-------------------------------------------------------------------------------+ | Topic | Datatype | Direction | Description | +====================================+============+===========+===============================================================================+ | ``/cha/sum`` | ``utf-8`` | R | ``sum`` message of the ``charger`` device class. | +------------------------------------+------------+-----------+-------------------------------------------------------------------------------+ | ``/cha/dev/`` | ``utf-8`` | R | ``dev`` message of a ``charger`` device. | +------------------------------------+------------+-----------+-------------------------------------------------------------------------------+ | ``/hea/sum`` | ``utf-8`` | R | ``sum`` message of the ``heater`` device class. | +------------------------------------+------------+-----------+-------------------------------------------------------------------------------+ | ``/hea/dev/`` | ``utf-8`` | R | ``dev`` message of a ``heater`` device. | +------------------------------------+------------+-----------+-------------------------------------------------------------------------------+ | ``/inv/sum`` | ``utf-8`` | R | ``sum`` message of the ``inverter`` device class. | +------------------------------------+------------+-----------+-------------------------------------------------------------------------------+ | ``/inv/dev/`` | ``utf-8`` | R | ``dev`` message of a ``inverter`` device. | +------------------------------------+------------+-----------+-------------------------------------------------------------------------------+ | ``/sol/sum`` | ``utf-8`` | R | ``sum`` message of the ``solar`` device class. | +------------------------------------+------------+-----------+-------------------------------------------------------------------------------+ | ``/sol/dev/`` | ``utf-8`` | R | ``dev`` message of a ``solar`` device. | +------------------------------------+------------+-----------+-------------------------------------------------------------------------------+ | ``/bat/sum`` | ``utf-8`` | R | ``sum`` message of the ``battery`` device class. | +------------------------------------+------------+-----------+-------------------------------------------------------------------------------+ | ``/bat/dev/`` | ``utf-8`` | R | ``dev`` message of a ``battery`` device. | +------------------------------------+------------+-----------+-------------------------------------------------------------------------------+ | ``/sen/dev/`` | ``utf-8`` | R | ``dev`` message of a ``sensor`` device. | +------------------------------------+------------+-----------+-------------------------------------------------------------------------------+