home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.49k stars 30.33k forks source link

Device_tracker (platform ping) problem #103445

Closed pety12321 closed 8 months ago

pety12321 commented 11 months ago

The problem

About a week ago I started having problems with device_tracker (ping platform).

What version of Home Assistant Core has the issue?

core-2023.10.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

device-tracker/ping

Link to integration documentation on our website

https://www.home-assistant.io/integrations/ping/#presence-detection

Diagnostics information

Logger: homeassistant Source: components/ping/device_tracker.py:136 First occurred: 1 november 2023 г. at 20:34:53 (31 occurrences) Last logged: 18:00:50

Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/ping/device_tracker.py", line 153, in _async_update_interval await async_update(now) File "/usr/src/homeassistant/homeassistant/components/ping/device_tracker.py", line 136, in async_update responses = await async_multiping( ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/icmplib/multiping.py", line 163, in async_multiping return [task.result() for task in tasks] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/icmplib/multiping.py", line 163, in return [task.result() for task in tasks] ^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/icmplib/ping.py", line 289, in async_ping reply = await sock.receive(request, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/icmplib/sockets.py", line 754, in receive loop.remove_reader(self._icmp_sock._sock) File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 338, in remove_reader self._ensure_fd_no_transport(fd) File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 257, in _ensure_fd_no_transport raise RuntimeError( RuntimeError: File descriptor <socket.socket fd=74, family=2, type=3, proto=1, laddr=('0.0.0.0', 1)> is used by transport <_SelectorSocketTransport fd=74 read=polling write=<idle, bufsize=0>>

Example YAML snippet

device_tracker:
  - platform: ping
    count: 3
    scan_interval: 30
    hosts:
      google_dns: 8.8.8.8
      kitchen_pristavka: 192.168.149.188
      nuc1: 192.168.149.81
      yandex_station1: 192.168.149.140
      sonoff_alisa: 192.168.149.182
      zmai_schetchik: 192.168.149.219
      sos_gw: 192.168.150.20
      bg_dver_cam1: 192.168.149.144
      gd_gw1: x.x.x.120
      fractel1: x.x.x.133
      bg_sberbox: 192.168.149.158
      gd_cam1: 192.168.4.180
      het1: x.x.x.47
      het2: x.x.x.110
      het3: x.x.x.58

Anything in the logs that might be useful for us?

No response

Additional information

Looks like this is something like this: https://stackoverflow.com/questions/57200946/runtimeerror-file-descriptor-8-is-used-by-transport

home-assistant[bot] commented 11 months ago

Hey there @jpbede, mind taking a look at this issue as it has been labeled with an integration (ping) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `ping` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign ping` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


ping documentation ping source (message by IssueLinks)

jpbede commented 11 months ago

Could you try to increase the scan_interval to 60 or so? I suspect that asyncio tries to reuse some file descriptors, which are still in use.

pety12321 commented 11 months ago

This action (scan_interval 60) did not help, I received an error after a couple of hours. Now I try scan_interval 90 and waiting again.

jpbede commented 11 months ago

If this does not work either, then please add some more information like which hardware run on, what was the last version where this worked.

Maybe you could try the binary_sensor instead of device_tracker platform or reduce the amount of devices, we need somehow takle this down.

Andrewkha commented 11 months ago

I have a different problem with th same integration. I have setup the presence detector (ping) for my 2 PCs like this:

device_tracker:
  - platform: ping
    scan_interval: 60
    hosts:
      home_pc_ping: 192.168.1.20
      dacha_pc_ping: 192.168.100.20

restarted the Home Assistant but there're no new entities for these trackers in the tool. Nothing in the logs. Should I open a separate issue for this? I'm running HA 2023.11.0 in a container on my QNAP NAS

jpbede commented 11 months ago

Should I open a separate issue for this?

Yes, please open a separate issue and turn on debug logging for the integration, to have a more detailed log.

issue-triage-workflows[bot] commented 8 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.