November 22, 20214 yr On 2021/09/16 at 11:28 AM, kellerza said: @Sc00bs - seems like I finally have my Home Assistant energy dashboard working with my Sunsynk 🙂 Using only the following sensor config & the addon - https://github.com/kellerza/sunsynk SENSORS: - total_pv_power - total_grid_export - total_grid_import - total_pv_power - total_battery_charge - total_battery_discharge Hey @kellerza. Does this addon assume that the HA server is connected to the RS48? (I've got a Pi by the inverter dropping to my separate HA server)
November 23, 20214 yr 23 hours ago, crash said: Hey @kellerza. Does this addon assume that the HA server is connected to the RS48? (I've got a Pi by the inverter dropping to my separate HA server) You can deploy it in several ways: The RS485 port can be local or remote. If remote you will need another device (like your Pi by the inverter) that runs a mbusd TCP-to-RS485 gateway. I use this method with a Pi running HomeAssistant OS near the inverter running mbusd as an addon, see https://github.com/kellerza/sunsynk/tree/main/hass-addon-mbusd . You can also run mbusd on any standard Linux OS (which means a Pi 1 could also perform this function) The other way to do it is to have the Sunsynk Addon running on the pi close to the inverter and then connect to a the MQTT server on your main HomeAssistant server. Edited November 23, 20214 yr by kellerza
March 21, 20224 yr Would it be possible to set this up using the remote appraoch with an ESP32 and TTL to RS485 module? Does Esphome perhaps have the code for the modbus TCP gateway? Or maybe there is code that can run on the ESP32 to achieve this.
March 22, 20224 yr 16 hours ago, BrettC said: Would it be possible to set this up using the remote appraoch with an ESP32 and TTL to RS485 module? Does Esphome perhaps have the code for the modbus TCP gateway? Or maybe there is code that can run on the ESP32 to achieve this. ESPhome cannot create a MODBUS-TCP gateway that I know of, but you can read/write modbus registers. If you create sensors with the correct state_class it should be possible to do this. You might have to write your own ESP lambda functions to do some math between the registers. It could be a nice solution, but it does violate one of my home automation rules that it should not be too custom. And anything where you need a soldering iron (to connect the RS-485 to the ESP board) is too custom 😉
April 4, 20224 yr I went ahead and managed to set this up with an ESP32 and a R30 RS485 to TTL board I ordered off Banggood. The Esphome code was surprisingly easy when I figured it out, and it was quite simple to set up the entities once I figured out how the Esphome modbus setup worked. I am just reading the sensors for now. I still need to working on write updates to the settings.
April 4, 20224 yr Here is a sample of the code if anyone else wants to try this approach. uart: id: mod_bus tx_pin: 17 rx_pin: 16 baud_rate: 9600 stop_bits: 1 modbus: id: modbus1 modbus_controller: - id: sunsynk address: 0x01 modbus_id: modbus1 setup_priority: -10 update_interval: 20000ms sensor: - platform: modbus_controller modbus_controller_id: sunsynk name: "Grid power" id: grid_power register_type: holding address: 169 unit_of_measurement: W device_class: power state_class: measurement
April 5, 20224 yr Author That looks pretty awesome @BrettC I have found https://www.robotics.org.za/ to be a great local source for electronic components. I have a NodeMCU lying around and am thinking I might connect that up and see if I can get it to work 🙂 Will be a great low cost connectivity solution
April 5, 20224 yr Author Suspect I may have to get an ESP32, I doubt the 8266 will have enough grunt.
April 6, 20224 yr Yes, the Esphome Modbus specs do say an ESP32 is preferred although an ESP8266 should work too. https://esphome.io/components/modbus_controller.html
April 13, 20224 yr Will I be able to use this with solar-assistant in the middle (MQTT enabled)? kind regards Aubrey
June 16, 20224 yr Hi all. Here is my version to get Sunsynk 8.8 Modbus metrics in Home Assistant: Required Hardware: ESP32 Development Board @R149.95 https://www.diyelectronics.co.za/store/espressif-iot/1495-esp32-development-board.html?search_query=esp32&results=26 MAX485 RS-485 to TTL Convert Module @R19.95 https://www.diyelectronics.co.za/store/serial/1204-max485-rs-485-to-ttl-converter-module.html?search_query=485&results=21 3D Printed Case I use to pack it all: https://www.thingiverse.com/thing:4670334 My code for ESPHome https://esphome.io/ Note: On the Sunsynk inverter side it is set to Modbus ID 1 and runs in Slave mode. (I think this is default for the inverter) esphome: name: "sunsynk" esp32: board: esp32dev framework: type: arduino logger: baud_rate: 0 api: ota: wifi: ssid: !secret wifi_ssid password: !secret wifi_password # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "SOMEFALLBACKAP" password: "password" fast_connect: true power_save_mode: none time: - platform: sntp id: sntp_time timezone: Africa/Johannesburg servers: - pool.ntp.org uart: id: mod_bus tx_pin: 17 rx_pin: 16 baud_rate: 9600 stop_bits: 1 modbus: id: sunsynk_modbus flow_control_pin: 4 modbus_controller: - id: sunsynk address: 0x01 modbus_id: sunsynk_modbus setup_priority: -10 update_interval: 20000ms sensor: - platform: modbus_controller modbus_controller_id: sunsynk name: "Total Battery Charge (kWh)" id: total_battery_charge_kwh register_type: holding address: 72 unit_of_measurement: "kWh" accuracy_decimals: 2 device_class: energy state_class: total_increasing filters: - multiply: 0.1 - platform: modbus_controller modbus_controller_id: sunsynk name: "Total Battery Discharge (kWh)" id: total_battery_discharge_kwh register_type: holding address: 74 unit_of_measurement: "kWh" accuracy_decimals: 2 device_class: energy state_class: total_increasing filters: - multiply: 0.1 - platform: modbus_controller modbus_controller_id: sunsynk name: "Total Grid Export (kWh)" id: total_grid_export_kwh register_type: holding address: 81 unit_of_measurement: "kWh" accuracy_decimals: 2 device_class: energy state_class: total_increasing filters: - multiply: 0.1 - platform: modbus_controller modbus_controller_id: sunsynk name: "Total Grid Import (kWh)" id: total_grid_import_kwh register_type: holding address: 78 unit_of_measurement: "kWh" accuracy_decimals: 2 device_class: energy state_class: total_increasing filters: - multiply: 0.1 - platform: modbus_controller modbus_controller_id: sunsynk name: "Total Load Power (kWh)" id: total_load_power_kwh register_type: holding address: 85 unit_of_measurement: "kWh" accuracy_decimals: 2 device_class: energy state_class: total_increasing filters: - multiply: 0.1 - platform: modbus_controller modbus_controller_id: sunsynk name: "Total PV Power (kWh)" id: total_pv_power_kwh register_type: holding address: 96 unit_of_measurement: "kWh" accuracy_decimals: 2 device_class: energy state_class: total_increasing filters: - multiply: 0.1 - platform: modbus_controller modbus_controller_id: sunsynk name: "Grid Power" id: grid_power register_type: holding address: 169 unit_of_measurement: "W" accuracy_decimals: 2 device_class: power state_class: measurement filters: - lambda: |- float MIN_VALUE = 0.00; float MAX_VALUE = 8000.00; if (MIN_VALUE <= x && x <= MAX_VALUE) return x; else return {}; - platform: modbus_controller modbus_controller_id: sunsynk name: "Load Power" id: load_power register_type: holding address: 178 unit_of_measurement: "W" accuracy_decimals: 2 device_class: power state_class: measurement - platform: modbus_controller modbus_controller_id: sunsynk name: "PV1 Power" id: pv1_power register_type: holding address: 186 unit_of_measurement: "W" accuracy_decimals: 2 device_class: power state_class: measurement - platform: modbus_controller modbus_controller_id: sunsynk name: "PV2 Power" id: pv2_power register_type: holding address: 187 unit_of_measurement: "W" accuracy_decimals: 2 device_class: power state_class: measurement - platform: modbus_controller modbus_controller_id: sunsynk name: "Battery SOC" id: battery_soc register_type: holding address: 184 unit_of_measurement: "%" accuracy_decimals: 0 device_class: battery - platform: modbus_controller modbus_controller_id: sunsynk name: "Battery Charging Efficiency" id: battery_charging_efficiency register_type: holding address: 216 unit_of_measurement: "%" accuracy_decimals: 1 device_class: battery filters: - multiply: 0.1 - platform: modbus_controller modbus_controller_id: sunsynk name: "Grid Connected Status" id: grid_connected_status register_type: holding address: 194 accuracy_decimals: 0 In Home Assistant, ensure to include the new sensors in the recorder: recorder: include: entity_globs: - sensor.total_* - sensor.grid_* - sensor.load_* - sensor.pv*_power - sensor.power_production* Edited September 27, 20223 yr by sjlouw
June 16, 20224 yr Author Wow, @sjlouw That looks awesome, going to have to put one together. Thanks for all the hard work 🙂
June 20, 20224 yr Author A question @sjlouw Does the inverter need to be in Slave mode? Comes up with an F13 Grid_mode_changed error when I change that value on my inverter, is set for master.
June 20, 20224 yr @Sc00bs Yes. Please see screenshot. The F13 Grid_mode_changed error is normal. Im also getting that if I switch between Slave and Master. The error should clear after a few mins.
June 21, 20224 yr Author So @sjlouw, I have two questions, not sure if you know the answers - What is the effect of switching the inverter into Slave on overall inverter functioning - Any idea why it is necessary for the inverter to be set as Slave for the comms to work, it works using the RS485 without changing the settings using @Bloubul7 's node red flows
June 23, 20224 yr On 2022/06/21 at 1:34 PM, Sc00bs said: So @sjlouw, I have two questions, not sure if you know the answers - What is the effect of switching the inverter into Slave on overall inverter functioning - Any idea why it is necessary for the inverter to be set as Slave for the comms to work, it works using the RS485 without changing the settings using @Bloubul7 's node red flows 1. If you have a single inverter, there is no effect. (The default setting for mine was Slave). Its only there if you have multiple inverters setup in parallel, then you have to define them each with a unique number and have at least one in MASTER mode on the modbus. 2. The ESP32 acts as a modbus master on the bus, from what I understand.
July 14, 20223 yr Excellent work i have my setup all have gone with Pi zero sending Data to HA on pi 4b and all looking really good. Now with the load shedding animal i need to be able to change my charge settings on my Sunsynk Inverter similar to the settings that you can change on Solar Assistant A lot of work that i still need to get going on grafana but i have some graphs working lekker thanks to Scoobs and Bloubul 7 I just need to figure out how i can change these settings on my inverter and if possible have the schedule changed automaticlly with these hectic schedules we have at the moment but for now if i can just change it using Home assistant or Nodered and write back to the inverter
July 14, 20223 yr Author Hi @Farcus It is possible to write settings back to the inverter using the flows that @Bloubul7 created using the Node Red UI. How exactly to set it up, I have no idea as I could never get it to work and I kept on overwriting my inverter settings but a number of people have so I was obviously doing something wrong. Maybe someone who has got it running could explain what needs to be setup for it to work.
July 17, 20223 yr Author @sjlouw Is it possible to write settings back to the inverter using you ESPhome solution? Would be nice to be able to store multiple setups the way the Node Red flows do and write them back to the inverter when required.
August 4, 20223 yr Hi all, I have downloaded the SunSynk Modbus document. It would seem to be applicable to single phase inverters I have a SunSynk 12 kW 3 phase inverter ... is this document valid for this model? Or can anyone advise on where one might find the modbus register layout for the SunSynk 3 phase inverter?
August 14, 20223 yr On 2022/08/04 at 10:26 PM, MoGuLza said: Hi all, I have downloaded the SunSynk Modbus document. It would seem to be applicable to single phase inverters I have a SunSynk 12 kW 3 phase inverter ... is this document valid for this model? Or can anyone advise on where one might find the modbus register layout for the SunSynk 3 phase inverter? Pretty much all Sunsynk and Deye models use same registers as described in the document. Differences come with wiring pins and getting stable read.
August 14, 20223 yr On 2022/07/14 at 7:46 AM, Farcus said: Excellent work i have my setup all have gone with Pi zero sending Data to HA on pi 4b and all looking really good. Now with the load shedding animal i need to be able to change my charge settings on my Sunsynk Inverter similar to the settings that you can change on Solar Assistant A lot of work that i still need to get going on grafana but i have some graphs working lekker thanks to Scoobs and Bloubul 7 I just need to figure out how i can change these settings on my inverter and if possible have the schedule changed automaticlly with these hectic schedules we have at the moment but for now if i can just change it using Home assistant or Nodered and write back to the inverter You kinda almost there, as far as inputs for Time, Power, and SoC go fairly straight forward. Actual register(s) holding value for charging state for given time slot on/off requires bit more elaboration.... Albeit if file access permission flag makes sense to you it kinda works in a similar way. Charge field in inverter registry is integer and holds values for, all possible states State table should look something like this : GridChrg GeneChrg 04 false false Both off 05 true false Grid on, Gen off 06 false true Grid off, Gen on 07 true true Grid On, Gen on So if you don't need anything fancy and/or care for states other than grid charge on/off having a simple map that binds 04 to false and 05 to true should do the trick ... I'm assuming rest of the reg addresses and such like you have already worked out. Hope this helps Edited August 14, 20223 yr by Padwan
August 25, 20223 yr Thanks for this , this is excellent. The ESP32 method is by far the quickest and easiest. Only issue I seam to be having is delayed readings, sometime no readings. @sjlouw did you remove the termination resistor (R7) off from the RS485 board? Or do you have similar issues using the esp32 Thanks for the effort
September 4, 20223 yr @Garreth No, I have not removed the resistor. The module is used as-is. I'm not experiencing those issues. I wonder, can it maybe be poor Wifi connection from your ESP to your access point? Mine is literally next to an Access Point. Also note that I have used an ESP32 which does have a little more processing power than the ESP8266, which I think is sort-off required for the modbus component in ESPHome to reliably work.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.