Skip to content

Instantly share code, notes, and snippets.

@vladyspavlov
Last active December 10, 2025 09:16
Show Gist options
  • Select an option

  • Save vladyspavlov/5ac21cb58923482eff8e7bbb2d0854b3 to your computer and use it in GitHub Desktop.

Select an option

Save vladyspavlov/5ac21cb58923482eff8e7bbb2d0854b3 to your computer and use it in GitHub Desktop.
Must inverter ESPHome configuration for ESP32. More info and the latest version of the config are now in the repo: https://github.com/vladyspavlov/esphome-must-inverter
# More info and the latest version of the config are now in the repo: https://github.com/vladyspavlov/esphome-must-inverter
substitutions:
inverter_id: inverter
updates: 5s
api_key: xxx
ota_password: xxx
esphome:
name: inverter-monitor
comment: "Inverter monitor"
esp32:
board: esp32dev
framework:
type: esp-idf
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
logger:
level: DEBUG
api:
encryption:
key: ${api_key}
ota:
password: ${ota_password}
uart:
- id: uart_inverter
baud_rate: 19200
tx_pin: GPIO19
rx_pin: GPIO18
stop_bits: 1
parity: NONE
data_bits: 8
debug:
direction: BOTH
dummy_receiver: false
modbus:
- id: modbus_inverter
uart_id: uart_inverter
send_wait_time: 200ms
modbus_controller:
- id: must_inverter
address: 0x04
modbus_id: modbus_inverter
command_throttle: 200ms
setup_priority: -10
update_interval: ${updates}
sensor:
# charger sensors
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15201
name: "PV Charger Workstate"
register_type: holding
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15202
name: "PV Charger MPPT state"
register_type: holding
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15203
name: "PV Charger Charging state"
register_type: holding
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15205
name: "PV Charger Voltage"
register_type: holding
unit_of_measurement: "V"
accuracy_decimals: 1
icon: mdi:sine-wave
filters:
multiply: 0.1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15206
name: "PV Charger Battery voltage"
register_type: holding
unit_of_measurement: "V"
accuracy_decimals: 1
icon: mdi:sine-wave
filters:
multiply: 0.1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15207
name: "PV Charger Current"
register_type: holding
unit_of_measurement: "A"
accuracy_decimals: 1
icon: mdi:current-dc
filters:
multiply: 0.1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15208
register_type: holding
name: "PV Charger power"
unit_of_measurement: "W"
accuracy_decimals: 1
icon: mdi:flash
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15209
register_type: holding
name: "PV Charger Radiator temp"
unit_of_measurement: "°C"
accuracy_decimals: 1
icon: mdi:temperature-celsius
# - platform: modbus_controller
# modbus_controller_id: must_inverter
# address: 15210
# register_type: holding
# name: "PV Charger External temp"
# unit_of_measurement: "°C"
# accuracy_decimals: 1
# icon: mdi:temperature-celsius
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15212
register_type: holding
name: "PV Relay"
icon: mdi:electric-switch
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15217
register_type: holding
id: charger_total_mwh
internal: true
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15218
register_type: holding
id: charger_total_kwh
internal: true
filters:
multiply: 0.1
- platform: template
name: "PV Charger Accumulated charger power"
unit_of_measurement: kWh
lambda: !lambda 'return (id(charger_total_mwh).state * 1000.0 + id(charger_total_kwh).state );'
accuracy_decimals: 1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15219
register_type: holding
name: "PV Charger Accumulated day"
unit_of_measurement: "W"
accuracy_decimals: 1
icon: mdi:flash
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15220
register_type: holding
name: "PV Charger Accumulated hour"
unit_of_measurement: "W"
accuracy_decimals: 1
icon: mdi:flash
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 15221
register_type: holding
name: "PV Charger Accumulated minute"
unit_of_measurement: "W"
accuracy_decimals: 1
icon: mdi:flash
# inverter sensors
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25201
register_type: holding
name: "Inverter Work state"
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25205
name: "Inverter Battery Voltage"
register_type: holding
unit_of_measurement: "V"
accuracy_decimals: 1
icon: mdi:sine-wave
filters:
multiply: 0.1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25206
name: "Inverter Voltage"
register_type: holding
unit_of_measurement: "V"
accuracy_decimals: 1
icon: mdi:sine-wave
filters:
multiply: 0.1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25207
name: "Inverter Grid voltage"
register_type: holding
unit_of_measurement: "V"
accuracy_decimals: 1
icon: mdi:sine-wave
filters:
multiply: 0.1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25207
name: "Inverter Grid voltage"
register_type: holding
unit_of_measurement: "V"
accuracy_decimals: 1
icon: mdi:sine-wave
filters:
multiply: 0.1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25208
name: "Inverter BUS Voltage"
register_type: holding
unit_of_measurement: "V"
accuracy_decimals: 1
icon: mdi:sine-wave
filters:
multiply: 0.1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25209
name: "Inverter Control current"
register_type: holding
unit_of_measurement: "A"
accuracy_decimals: 1
icon: mdi:current-dc
filters:
multiply: 0.1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25210
name: "Inverter Current"
register_type: holding
unit_of_measurement: "A"
accuracy_decimals: 1
icon: mdi:current-dc
filters:
multiply: 0.1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25211
name: "Inverter Grid current"
register_type: holding
unit_of_measurement: "A"
accuracy_decimals: 1
icon: mdi:current-ac
filters:
multiply: 0.1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25212
name: "Inverter Load current"
register_type: holding
unit_of_measurement: "A"
accuracy_decimals: 1
icon: mdi:current-ac
filters:
multiply: 0.1
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25213
name: "Inverter Power"
register_type: holding
unit_of_measurement: "W"
accuracy_decimals: 1
icon: mdi:flash
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25214
name: "Inverter Grid power"
register_type: holding
unit_of_measurement: "W"
accuracy_decimals: 1
value_type: S_WORD
icon: mdi:flash
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25215
name: "Inverter Load power"
register_type: holding
unit_of_measurement: "W"
accuracy_decimals: 1
icon: mdi:flash
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25216
name: "Inverter System load"
register_type: holding
unit_of_measurement: "%"
accuracy_decimals: 1
icon: mdi:flash
# MOST INFO
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25233
register_type: holding
name: "Inverter AC radiator temp"
accuracy_decimals: 1
unit_of_measurement: "°C"
icon: mdi:temperature-celsius
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25234
register_type: holding
name: "Inverter Transformer temp"
unit_of_measurement: "°C"
accuracy_decimals: 1
icon: mdi:temperature-celsius
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25235
register_type: holding
name: "Inverter DC Radiator temp"
unit_of_measurement: "°C"
accuracy_decimals: 1
icon: mdi:temperature-celsius
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25237
register_type: holding
name: "Inverter Relay state"
icon: mdi:electric-switch
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25238
register_type: holding
name: "Inverter Relay state Grid"
icon: mdi:electric-switch
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25239
register_type: holding
name: "Inverter Relay state Load"
icon: mdi:electric-switch
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25240
register_type: holding
name: "Inverter Relay state NLine"
icon: mdi:electric-switch
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25241
register_type: holding
name: "Inverter Relay state DC"
icon: mdi:electric-switch
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25242
register_type: holding
name: "Inverter Relay state Earth"
icon: mdi:electric-switch
# Inverter Accumulated discharge power
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25247
register_type: holding
id: discharger_total_mwh
internal: true
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25248
register_type: holding
id: discharger_total_kwh
internal: true
filters:
multiply: 0.1
- platform: template
name: "Accumulated discharger power"
unit_of_measurement: kWh
accuracy_decimals: 1
lambda: !lambda 'return (id(discharger_total_mwh).state * 1000.0 + id(discharger_total_kwh).state);'
# Inverter Accumulated buy power
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25249
register_type: holding
id: buy_mwh
internal: true
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25250
register_type: holding
id: buy_kwh
internal: true
filters:
multiply: 0.1
- platform: template
name: "Accumulated buy power"
unit_of_measurement: kWh
lambda: |-
return (id(buy_mwh).state * 1000.0 + id(buy_kwh).state);
accuracy_decimals: 1
# Inverter Accumulated sell power
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25251
register_type: holding
id: sell_mwh
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25252
register_type: holding
id: sell_kwh
filters:
multiply: 0.1
- platform: template
name: "Accumulated sell power"
unit_of_measurement: kWh
accuracy_decimals: 1
lambda: !lambda return (id(sell_mwh).state * 1000.0 + id(sell_kwh).state);
# Inverter Accumulated load power
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25253
register_type: holding
id: load_mwh
internal: True
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25254
register_type: holding
id: load_kwh
internal: True
filters:
multiply: 0.1
- platform: template
name: "Accumulated load power"
unit_of_measurement: kWh
accuracy_decimals: 1
lambda: !lambda return (id(load_mwh).state * 1000.0 + id(load_kwh).state);
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25273
register_type: holding
value_type: S_WORD
name: "Inverter Battery power"
unit_of_measurement: "W"
accuracy_decimals: 1
icon: mdi:flash
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25274
register_type: holding
value_type: S_WORD
name: "Inverter Battery current"
unit_of_measurement: "A"
accuracy_decimals: 1
icon: mdi:current-dc
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25275
register_type: holding
value_type: S_WORD
name: "Inverter Battery grade"
unit_of_measurement: "V"
icon: mdi:alpha-V
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 25277
register_type: holding
name: "Inverter Rated power"
unit_of_measurement: "W"
accuracy_decimals: 1
icon: mdi:flash
select:
- platform: modbus_controller
modbus_controller_id: must_inverter
id: energy_use_mode
name: "Inverter Energy use mode (parameter 00)"
address: 20109
optionsmap:
"SBU (Solar/battery/utility)": 1
"SUB (Solar/utility/battery)": 2
"UTI (Utility only)": 3
"SOL (Solar only)": 4
- platform: modbus_controller
modbus_controller_id: must_inverter
id: charger_source_priority
name: "Inverter Charger source priority (parameter 10)"
address: 20143
optionsmap:
"CSO (Solar first)": 0
"SNU (Solar and utility)": 2
"OSO (Solar only)": 3
- platform: modbus_controller
modbus_controller_id: must_inverter
address: 20111
id: inverter_ac_input_voltage_range
name: "Inverter AC input voltage range (02)"
optionsmap:
"VDE (184-253VAC)": 0
"UPS (170-280VAC)": 1
"APL (90-280VAC)": 2
"GEN (Generator)": 3
number:
- platform: modbus_controller
id: batt_float_voltage
name: "PV Charger Float voltage"
unit_of_measurement: "V"
address: 10103
value_type: U_WORD
multiply: 10
- platform: modbus_controller
id: batt_absorb_voltage
name: "PV Charger Absorb voltage"
unit_of_measurement: "V"
address: 10104
value_type: U_WORD
multiply: 10
- platform: modbus_controller
id: batt_stop_dischg
name: "Inverter Battery stop discharging voltage"
unit_of_measurement: "V"
address: 20118
value_type: U_WORD
lambda: "return x * 0.1; "
write_lambda: |-
return x * 10 ;
- platform: modbus_controller
id: batt_stop_chg
name: "Inverter Battery stop charging voltage"
unit_of_measurement: "V"
address: 20119
value_type: U_WORD
multiply: 10
- platform: modbus_controller
id: batt_low_voltage
name: "Inverter Battery low voltage"
unit_of_measurement: "V"
address: 20127
value_type: U_WORD
multiply: 10
- platform: modbus_controller
id: batt_high_voltage
name: "Inverter Battery high voltage"
unit_of_measurement: "V"
address: 20128
value_type: U_WORD
multiply: 10
- platform: modbus_controller
id: solar_charger_current
name: "Inverter Charger current"
unit_of_measurement: "A"
address: 20132
value_type: U_WORD
multiply: 10
@andreibut
Copy link

добавить нечего , все есть.
может кому надо

text_sensor:

  • platform: modbus_controller
    modbus_controller_id: d
    id: Charger_workstate_d
    name: "Charger workstate"
    address: 15201
    register_type: holding
    raw_encode: HEXBYTES
    lambda: |-
    uint16_t value = modbus_controller::word_from_hex_str(x, 0);
    switch (value) {
    case 0: return std::string("Initialization Mode");
    case 1: return std::string("Selftest Mode");
    case 2: return std::string("Work Mode");
    case 3: return std::string("Stop Mode");
    default: return std::string("Unknown");
    }
    return x;

@Jugheadbomb
Copy link

Hello! Sorry for offtop, I'm not using ESPHome, just trying to get values from PV18 inverter using arduino UNO (with ESP8266 onboard), MAX RS485 to TTL adapter, but i'm unable to get it to work. I'm using ModbusMaster library, anytime I try to read registers, it throws Modbus error: 226 (which means Timeout). Help please. Much appreciated.

#include <SoftwareSerial.h>
#include <ModbusMaster.h>

#define RS485_DIR 4  // DE, RE

SoftwareSerial rs485(2, 3);  // RX, TX (RO, DI)
ModbusMaster node;

void preTransmission()
{
  digitalWrite(RS485_DIR, HIGH); // Sending mode
}

void postTransmission()
{
  digitalWrite(RS485_DIR, LOW); // Receiving mode
}

void setup()
{
  Serial.begin(9600);
  rs485.begin(9600); // Modbus baud

  pinMode(RS485_DIR, OUTPUT);
  digitalWrite(RS485_DIR, LOW);

  node.begin(1, rs485); // slave ID = 1?
  node.preTransmission(preTransmission);
  node.postTransmission(postTransmission);

  Serial.println("Starting Modbus polling...");
  delay(1000);
}

void loop()
{
  // 15206: PV Voltage, 15207: PV Current, 15208: Battery Voltage
  uint8_t result = node.readHoldingRegisters(15206, 3); // 1 arg - register, 2 arg - count
  if (result == node.ku8MBSuccess)
  {
    float pvVoltage = node.getResponseBuffer(0) * 0.1;
    float pvCurrent = node.getResponseBuffer(1) * 0.1;
    float battVoltage = node.getResponseBuffer(2) * 0.1;

    Serial.print("PV Voltage: ");
    Serial.print(pvVoltage);
    Serial.print(" V | PV Current: ");
    Serial.print(pvCurrent);
    Serial.print(" A | Battery Voltage: ");
    Serial.print(battVoltage);
    Serial.println(" V");
  }
  else
  {
    Serial.print("Modbus error: ");
    Serial.println(result);
  }

  delay(2000);
}

Connection scheme
image

@1Nikolay
Copy link

1Nikolay commented Nov 14, 2025 via email

@XSweetHub
Copy link

0-02-05-adae623044369358265d3da65b19f31b7b89411cae821c2761ecfc7f62c40f95_5b87c128cad98e6f 0-02-05-353a346a88e272331199bdc4a50fc86bbb978beb628717d66d019c2233588c24_c3f01963ba06ca4a Тимчасовий варіант)))

0-02-05-adae623044369358265d3da65b19f31b7b89411cae821c2761ecfc7f62c40f95_5b87c128cad98e6f 0-02-05-353a346a88e272331199bdc4a50fc86bbb978beb628717d66d019c2233588c24_c3f01963ba06ca4a Тимчасовий варіант)))

Зробив таку смеху точно, але чомусь сенсори не читає з інвертора, немає данних ніяких. В Чому проблема може бути ?

@andreibut
Copy link

andreibut commented Dec 10, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment