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!
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)
- 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)
- Open the browser and visit http://172.16.0.1 and click on the āCommunicationā menu item
- Select āRS485-2ā
- 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.
- Change the Protocol over to āSolarEdge Masterā (now a SolarEdge logger script was getting data too)
- Change back protocol to āNoneā
- 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.
Great!! @awulf as your inverter and mine are basically the same (a part from the huge power difference ), 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
@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!
( 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)
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!! 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
Hi to all, when the script run, in home assistant get this error:
2020-02-25 14:30:05 ERROR (MainThread) [custom_components.solaredge_modbus.sensor] error 4
I have the same issue and the lovelace is unresponsive.
With extra meter=true lovevlace does not even start.
could you please cross check?