asantaga / lightwaverf_HA_EnergySensor

Home Assistant Sensor for the LightwaveRF energy monitor
MIT License
5 stars 3 forks source link

UDP Port Conflict #13

Open ColinRobbins opened 1 year ago

ColinRobbins commented 1 year ago

I created a PR into the main HA Lightwave integration, to add direct support for lightwave TRVs. https://github.com/home-assistant/core/pull/85385 Testing by @hunterdriver has seen an issue (https://community.home-assistant.io/t/lightwave-thermostatic-valves/131644/23).

This is caused by both the TRV listener and your code needing to listen on UDP Port 9761.

I believe the following change would resolve the issue. https://github.com/asantaga/lightwaverf_HA_EnergySensor/blob/master/custom_components/lightwaverf_energy/sensor.py

            sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
            sock.bind(("0.0.0.0", 9761))

to

            sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
            sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
            sock.bind(("0.0.0.0", 9761))
ColinRobbins commented 1 year ago

See the conversation on https://community.home-assistant.io/t/lightwave-thermostatic-valves/131644/28 It seems to above suggestion does not work.

Open to suggestions, but fundamentally both code bases need access to the same UDP port in the same Python thread, which I don't think can be done.

asantaga commented 1 year ago

oh, i didnt see this. So the issue is that this codebase and the one for lightwave trvs.

I'll check the main HA Lightwave integration, my code is simple, perhaps they just add support for Lightwave energy sensors in their mainline