Custom Component: SolarEdge Modbus TCP

I see. Maybe I can give it a try if you would give it a shot to test it. Might take a couple of rounds to get it working though

@jolaca if you look at page 19 here https://www.solaredge.com/sites/default/files/sunspec-implementation-technical-note.pdf would you be able to identify which registers that match what you want to read from your meter?

Hi, I’ve been taking a look and I’m mostly interested in total real power values, my inverter is monophasic so total will give only phase A, so 40206. However the only description about import, export and consumption power comes from the string 40155 but I don’t know if this is going to have values or only options. Related to energy there are: 40226, 40234
Not sure if this would get the correct data, thanks for trying anyway!!

Does any one else have troubles reading Modbus TCP values from their SolarEdge inverter? With this custom component I get “error 4”, with other Modbus TCP clients I get “timeout” reading the holding registers. Port 1502 is open and clients can connect, but I don’t get a response when reading values. The inverter (SE10000H screen less) is connected via ethernet and Modbus TCP is enabled. I have tried power cycling the inverter and switch Modbus TCP off and on again. I am also still waiting for a response from SolarEdge support (none so far).
I have only had the inverter installed over a week ago, local API was working with home assistant for 2 days before it disappeared (i’m guessing the firmware updated). I’m kinda regretting getting SolarEdge cause of the lack of support and that the local API closed off.
Any ideas what my Modbus TCP problem may be?

@awulf SolarEdge only support one modbus tcp client at the same time so make sure you dont have other clients trying to connect at the same time. Is that the case? If I recall correctly the client must also connect within like 2 minutes from power on, so try to have just this component enabled, turn off any other clients trying to connect and then power cycle the inverter and see if it works

HI @awulf, I have SE4000H (smaller than yours) also screen less, and Modbus TCP is working fine for me. I can confirm that local API is not working at all with latest firmware for my inverter. Did you access your inverter config via the SetApp app in order to enable modbus TCP??.

If you manage to make it work, it’s great to have instant data of solar production power, however it would be great if @erikarenhill could manage to get from the modbus meter data, the consumption and the imported/exported power from the grid, and thus there we’ll have the whole power flow picture in real time.

@erikarenhill I have tried power cycling and connecting within 2 minutes, I have also tried changing the IP address (statically assigned by the router via DHCP), power cycling and trying to connect within 2 minutes. I can confirm that if I try to connect 2 or more clients the subsequent clients get connection refused. So connecting to the Modbus TCP port is working .
e.g.

$ mbtget -r3 -n 100 -a 40001 192.168.34.113 -p 1502
receive timeout

vs

$ mbtget -r3 -n 100 -a 40001 192.168.34.113 -p 1502
server connect [192.168.34.113]:1502 failed

@jolaca I can access SetUp if I flick the “P” button to create a WiFi hot spot to connect to it and have enabled Modbus TCP via this (I have also tried disabling and enabling it again).

I also have an Import+Export Meter connected to RS485-1, Modbus ID #2. And the values from that are reporting correctly to the cloud (and was reporting correctly when the local API was working)

@awulf Very strange, but now I recall reading somewhere that some SolarEdge inverters can fail to connect if not adding a timeout in a specific place in the pymodbus (I think it was) library. Probably this could be needed to increase compatability with all models as in your case. I will look around a bit and see if I can find where I read it again and we could try that for you.

Finally Modbus TCP working! :smiley:
Not entirely sure if its a bug or what happened, but these are the steps I took, just in case someone else is having these problems. (For the screen less model)

  1. Flick the switch on SolarEdge to P and connect your mobile device to the WiFi hotspot (password on the side of the inverter, or use the QR code + mySolarEdge app)
  2. Open the browser and visit http://172.16.0.1 and click on the “Communication” menu item
  3. Select “RS485-2”
  4. Choose Protocol “SunSpec (Non-SE Logger)”, also under that set Device ID to 1 (mine was set to 5). Now some Modbus TCP requests were responding.
  5. Change the Protocol over to “SolarEdge Master” (now a SolarEdge logger script was getting data too)
  6. Change back protocol to “None”
  7. Power cycle the inverter for good measure, and it was all still working

Still need to get it into Home Assistant, but at least the Modbus part of it is working now.

3 Likes

@awulf Great that you got it working! And thanks for sharing the solution

Great!! @awulf as your inverter and mine are basically the same (a part from the huge power difference :smile:), I was just going to attach some photos of my config. Now we’ve just have to add to the excellent work form @erikarenhill, import-export power data to make this think fully useful!! I think I’ll give it a try myself.

@erikarenhill HI, using your excellent code as an example I’ve managed to get into modbus registers 40092 and 40093 in order to get AC production power factor to have it available in solaredge_modbus sensor.
However when trying to reach registers from meter1 like number 40206 I’m not getting it right, then, solaredge_modbus sensor does not load when restarting homeassistant:
To try to get that register I know I have to be cautious and skip the proper bytes. However what I am not sure I understand, is when you specify from which base register you read and how many, in this line:

reading = self._client.read_holding_registers(40069, 39)

I guess that if I want to read till register 40206, I will have to specify:

reading = self._client.read_holding_registers(40069, 137)

But this is not working for me. Maybe you cannot do this and you have to start again from the base register for the meter1 that according to the technical PDF, it is register 40121.
Could you please help me out a bit?? Thanks!!

@jolaca i got some code for the entire meter from @awulf that should work, I will do some work on it later

@erikarenhill , thank you for sharing. Looking forward to try and implement your code.

The sunspec protocol is used by many solar inverters. I am just starting with Home Assistant and do not have a complete conception of the architecture. Why ‘SolarEdge Modbus TCP’ and not ‘Sunspec Modbus TCP’? Could one generalise?

Regards

1 Like

@fcdvr Indeed there are several manufacturers that use the SunSpec protocol, but that is exactly what it is, a protocol and not a standard. The different brands use different registers for different data so this component is not reusable for example just pointing it to an SMA or Fronius inverter.

Of course you could write some more generic code and inject different maps to what to extract, but this really started out as a hobby project. I’m work as a programmer but in my profession I don’t use python so there I’m a rookie and just wanted something working up and running to solve the problem instead of getting generic and pretty code. Also because of lack of time I just solved my own problem but still wanted to share it with the community.

If you have knowledge of python and building home assistant components, please have a look at github and create pull requests there to improve it. @awulf already sent me some code to add support for reading the external RS485 modbus readings from the inverter for example, but it has not been tested and merged yet.

Enjoy the component! :slight_smile:

( If you are technically interested in comparing some different SunSpec implementations here is SolarEdge and SMA’s document about them:



)

@jolaca the solution from @awulf is now merged to master branch at github, so you got a working solution there now if you update the component and add the configuration for it (see readme).

There is now also support for configuration

scan_interval: X

where X is the seconds between polling. I’d recommend at fastest 2-3 seconds (default value is 5 sec)

1 Like

Thank you very much @erikarenhill and @awulf, this is truly awesome!! Now I’m really displaying my house power flow in real time locally!! I can even see that HA is displaying my data faster and before than the monitoring app from solaredge!! :joy: So great!!

Same as in Github:
Hello erikarenhill,
First of all thank you for your awesome work, this was to only thing i was missing in my solaredge setup.
The local data is a very important topic for my home automation, before i used the api data from the cloud.
My hassio System is on the latest software and on a RPi3+.
Now to my problem:
I installed your integration and added the sample configuration to my configuration.yaml
solaredge_modbus: name: 'SolarEdge Modbus' host: 192.168.17.127 port: 502 scan_interval: 60 #Optional: time in seconds between readings. Recommended value is at fastest 2-3 sec, default 5 read_meter1: false #Optional: set this to true if you have an external modbus meter connected with RS485 for reading self consumption

The inverter shows connected and i can receive data, but since i have this running my lovelace ui is very unresponsive it takes more than 30s to switch pages, so it could not be used as a daily driver.

When i uncomment it and restart it is normal again.
Do you have a hint, what could cause this problem?

Thanks in advance.
Regards,
Dominik

Hi @ds1707, I have the same Raspberry Pi and using this integration and I’m not having this issue at all. No idea why it does not work for you; I had some delay issues using graphswith too many points (resolution) in the frontend but not because of the integration per se. Hope erikarenhill can help you.

@erikarenhill, I’m having the issues described here using the ‘utility meter’ integration:
https://github.com/home-assistant/home-assistant/issues/20931

It seems that whenever there’s a lost connection to the meter sensor its value gets spoiled. I’m having this issue with import and export from meter1, however I’ve never had the problem with the PV lifetimeproduction meter as source. As it’s stated in the thread, it seems that the sensor from the source counters need to have implemented RestoreState.
The thing that I do not get is why PV lifetimeproduction works fine for me, but not import or export from meter1. Let me show you an example: import_daily came to 0 perfectly at midnight and started to sum up my house consumption bit by bit from then on properly. However, suddenly at 6:41am it added 230kWh (like adding the whole meter figure) . Maybe at this time HA was being reset, I don’t know why, but that shouldn’t spoiled values. Do you have any clue why this could happen and how to solve it??

I fixed the laggish lovelace ui by adding a small sleep to the loop. Had that initially but removed it, apparently it was needed for some hardware/installations.

Regarding the utility meter and storing the previous value that should be possible to fix. I’ll see when I get the time to dig into that issue. Can you please create an issue at GitHub for it? Thanks