RalfOGit / sma-emeter-simulator

An SMA(TM) emeter simulator written in C++
MIT License
16 stars 5 forks source link

Not detected by Sunny Portal/Sunny Home Manager 2.0 #1

Open FrederikVds opened 2 years ago

FrederikVds commented 2 years ago

Hi!

Thanks for sharing this project!

I tried adapting the code to get data from an unsupported solar panel inverter into Sunny Portal, but the portal doesn't detect this virtual e-meter. Would you happen to know what's required to make Sunny Portal detect it? The main device in my network is a Sunny Home Manager 2.0.

Thanks again!

RalfOGit commented 2 years ago

Hi,

I tested the simulator against an SMA Tripower inverter, as I do not have an SHM. It is tricky

Best regards

FrederikVds commented 2 years ago

Thank you for the suggestion about the iPhone app.

One problem I had is that the time in the emeter packets was always 0. localhost.getUnixEpochTimeInMs() wasn't working for me, on a Raspberry Pi with the default OS. I used some other code to get the time and now it's working. If you're interested, this worked:

emeter_packet.setTime((uint32_t)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count());

Another thing is that I was mistaken about where I should add the virtual emeter to Sunny Portal. I thought it would show up as a separate device but it doesn't. I had to add it to the SHM2.0 as a PV meter through the SHM2.0's own settings.

Thanks for your help, I'm thinking about publishing the project to Github as well. It allowed me to use an older SMA inverter (that uses the SMA Com Gateway) on Sunny Portal. I just need to clean up a bit first I'm afraid. It's a shame SMA itself doesn't support this.

RalfOGit commented 2 years ago

Thanks for suggestion on the use of std::chrono with linux builds. I just updated the libspeedwire repo accordingly. std::chrono is part of c++11, therefore it should be available on all platforms supporting this c++ version.

Algram commented 1 year ago

@FrederikVds I am also trying to get an unsupported inverter into the sunny portal. Would you mind sharing the solution you came up with in a little more detail?

I am very interested :)

Ernie1806 commented 1 year ago

Thanks also from me for sharing this project! Works great on Win OS! On a PI with Buster it only send messages to LocalHost:

address: 127.0.0.1 prefixlength: 8 mac: 00:00:00:00:00:00 name: "lo" address: 192.168.x.y prefixlength: 24 mac: B8:24:CW:CF:0E:56 name: "eth0" .. .. INFO: main: broadcast sma emeter packet to 239.12.255.254:9522 (via interface 127.0.1.1)

Any idea how to fix the issue?

RalfOGit commented 1 year ago

… thus it detects the eth0 interface but does not use it in the loop to send out packets?Can you check if eth0 is missing here in main.cpp: const std::vector& localIPs = localhost.getLocalIPv4Addresses(); ?

Ernie1806 commented 1 year ago

yes, only send out to 127.0.1.1! eth0 is missing in localIPs.

RalfOGit commented 1 year ago

…. I tried to reproduce the problem and it shows the same behaviour on my raspi.

LocalHost::queryLocalIpAddresses() uses the standard getaddrinfo() method to get a list of local ip addresses. That does not seem to work with the raspi OS. There is a discussion on stackoverflow about this behaviour: https://stackoverflow.com/questions/24109556/getaddrinfo-on-raspbian-returns-only-loopback-ip-same-code-on-os-x-multiple

LocalHost::queryLocalInterfaceInfos() is getting the correct information from the socket, as you can see in the printout. However this is a lot more tricky and I thought it would be more robust to use the simpler getaddrinfo() method to have at least something if LocalHost::queryLocalInterfaceInfos() fails.

I don’t know when I will find time to implement a workaround for the raspi os. Do you want to give it a try?

RalfOGit commented 1 year ago

… I just pushed an update for libspeedwire with a workaround for the broken getaddrinfo() on raspberry. Please give it a try and report back if this solved the problem.

sfranzis commented 1 year ago

Another thing is that I was mistaken about where I should add the virtual emeter to Sunny Portal. I thought it would show up as a separate device but it doesn't. I had to add it to the SHM2.0 as a PV meter through the SHM2.0's own settings.

@FrederikVds How did you add it to the SHM2.0 in the settings? I don't find this.

FrederikVds commented 1 year ago

@sfranzis In Sunny Portal, in Device Overview, go to the Sunny Home Manager properties. It's at the bottom under Meter Configuration.

FrederikVds commented 1 year ago

@Algram Sorry, I've been very busy lately.

I uploaded my application here: https://github.com/FrederikVds/smacomgw2shmtwo

I didn't have time to check whether it still contains things specific to my network. I hope it's useful to you.

sfranzis commented 1 year ago

@FrederikVds Tank you, found it. But then SHM2 ignores the data from my inverters. Wow SMA, highly sophisticated software design. 🙈

Elektron79 commented 10 months ago

Hi @FrederikVds ,

would you mind to Share your Development with me? I was Not Abel to find ist in your repository…

My Target would be to integrate an 3kW Party Inverter into my SMA-System, Boy emulating a SMA Inverter.

I uploaded my application here: https://github.com/FrederikVds/smacomgw2shmtwo

Thank you and Nest regards Michael

kommando828 commented 1 month ago

Hi @FrederikVds, I would also be interested in your development. I have a Solar-log connected to 3 SMA inverters for data logging, 2 are via Speedwire, I also have a Solax X1 Boost that I emulate as a SMA Modbus inverter within Node red using an MQTT feed.

https://gist.github.com/kommando828/7db69e532e4c58eb8078724092c4308a

But the Solar-log does not differentiate between the 2 MPPT's on SMA Modbus unlike on the Speedwire connected Inverters. By emulating the Solax X1 Boost as a SMA Speedwire I would hope to log data on both MPPT's.

Thank you in advance

John

kommando828 commented 2 weeks ago

@FrederikVds

Thank you.