iobroker-community-adapters / ioBroker.sma-em

ioBroker Adapter for SMA Energy Meter & Sunny Home Manager 2
MIT License
25 stars 16 forks source link

Listen multicast on defined network interface #117

Closed DesertFox8 closed 3 years ago

DesertFox8 commented 3 years ago

I have the experience, that the adapter is not working (receiving any multicast data) if more than one network interface is available on the host. Probably the socket select only one of them and chooses the wrong in my case.

Defining the target network fixes the issue: client.addMembership(this.config.BIP, '<HOST-IP>');

TGuybrush commented 3 years ago

I checked the documentation of the nodes network function. It's right that the adapter just gets the multicast packets from one interface. I will try to fix the problem in the next release. When the new version is ready, I appreciate a feedback.

pdbjjens commented 3 years ago

@TGuybrush Great! Thank you very much. I am looking forward to your PR and will take care that it will be merged promptly. Unfortunately I do not have the hardware to test it with multiple NICs. However I can test whether normal single NIC behaviour is still o.k. @DesertFox8 It would be great if you would check the new release whether it fixes your issue as soon as it is available.

TGuybrush commented 3 years ago

I've pushed a new version to my repository. Please feel free to test it in your multi device setup. You can see now in the log messages on with IP and device the adapter is binding.

pdbjjens commented 3 years ago

@DesertFox8 TGuybrush has provided a new version in his repository. Please check and report here if it fixes your issue.

DesertFox8 commented 3 years ago

Works perfect. Thanks. It's now listening on every network for the multicast.

However, doesn't it make sense to listen on a specific network only? Usually there is only one network where the SMA-EM is connected to. Maybe an option to select a network or every available network?

pdbjjens commented 3 years ago

@TGuybrush I installed the new version in my environment (1 SHM + 1 SEM on the same network). Since I do not have multiple network interfaces I can only confirm that the new version works as before and detects and binds to my only interface correctly.

I found two anomalies (see log) which probably have already been present in previous versions : iobroker.2021-02-07.log.zip

  1. If I choose all four options (L1, L2, L3, Extended Details) the iobroker admin reports: "Unsubscribe from all states, except system's, because over 3 seconds the number of events is over 200 (in last second 0)" when I have the Objects-Tab open. The update of the values in the objects-tab stalls in this case indefinitely long. If I don't have the Objects-Tab open It does not unsubscribe and even re-subscribes all states automatically. If I choose no options or only extended Details, the admin does not unsubscribe states. Probably this is due to the fact that I have two Devices (SHM and SEM) and that they update all values by the second. Is it possible to throttle the update rate of the values in the Objects tab somehow so that this behaviour can be avoided?
  2. The SMA-EM Adapter is started twice. First with all options false and then it is terminated and restarted after the options have been set and the config page is closed.
pdbjjens commented 3 years ago

@TGuybrush Thank you for providing the multiple network fix so quickly. In order to get a broader test-base, we would like to release another beta version. Would you be so kind as to prepare another PR containing your fix?

pdbjjens commented 3 years ago

@TGuybrush Several users reported frozen values in the object-tab (see issue #110 ) with 0.6.1-beta.0. patrick7519 has two network interfaces. Do you think this might be a reason for the frozen SMA-EM? Could it be that this issue might be fixed with your latest version for multiple networks?

pdbjjens commented 3 years ago

@TGuybrush I just noticed that patrick7519 already seems to be using your version of SMA-EM with the multiple network fix. (see the iobroker log which he provided in #110 ). He has two interfaces on two different networks (one being a DMZ) but only one EM on one of the networks (on the DMZ). It seems that the adapter detects the EM on both Networks. Do you have any idea why?

pdbjjens commented 3 years ago

@TGuybrush It seems that indeed the multicast on the two networks was the reason for the freeze. So this issue is fixed for patrick7519. However, do you think it makes sense and is possible to avoid such problems in the future if the adapter would check if it detects the same EM on different networks that it ignores one of them?

TGuybrush commented 3 years ago

There are many possible checks which I can imagine in general. However it's not useful for me to check for any misconfiguration on the network.

jb-home commented 3 years ago

Hey I got the same issue. I have two VLANs configured. And the adapter listens on the default network. I think a choice box of available IPs to listen for would be sufficient. In case someone got two on two different LANs, than a second instance could be used.

So I just wanted to mention, that you do not need more than one NIC to get this issue.

pdbjjens commented 3 years ago

@TGuybrush Thank you very much for providing the PR. We, (i.e. the co-workers of the iobroker-community-adapters repo) have published the new version as sma-em 0.6.3 to the iobroker latest repo. We also set up a Test thread in the iobroker Forum test-adapter-sma-em-v0-6-x-latest and hope for feedback of users. Our goal is to finally bring the sma-em adapter to the iobroker stable repo after successfully finishing the test phase. I would like to kindly ask you whether you would be interested to continue to work with us to achieve this goal.

TGuybrush commented 3 years ago

I'm interested to continue the work on the adapter. What has to be done to reach the goal to join the stable repository?

pdbjjens commented 3 years ago

@TGuybrush Wow, great. I am really happy that you agree to help us finalizing the sma-em. Basically, what still has to be done is ticking of the issues list and analyse user feedback and new issues coming in through the forum. To get started I suggest that we close this issue #117. However, before I close it, I would like to answer the concern which was mentioned by JensBonse, above. Do you have an idea whether the issue he mentions can also be fixed by correct network configuration or would it be neccessary and possible to fix this in sma-em? Next point for which I really would like your expertise is in issue #137. I am still waiting for more information from thgonline, but my suspicion is that these warnings have somthing to do with the SMA speedwire device discovery protocol. What do you think?

JHA-2021 commented 3 years ago

Hi, I downloaded and installed the adapter on my raspimatic Pi 4 with IObroker adapter. It stays yellow and does not show any data in objects.

Do I have to set anything besides the Phase values I'd like to get? The Multicast IP is probably a fixed IP?

I have a network with several repeaters and a power-to-lan adapter could this cause problems?

pdbjjens commented 3 years ago

@JHA-2021 You should not change the multicastIP and port presets, because they are fixed SMA adresses. I would say that almost for certain your network is the culprit. It is essential that the network forwards the multicasts of the SEM to the segment where your RasPi is located. Especially power-to-lan adapters are notorious for causing problems with SMA multicasts. So I recommend that first of all you avoid segments with power-to-lan adapters between RasPi and SEM. WLAN Repeaters usually do not interfere with multicasts. Make sure that you disable any IGMP snooping on LAN switches in your network as this is the second-most reason for SMA-multicasts not going through.

JHA-2021 commented 3 years ago

Thank you for the swift reply. Sorry for my questions. Power-to LAN unfortunately is the only way to get the data from under the roof into the basement. I will look for an adapter which does not cause multicast problems then. Regarding my network I have to be more precise: I use several repeaters working as access points to distribute Wifi in the house but that shouldn't be the cause, I guess, or do you think it could? How can I set anything on my switches? I have a small one between the P-T-LAN and the inverter and I have one in the basement between the P-T-LAN and my Fritz!Box but It is new to me that I can set IGMP Snooping etc.

pdbjjens commented 3 years ago

@JHA-2021 Since this is not really an issue of the sma-em adapter, I suggest that we continue this discussion in the german iobroker forum Please be so kind as to to ask your question once more there preferably in german, as other users might also have good proposals for you. I will also go there.

pdbjjens commented 3 years ago

@TGuybrush Are you interested in working on issue #142 ? This is an issue which I think needs to be solved before the adapter can go to stable.

TGuybrush commented 3 years ago

Sure, I will make a proposal in the #142.

pdbjjens commented 3 years ago

Done with release v0.6.3.