ESPHome modbus Growatt ShineWiFi-S

hey @candidotsa @nikiyahoo , got it working after trying multiple versions of HA and but however i don’t think it is related to HA,
1st i’d advise you to turn of the inverter completely and power off ur house, then let the inverter boot up and then turn on the d1,
logs attached:

log

here’s my test code:
i’m using Home Assistant 2023.9.0b4
Supervisor 2023.09.0.dev0102
Frontend 20230904.0 - latest
esphome dev addon

esphome:
  name: esp-5k
#  libraries:
#    - uart=https://github.com/plerup/espsoftwareserial.git#8.0.1
# Enable logging

esp8266:
  board: d1_mini

logger:
  level: DEBUG
  baud_rate: 0
# Enable Home Assistant API
api:
  encryption:
    key: "WEpwXy3Sh8tO5Nj+ebZwsISIMNAvUIiiNwtaRwJKPlw="

ota:
  password: "e1157d54ed3035ececb22b71db94c3ed"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
      static_ip: 10.0.0.36
      gateway: 10.0.0.1
      subnet: 255.255.255.0
      dns1: 10.0.0.1
      dns2: 8.8.8.8
web_server:
  port: 80
  include_internal: true  

uart:
  id: uart_modbus
  tx_pin: 1
  rx_pin: 3
  baud_rate: 9600
  #stop_bits: 2
 
modbus:
  id: modbus1
  uart_id: uart_modbus
  flow_control_pin: GPIO4
    
modbus_controller:
  - id: growatt
    address: 0x1
    modbus_id: modbus1
    update_interval: 15s
    setup_priority: -10    

button:
  - platform: restart
    name: "esp-5k Restart"

text_sensor:
  - platform: template
    name: "Growatt Status"
    icon: mdi:eye
    entity_category: diagnostic
    lambda: |-
      if ((id(status).state) == 1) {
          return {"Normal"};
        } else if ((id(status).state) == 0)  {
          return {"Standby"};
        } else if ((id(status).state) == 2)  {
          return {"Discharge"};
        } else if ((id(status).state) == 3)  {
          return {"Fault"};
        } else if ((id(status).state) == 4)  {
          return {"Flash"};
        } else if ((id(status).state) == 5)  {
          return {"PV Charging"};
        } else if ((id(status).state) == 6)  {
          return {"AC Charging"};
        } else if ((id(status).state) == 7)  {
          return {"Combined Charging"};
        } else if ((id(status).state) == 8)  {
          return {"Combined Charging & Bypass"};
        } else if ((id(status).state) == 9)  {
          return {"PV Charging & Bypass"};
        } else if ((id(status).state) == 10)  {
          return {"AC Charging & Bypass"};
        } else if ((id(status).state) == 11)  {
          return {"Bypass"};
        } else if (id(status).state == 12)  {
          return {"PV Charge and Discharge"};
        } else {
          return {"Unknown"};
        }

sensor:

  - platform: modbus_controller
    address: 0
    register_type: read
    internal: true
    accuracy_decimals: 0
    value_type: U_WORD
    id: status

  - platform: wifi_signal
    name: "WiFi Signal Sensor"
    update_interval: 60s

# Temperatures Monitors

  - platform: modbus_controller
    id: invtemp
    modbus_controller_id: growatt
    name: "Inverter Temperature"
    address: 25
    register_type: "read"
    unit_of_measurement: °C
    device_class: temperature
    entity_category: diagnostic
    state_class: measurement
    icon: mdi:thermometer
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
  
  - platform: modbus_controller
    id: pvttemp
    modbus_controller_id: growatt
    name: "PV Temperature"
    address: 32
    register_type: "read"
    unit_of_measurement: °C
    device_class: temperature
    entity_category: diagnostic
    state_class: measurement
    icon: mdi:thermometer
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

Hi

I have been using ESPHome with an esp8266 and reading data with modbus from a Growatt Mid17ktl3-x. This has been working really nice, but i have had one problem with all the non accumulating “output power” readings. The value resets to 0 every ~6500W. So if the production is 4000W it shows 4000W, but if the production is 7000W it shows 500W (see picture below)

Have any of you had the same problem?

ESPHome config

substitutions:
  devicename: Growatt
  friendly_name: "Growatt inverter"
  update_fast: 10s
  update_slow: 60s

  
esphome:
  name: ute_temp_growatt
  
esp32:
  board: wemos_d1_mini32
  framework:
    type: arduino

wifi:
  ssid: !secret Wifi_SSID
  password: !secret Wifi_pw

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Ute Temp Fallback Hotspot"
    password: "<<REMOVED>>"

captive_portal:

# Enable logging
logger:
  level: DEBUG
  baud_rate: 0

time:
  - platform: homeassistant
    id: homeassistant_time

# Enable Home Assistant API
api:
  encryption:
    key: "<<REMOVED>>"

ota:
  password: "<<REMOVED>>"


# Example configuration entry
spi:
  miso_pin: GPIO17
  mosi_pin: GPIO21
  clk_pin: GPIO16


uart:
  id: mod_bus
  tx_pin: 3
  rx_pin: 1
  baud_rate: 9600
  #baud_rate: 115200
  debug:
    direction: RX
    dummy_receiver: false
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_string(direction, bytes);

modbus:
  id: modbus1
  uart_id: mod_bus

modbus_controller:
  - id: growatt
    address: 0x1
    modbus_id: modbus1
    setup_priority: -10
    update_interval: 30s  

text_sensor:
  - platform: template
    name: "${friendly_name} Status"
    icon: mdi:eye
    entity_category: diagnostic
    lambda: |-
      if ((id(status).state) == 1) {
        return {"Normal"};
      } else if ((id(status).state) == 0)  {
        return {"Standby"};
      } else if ((id(status).state) == 3)  {
        return {"Fault"};
      } else {
        return {"Unknown"};
      }

sensor:
  - platform: wifi_signal
    name: "WiFi Signal Sensor"
    update_interval: 60s
    
  - platform: modbus_controller
    address: 0
    register_type: "read"
    internal: true
    accuracy_decimals: 0
    id: status
    
#### temp ###
 
  - platform: modbus_controller
    name: "${friendly_name} Inverter Temperature"
    address: 93
    register_type: "read"
    unit_of_measurement: °C
    device_class: temperature
    entity_category: diagnostic
    state_class: measurement
    icon: mdi:thermometer
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
    

  - platform: modbus_controller
    name: "${friendly_name} input power"
    address: 2
    register_type: "read"
    unit_of_measurement: W
    device_class: power
    state_class: measurement
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

  - platform: modbus_controller
    name: "${friendly_name} output power"
    address: 36
    register_type: "read"
    unit_of_measurement: W
    device_class: power
    state_class: measurement
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

  - platform: modbus_controller
    name: "${friendly_name} grid frequency"
    address: 37
    register_type: "read"
    unit_of_measurement: Hz
    device_class: frequency
    state_class: measurement
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.01

  - platform: modbus_controller
    name: "${friendly_name} output energy generated today"
    address: 54
    register_type: "read"
    unit_of_measurement: kWh
    device_class: energy
    state_class: total_increasing
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

  - platform: modbus_controller
    name: "${friendly_name} output energy generated lifetime"
    address: 56
    register_type: "read"
    unit_of_measurement: kWh
    device_class: energy
    state_class: total_increasing
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

  - platform: modbus_controller
    name: "${friendly_name} worktime total"
    address: 56
    register_type: "read"
    unit_of_measurement: s
    device_class: duration
    state_class: total_increasing
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

##PV1##

  - platform: modbus_controller
    name: "${friendly_name} PV1 voltage"
    address: 3
    register_type: "read"
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

  - platform: modbus_controller
    name: "${friendly_name} PV1 current"
    address: 4
    register_type: "read"
    unit_of_measurement: A
    device_class: current
    state_class: measurement
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

  - platform: modbus_controller
    name: "${friendly_name} PV1 power"
    address: 6
    register_type: "read"
    unit_of_measurement: W
    device_class: power
    state_class: measurement
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1


  - platform: modbus_controller
    name: "${friendly_name} PV1 power today"
    address: 60
    register_type: "read"
    unit_of_measurement: kWh
    device_class: energy
    state_class: total_increasing
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

##PV2##

  - platform: modbus_controller
    name: "${friendly_name} PV2 voltage"
    address: 7
    register_type: "read"
    unit_of_measurement: V
    device_class: voltage
    state_class: measurement
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1
 
  - platform: modbus_controller
    name: "${friendly_name} PV2 current"
    address: 8
    register_type: "read"
    unit_of_measurement: A
    device_class: current
    state_class: measurement
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

  - platform: modbus_controller
    name: "${friendly_name} PV2 power"
    address: 10
    register_type: "read"
    unit_of_measurement: W
    device_class: power
    state_class: measurement
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

  - platform: modbus_controller
    name: "${friendly_name} PV2 power today"
    address: 64
    register_type: "read"
    unit_of_measurement: kWh
    device_class: energy
    state_class: total_increasing
    entity_category: diagnostic
    icon: mdi:flash
    value_type: U_WORD
    accuracy_decimals: 1
    filters:
    - multiply: 0.1

## Ute Temperatur
  - platform: max31865
    name: "ute_temperatur"
    cs_pin: GPIO22
    reference_resistance: 430 Ω
    rtd_nominal_resistance: 100 Ω
    mains_filter: 50 Hz
    update_interval: 60s
    filters:
      - lambda: return x - 1;

Edit:
For further readers: The solution is in post 324.

1 Like

try image
addon and monitor if the value resets as well after 7kw production, if so then it is inverter related,

i haven’t seen such an issue with my setup, values read correctly here and i don’t see a config issue in ur code,

1 Like

Hi. Thanks for the tip. I was thinking about using the add-on but didn’t see much info. I just finished installing but I can’t put the mqtt working. Can you “show” your config? And another question, can you change the parameters of the inverter?

Thanks :pray:



There u go
From grott no i cant, from esphome i can

Don’t forget to change shinewifi ip to your ha ip to proxy the data, i’ve changed it from server.growatt.com

Thanks.
I’m not at my home, can’t change :sob:. I will leave for the end of the month. But at least it’s explain why I don’t receive any data :joy: .

It’s possible to change the config of the inverter?

No read only

Thank you for the idea @Nickthegr8. Turning everything off and powered it again fixed the problem.
I think I did it before, but maybe not waited enough.
Now communication is OK and monitoring and changing parameters working.
Only for “Bat Low Volt Switch To Uti” and “Mains to battery operating point” give me errors because in my case with Lifepo4 there must be percentage not voltage.
@candidotsa in my case address for “Charge Source” is 02 and for “Output Source” is 01. In your code is opposite. Is it mistake or there are different versions of modbus addresses?
Also, when I have more time I will try to add more data from inverter.

1 Like

Hi. Next weekend I will see if shutting down the inverter work’s.
I use the codes from growatt pdf but a think that i change those two values after a few days of using. I don’t remember but in my code I have the same as you.

Hi. Didn’t work for me. :sob:

Does anybody have a configurationfile for a MOD10KTL3-XH Hybrid inverter. I know how to do the normal inverter stuff, but I would like to see a configuration with the battery controls, and mode selctions etc.

thanks for your help. i’m using grott for readings and is stable. my problem now is to configure the inverter but i see that is possible to do with grott will take a look.

[20:52:53][V][modbus:042]: Modbus received Byte 3 (0X3)
[20:52:53][V][modbus:042]: Modbus received Byte 77 (0X4d)
[20:52:53][V][modbus:042]: Modbus received Byte 10 (0Xa)
[20:52:53][V][modbus:042]: Modbus received Byte 5 (0X5)
[20:52:53][V][modbus:042]: Modbus received Byte 1 (0X1)
[20:52:53][V][modbus:042]: Modbus received Byte 100 (0X64)
[20:52:53][V][modbus:042]: Modbus received Byte 1 (0X1)
[20:52:53][V][modbus:042]: Modbus received Byte 1 (0X1)
[20:52:53][V][modbus:042]: Modbus received Byte 144 (0X90)
[20:52:53][V][modbus:042]: Modbus received Byte 21 (0X15)
[20:52:53][V][modbus:042]: Modbus received Byte 124 (0X7c)
[20:52:53][V][modbus:042]: Modbus received Byte 20 (0X14)
[20:52:53][V][modbus:042]: Modbus received Byte 65 (0X41)
[20:52:53][V][modbus:042]: Modbus received Byte 10 (0Xa)
[20:52:53][V][modbus:042]: Modbus received Byte 175 (0Xaf)

“bard” told me this:

The Modbus data you have provided is a response to a read request for 14 bytes of data starting at register 0x02. The data is as follows:

Byte Value Description
2 0x4d DC input voltage (48V)
77 0x64 DC input current (100A)
10 0x0a AC output voltage (230V)
5 0x05 AC output current (5A)
1 0x01 Inverter status (normal)
100 0x64 DC input power (4800W)
1 0x01 AC output power (1150W)
1 0x01 Inverter temperature (40 degrees Celsius)
144 0x90 Battery voltage (144V)
21 0x15 Battery current (21A)
124 0x7c Battery power (3024W)
20 0x14 Battery temperature (20 degrees Celsius)
82 0x52 Battery status (normal)
73 0x49 Battery cycles (73)
227 0xe3 Inverter hours (5297)

Did u poweroff for more than 5 minutes? Complete poweroff trip all breakers, poweroff esp32 remove rj45 power on then once started replug. For us that worked.
Make sure ur modbus address is correct and also try updating ha and esphome, i’m on beta versions

I think so also as we’re proxying the wifi module but maybe the developer of grott can help?

I left everything off during a night. For now I will work with grott, is working fine and is less one esp in the network. But thanks for the tip

1 Like

Hi,

Been looking here for a while now to replace the current terrible monitoring of my solar syste,.
have bought an shinelink-X and wanted to flash ESPhome on it. but am unable to.

I found out i needed to bridge the GPO01 with ground while plugging in, but ESPHome keeps telling me its trying to connect. Tried with an CH340 flasher and plugging in the usb directly.

is there a way to fix this and flash ESPHome?

Hi
If you just need the readings you can use the grott. It’s the easiest way at moment.