Skip to content

MQTT topics

Stefan Allius edited this page Dec 24, 2024 · 21 revisions

MQTT Topics

The proxy is an MQTT client and publishes all measured values and data from all connected inverters to an MQTT broker. MQTT clients that want to receive the data must subscribe for the corresponding MQTT topics. The MQTT topics described below are used for this purpose.

The topics are structured for easy filtering. All topics that are sent to an MQTT broker must be unique so that they can be correctly assigned and filtered. If there are conflicts with other MQTT-clients, the topic levels of the proxy can be changed in config.toml.

Typical topics of the proxy looks like:

  • tsun/inv_1/controller
  • tsun/inv_1/inverter
  • tsun/inv_2/input

The parts tsun and ìnv_1 or ìnv_2 can be configured in the config.toml. The first one is common for all topics of the proxy. Its value comes from the configuration item ha.entity_prefix. The second topic level (here 'inv_1' or 'inv_2') is used to distinguish the individual inverters and is referred to as node_id. The value of node_id is determined for each inverter by an assignment serialnumber -> node_id in config.toml:

[inverters."Y170000000000001"]
monitor_sn = 2000000000       # The "Monitoring SN:" can be found on a sticker enclosed with the inverter
node_id = 'inv_1'                 # Optional, MQTT replacement for inverters serial number  

[inverters."R17xxxxxxxxxxxx2"]
node_id = 'inv_2'                 # Optional, MQTT replacement for inverters 

For proxy data, the second part of the topics is defined by ha.proxy_node_id, as these values are inverter-independent.

The data itself is delivered as a json object

Proxy

The proxy publishes internal counters on:

  • <ha.entity_prefix>/<ha.proxy_node_id>/proxy

as a json payload with the following instances:

Instance Type Description
"Inverter_Cnt" number Number of inverters that have an active connection to the proxy
"Unknown_SNR" number Number of received messages with an unknown serial number. Please check your config.toml
"Unknown_Msg" number Number of received messages with an unknown message id
"Invalid_Data_Type" number GEN3: Number of received messages with an invalid data type. Please contact the maintainer
"Internal_Error" number Number of error in internal definition tables. Please contact the maintainer
"Unknown_Ctrl" number GEN3: Number of received messages with an invalid control byte. Please contact the maintainer
"OTA_Start_Msg" number GEN3: Number of received Over The Air start commands
"SW_Exception" number Number of software exceptions
"Invalid_Msg_Format" number GEN3PLUS: Number of received message with invalid startbyte, stopbyte or wrong checksum (also MODBUS crc-error)
"AT_Command" number GEN3PLUS: Number of received AT commands from the cloud
"AT_Command_Blocked" number GEN3PLUS: Number of dropped AT commands from the cloud
"Modbus_Command" number Number of received Modbus commands from the cloud

Example proxy payload

{
    "Inverter_Cnt": 1,
    "Unknown_SNR": 3,
    "Unknown_Msg": 0,
    "Invalid_Data_Type": 0,
    "Internal_Error": 0,
    "Unknown_Ctrl": 0,
    "OTA_Start_Msg": 2,
    "SW_Exception": 0,
    "Invalid_Msg_Format": 0,
    "AT_Command": 0,
    "AT_Command_Blocked": 0,
    "Modbus_Command": 0
}

Controller

The proxy publishes data about the collector/communication module on:

  • <ha.entity_prefix>/<node_id>/collector

as a json payload with the following instances:

Instance Type Unit Description
"Collector_Fw_Version" string - Received signal strength
"Chip_Type" string - Manufactorer of the communication module/chip
"Chip_Model" string - Name of the communication module/chip
"Trace_URL" string -
"Logger_URL" string -

Examples collector payloads

GEN3PLUS payload:

{
    "Chip_Type": "IGEN TECH",
    "Chip_Model": "LSW5BLE_17_02B0_1.05",
    "Collector_Fw_Version": "V1.1.00.0B"
}

GEN3 payload:

{
    "Collector_Fw_Version": "RSW_400_V1.00.06",
    "Chip_Type": "Raymon",
    "Chip_Model": "RSW-1-10001",
    "Trace_URL": "t.raymoniot.com",
    "Logger_URL": "logger.talent-monitoring.com"
}

The proxy publishes controller data on:

  • <ha.entity_prefix>/<node_id>/controller

as a json payload with the following instances:

Instance Type Unit Description
"Signal_Strength" number % Received signal strength
"Power_On_Time" number ?
"Collect_Interval" number min fixed value
"Connect_Count" number -
"Communication_Type" number - Type of wireless module
0: n/a
1: Wi-Fi
2: G4
3: G5
4: GPRS
"Data_Up_Interval" number s The data up interval, defines the cadence with data coming/requesting from the inverter
"Heartbeat_Interval" number s Heartbeat interval (GEN3PLUS only)
"IP_Address" string - IP address of the communication module

Examples controller payloads

GEN3PLUS payload:

{
    "Data_Up_Interval": 300,
    "Collect_Interval": 1,
    "Heartbeat_Interval": 120,
    "Signal_Strength": 37,
    "IP_Adress": "192.168.80.49",
    "Power_On_Time": 4568
}

GEN3 payload:

{
    "Collect_Interval": 1,
    "Signal_Strength": 94,
    "Power_On_Time": 18051,
    "Communication_Type": 1,
    "Connect_Count": 1,
    "Data_Up_Interval": 300
}

Inverter

The proxy publishes inverter data on:

  • <ha.entity_prefix>/<node_id>/inverter

as a json payload with the following instances:

Instance Type Unit Description
"Product_Name" string - Product series (GEN3 only)
"Manufacturer" string - Device manufacturer
"Version" string - Software version of the inverter (DSP)
"Serial_Number" string - Serialnumber of the device
"Equipment_Model" string - Trade name of the inverter
"No_Inputs" number - Number of physical inputs
"Max_Designed_Power" number W Maximul output power in unthrottled operation
"Rated_Power" number W Throttled output power of the inverter
"Output_Coefficient" number % Output factor in percent for further limiting the Rated Power
"PV<1..6>_Manufacturer" string - PV module manufacturer for input <1..6>. Value comes from the config.toml configuration
"PV<1..6>_Model" string - PV module model for input <1..6>. Value comes from the config.toml configuration

Examples inverter payloads

GEN3PLUS payload:

{
    "Manufacturer": "TSUN",
    "Equipment_Model": "TSOL-MS2000(600)",
    "PV1_Manufacturer": "Risen",
    "PV1_Model": "RSM40-8-410M",
    "PV2_Manufacturer": "Risen",
    "PV2_Model": "RSM40-8-410M",
    "PV3_Manufacturer": "Risen",
    "PV3_Model": "RSM40-8-405M",
    "Serial_Number": "Y17E1234567890AB",
    "Version": "v4.0.10",
    "Rated_Power": 600,
    "Max_Designed_Power": 2000,
    "No_Inputs": 4
}

GEN3 payload:

{
    "Product_Name": "Microinv",
    "Manufacturer": "TSUN",
    "Version": "V5.0.11",
    "Serial_Number": "T17E1234567890AB",
    "Equipment_Model": "TSOL-MS600"
}

Inverter DC Inputs

The proxy published measured values from the MPTT trackers (inputs) on:

  • <ha.entity_prefix>/<node_id>/input

as a json payload with named object "pv<1..6>" each with following instances:

Instance Type Unit Description
"Voltage" number V Voltage at the input
"Current" number A Current of the input
"Power" number W Input power
"Timestamp" number s Unix epoche; see www.epochconverter.com
"Daily_Generation" number kWh Daily energy generation of the input. Will be reset daily at midnight
"Total_Generation" number kWh Total energy generation of the input

Example input payload

{
    "pv1": {
        "Voltage": 31.9,
        "Current": 0.23,
        "Power": 7.7,
        "Daily_Generation": 0.44,
        "Total_Generation": 28.32
    },
    "pv2": {
        "Voltage": 32.4,
        "Current": 0.2,
        "Power": 6.7,
        "Daily_Generation": 0.38,
        "Total_Generation": 25.75
    },
    "pv3": {
        "Voltage": 32.5,
        "Current": 0.24,
        "Power": 8.2,
        "Daily_Generation": 0.48,
        "Total_Generation": 29.34
    },
    "pv4": {
        "Voltage": 1.8,
        "Current": 0.01,
        "Power": 0,
        "Total_Generation": 15.58
    }
}

Power Grid

The proxy published measured values from grid on:

  • <ha.entity_prefix>/<node_id>/total

as a json payload with the following instances:

Instance Type Unit Description
"Daily_Generation" number kWh Daily energy generation of the inverter. Will be reset daily at midnight
"Timestamp" number s Unix epoche; see www.epochconverter.com
"Total_Generation" number kWh Total energy generation of the inverter

Example total payload

{
    "Daily_Generation": 1.24,
    "Total_Generation": 94.53
}

The proxy published measured values from grid on:

  • <ha.entity_prefix>/<node_id>/grid

as a json payload with the following instances:

Instance Type Unit Description
"Voltage" number V Grid voltage at the inverter
"Current" number A Output Current of the inverter
"Frequency" number Hz Grid frequenz
"Timestamp" number s Unix epoche; see www.epochconverter.com
"Output_Power" number W Output power of the inverter

Example grid payload

{
    "Voltage": 226.4,
    "Current": 0.09,
    "Frequency": 49.96,
    "Output_Power": 21.6
}

General

The proxy published the inverter status on:

  • <ha.entity_prefix>/<node_id>/env

as a json payload with the following instances:

Instance Type Unit Description
"Inverter_Status" number - GEN3Plus:
0: off-line
1: on-grid
2: off-grid
"Inverter_Temp" number °C Temperature of the inverter
{
    "Inverter_Status": 1,
    "Inverter_Temp": 13
}

Inverter Rated Load

The proxy listens on:

<ha.entity_prefix>/<node_id>/rated_load

and expects a payload of an integer. This payload value indicates the maximum rated load of the inverter. The rated load cannot be set as required, but can only be set to predefined values that depend on the type of inverter. The mapping for some inverters is listed in the following table:

Payload Description TSOL-MS600 (SN:R17E) TSOL-MS2000 (SN:Y17) TSOL-MS2000(600) (SN:Y47)
0 rated level 0 800W 1600W 1600W
1 rated level 1 700W 1500W 1500W
2 rated level 2 600W 800W 1200W
3 rated level 3 300W 600W 600W
4 rated level 4 -- 2000W 2000W
5 rated level 5 -- 1800W 1800W
6 rated level 6 -- -- 800W

Caution: setting incorrect values can lead to internal errors, which may require the inverter to be restarted.

❗Attention: Setting higher values is subject to legal conditions. These must be observed by the operator. It must also be ensured that the electrical installation is suitable for the set power. An inspection by a qualified electrician is strongly recommended.

Inverter Output Coefficient

The proxy listen on:

<ha.entity_prefix>/<node_id>/out_coeff

and expects a payload in the form of a float value in the range from 0.0 to 100.0. This payload value specifies the output factor in percent with which the maximum nominal load of the inverter can be further throttled. The maximum output power is thus calculated by multiplying the 'Rated Power' by the 'out_coeff':

Rated Power out_coeff Max Output
600W 33.4% 200W
600W 50.0% 300W
2000W 70.0% 1400W

As the self-consumption of the inverter remains constant and is deducted from the output power, the real output power is always slightly below the calculated power. You should adjust the factor to compensate for this.

❗Attention: This value is permanently stored in the inverter flash and is therefore not suitable for control tasks. Very frequent writing can destroy the inverter.

MODBUS Register

The proxy listens on:

<ha.entity_prefix>/<node_id>/modbus_read_regs

and expects a payload of two integers separated by a comma. The first is the MODBUS start register and the second is the number of registers to be read.

Payload Description
0x300e, 1 read the register at 0x3003
0x2000, 12 read the register from 0x2000 to 0x200b

The read values are saved in the proxy's internal database. If a register has changed its value, the new value is published with the corresponding MODBUS topic.

I have compiled an overview of the MODBUS registers here

Example trace MODBUS read registers

Nachricht 20 empfangen auf tsun/inv_2/modbus_read_regs um 18:37:
0x3008, 16

Nachricht 21 empfangen auf tsun/inv_2/grid um 18:37:
{
    "Voltage": 229.1,
    "Current": 0.62,
    "Frequency": 50,
    "Output_Power": 142.6
}

Nachricht 22 empfangen auf tsun/inv_2/input um 18:37:
{
    "pv1": {
        "Voltage": 33.4,
        "Current": 1.5,
        "Power": 50.3,
        "Daily_Generation": 0.59,
        "Total_Generation": 94.84
    },
    "pv2": {
        "Voltage": 33.7,
        "Current": 1.35,
        "Power": 45.8,
        "Daily_Generation": 0.51,
        "Total_Generation": 84.59
    },
    "pv3": {
        "Voltage": 33.5,
        "Current": 1.58,
        "Power": 53.3,
        "Daily_Generation": 0.63,
        "Total_Generation": 99.33
    },
    "pv4": {
        "Voltage": 1.8,
        "Current": 0.01,
        "Power": 0,
        "Total_Generation": 15.58
    }
}

AT+ Commands (GEN3PLUS only)

The proxy listens on:

<ha.entity_prefix>/<node_id>/at_cmd

and expects a string with the AT+ command as payload. The character string should not contain a trailing \r. The proxy publishes the result on:

  • <ha.entity_prefix>/<node_id>/at_resp

I have compiled an overview of the possible AT+ commands here

Example trace of AT+ command

Example for an allowed and supportet command:

Nachricht 0 empfangen auf tsun/inv_2/at_cmd um 18:31:
AT+WANN

Nachricht 1 empfangen auf tsun/inv_2/at_resp um 18:31:
+ok=DHCP,192.168.80.49,255.255.255.192,192.168.80.1

Example for a valid command which is blocked by the configuration (config.toml file):

Nachricht 23 empfangen auf tsun/inv_2/at_cmd um 20:05:
AT+WEBU

Nachricht 24 empfangen auf tsun/inv_2/at_resp um 20:05:
'AT+WEBU' is forbidden