custom-components / sensor.owlintuition

A set of sensors to integrate the OWL Intuition devices network
MIT License
11 stars 9 forks source link

Unable to bind: [Errno 98] Address in use #26

Closed shortbloke closed 1 year ago

shortbloke commented 1 year ago

Updating to the latest HA version and Owl custom component version I'm now seeing an error being logged multiple times every 30 seconds.

Versions:

Section from configuration.yaml:

# Owl Energy Monitor
- platform: owlintuition
  host: 192.168.200.45
  port: 32000
  mode: triphase
  cost_icon: 'mdi:currency-gbp'
  cost_unit_of_measurement: GBP
  monitored_conditions:
    - electricity
    - solar

HomeAssistant.log

2023-05-06 18:44:49.771 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration owlintuition which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-06 18:44:49.776 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-05-06 18:45:11.380 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor electricity_battery
2023-05-06 18:45:11.380 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor electricity_battery_lvl
2023-05-06 18:45:11.381 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor electricity_radio
2023-05-06 18:45:11.381 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor electricity_power
2023-05-06 18:45:11.381 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor electricity_energy_today
2023-05-06 18:45:11.381 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor electricity_cost_today
2023-05-06 18:45:11.381 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor solargen
2023-05-06 18:45:11.381 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor solargen_today
2023-05-06 18:45:11.382 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor solarexp
2023-05-06 18:45:11.382 DEBUG (MainThread) [custom_components.owlintuition.sensor] Adding sensor solarexp_today
2023-05-06 18:45:11.393 ERROR (SyncWorker_4) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.397 ERROR (SyncWorker_10) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.399 ERROR (SyncWorker_12) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.400 ERROR (SyncWorker_9) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.402 ERROR (SyncWorker_7) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.404 ERROR (SyncWorker_8) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.404 ERROR (SyncWorker_13) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.404 ERROR (SyncWorker_2) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.407 ERROR (SyncWorker_5) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.408 ERROR (SyncWorker_1) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.409 ERROR (SyncWorker_0) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.411 ERROR (SyncWorker_11) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.413 ERROR (SyncWorker_14) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.415 ERROR (SyncWorker_15) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:11.437 ERROR (SyncWorker_16) [custom_components.owlintuition.sensor] Unable to bind: [Errno 98] Address in use
2023-05-06 18:45:14.442 DEBUG (SyncWorker_3) [custom_components.owlintuition.sensor] Datagram received for type solar
shortbloke commented 1 year ago

Adding some simple logging before sock.bind((self._binding[0], self._binding[1])) I can see that update method is called for each sync worker (0 to 16 in the log above). Each attempt to bind to the same address and port.

So I suspect the first SyncWorker will succeed and bind to the port, and rest will always fail as in use.

The previous version of this component would also have called multiple times, so I don't why this is now occurring, unless this regression has been introduced by the multicast support, or some change to HA that is now calling update more than before? I don't know...

shortbloke commented 1 year ago

Reverting sensor.py to a version before the multicast changes, and the unable to bind error is still present, so seems likely it is caused by a HA change.

shoey79 commented 1 year ago

Seeing identical issues as well, appears the HA update was the cause as I downgraded to 2023.4.6 as per https://community.home-assistant.io/t/owl-intuition-pv-home-assistant/18157/99 and was then able to view the output again.

shortbloke commented 1 year ago

Reverting to 2023.4.6 shows that the update method is still called by each SyncWorker. I also noticed that startup time has improved significantly on 2023.5.2, on my Pi4 it's < 10 seconds now, whereas when I reverted back to 23.4.6 it was > 100 seconds.

muzzy00uk commented 1 year ago

Hi there, I'm getting the exact same error and owl no longer working. I've checked I am the website for owl everything there working as expected and the data push address matches and it's in the config but HA just not seeing the data at all.

I've tried downgrading the core to the same as mentioned above and but that hasn't helped although it did sort a different issue.

Is there anything you can advise to try?

Many thanks Steven

shortbloke commented 1 year ago

@muzzy00uk Tryt the change in PR linked to this issue. I believe it will fix it for you.