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
69.75k stars 28.91k forks source link

Ping does not work #116804

Open geedsen opened 2 months ago

geedsen commented 2 months ago

The problem

I added ping integration, to ping my main router. After a few minutes it tells me that it is disconnected. But in terminal I can actually see that ping is working fine. And the debug log shows the ping is just fine. What am I missing? image

But the UI tells me this image

What version of Home Assistant Core has the issue?

core-2024.4.0b5

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

Ping

Link to integration documentation on our website

https://www.home-assistant.io/integrations/ping/

Diagnostics information

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 2 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. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


ping documentation ping source (message by IssueLinks)

jpbede commented 2 months ago

Could you please try the local IP of your router instead of the hostname. The hostname resolves to a public reachable IP, now if your public IP changes and the resolved IP to your hostname is cached, this may lead to wrong results

geedsen commented 2 months ago

My router has a problem. It is using ddns to register my dns name to the ip address. If the ip address changes, the new ip is registered with the dns name. And the dns name is important for me to reach homeassistant from the outside. The problem is the router sometimes does not continue registering the name and the name is than unknown on the internet. If that happens I need to reboot the router. And that is what I want to automate. So it needs to be the outside dns name, not the local ip.

geedsen commented 2 months ago

And the ip was not changed. It hardly ever changes. I could ping it from the homeassistant terminal and even the ping debug log shows it is reachabele. But the UI says disconnected.

jpbede commented 2 months ago

even the ping debug log shows it is reachabele.

Nope, (success: True) only indicates that ping was executed without errors but not if the device is reachable.

Could you please reload the ping integration and attach the debug log again?

jpbede commented 2 months ago

I don't know how your network is set up, but could it be, that you've two networks within your HA installation? So HA would use a different network then you on the terminal to ping and there ICMP is blocked? When I try to ping your address from the debug log, ICMP is blocked.

geedsen commented 2 months ago

Just checked to make sure, HA is running with an ip of my local network. Now it is interesting to note that ICMP is blocked , probably from the outside. The address shows when I ping is the uutside address, But it is pinging from the inside, maybe it is not blocked from the inside? Anyway I assume that HA Ping would also ping from the inside then.

geedsen commented 2 months ago

I removed my ddns name from the integration and then added both google.nl and myrouter.asuscomm.com. They both started of connected. But after a few minutes myrouter.asuscomm.com. became disconnected again. Google stays connected. The debug log still only shows that the ping for both dns names was executed without errors. And from the terminal pinging to the ddns name works just fine....

felipecrs commented 1 month ago

I am having the exact same problem. Debug logs for the ping integration shows absolutely nothing when calling update_entity for it.

goossensk commented 3 weeks ago

I'm also having the same issues :(

Added the integration to ping [192.168.0.81] which is the host I'm currently using.

The debug logs are mentioning: 2024-06-10 15:07:08.558 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 192.168.0.81 2024-06-10 15:07:08.577 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 192.168.0.81 data in 0.019 seconds (success: True)

However, within HASS my entity is [Disconnected] with unknown attribute values.

jpbede commented 3 weeks ago

However, within HASS my entity is [Disconnected] with unknown attribute values.

Again, as I mentioned earlier "success: True" does not mean the device is reachable šŸ™‚ Is your IP reachable from HASS?

Besides, I'll add more debug logging

felipecrs commented 3 weeks ago

The device is absolutely reachable from the HASS instance. I can confirm it by running ping in the SSH-addon terminal, which behaves as expected.

felipecrs commented 3 weeks ago

I personally believe this is a regression that was introduced since the migration from YAML config to UI config, as I suspect additional changes to the ping integration were made as well.

But this is not an evidence I can confirm. This issue is not easily reproductible, and downgrading HASS at this point is not feasible.

jpbede commented 3 weeks ago

I personally believe this is a regression that was introduced since the migration from YAML config to UI config, as I suspect additional changes to the ping integration were made as well.

Could be, I don't know šŸ¤·ā€ā™‚ļø I've added some more debug logs and tagged it for the next patch release and we will see

rawnsley commented 1 week ago

I think I may also be experiencing this problem. I have a LAN version (to the local IP of my router) and a WAN version (to 1.1.1.1). The LAN version works fine, but the WAN version periodically changes from Connected to Disconnected and then quickly back again. The ping debug logs look fine, but this comment confuses me...

Nope, (success: True) only indicates that ping was executed without errors but not if the device is reachable.

@jpbede What additional criteria are being considered other than the ping return code?

jpbede commented 1 week ago

Please enable the debug log

rawnsley commented 1 week ago

Please enable the debug log

I did this for the Ping (ICMP) integration by clicking Enable debug logging, there was an erroneous disconnect event at 10:33:14 and then I clicked the button again, which gave me the following log file (abbreviated):

2024-06-22 10:31:59.934 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 192.168.1.1
2024-06-22 10:31:59.936 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 192.168.1.1 data in 0.002 seconds (success: True)
2024-06-22 10:32:01.917 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 1.1.1.1 data in 4.048 seconds (success: True)
2024-06-22 10:32:29.935 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 192.168.1.1
2024-06-22 10:32:29.937 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 192.168.1.1 data in 0.002 seconds (success: True)
2024-06-22 10:32:31.868 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 1.1.1.1
2024-06-22 10:32:35.932 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 1.1.1.1 data in 4.064 seconds (success: True)
2024-06-22 10:32:59.935 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 192.168.1.1
2024-06-22 10:32:59.937 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 192.168.1.1 data in 0.002 seconds (success: True)
2024-06-22 10:33:05.868 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 1.1.1.1
2024-06-22 10:33:14.883 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 1.1.1.1 data in 9.015 seconds (success: True)
2024-06-22 10:33:29.936 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 192.168.1.1
2024-06-22 10:33:29.938 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 192.168.1.1 data in 0.002 seconds (success: True)
2024-06-22 10:33:44.868 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 1.1.1.1
2024-06-22 10:33:48.918 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 1.1.1.1 data in 4.049 seconds (success: True)
2024-06-22 10:33:59.934 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 192.168.1.1
2024-06-22 10:33:59.936 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 192.168.1.1 data in 0.002 seconds (success: True)
2024-06-22 10:34:18.868 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 1.1.1.1
2024-06-22 10:34:22.919 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 1.1.1.1 data in 4.051 seconds (success: True)
2024-06-22 10:34:29.935 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 192.168.1.1
2024-06-22 10:34:29.937 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 192.168.1.1 data in 0.002 seconds (success: True)
2024-06-22 10:34:52.868 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 1.1.1.1
2024-06-22 10:34:56.916 DEBUG (MainThread) [homeassistant.components.ping.coordinator] Finished fetching Ping 1.1.1.1 data in 4.048 seconds (success: True)
2024-06-22 10:34:59.935 DEBUG (MainThread) [homeassistant.components.ping.helpers] ping address: 192.168.1.1

Let me know if I need to do this differently to find more useful info.

jpbede commented 1 week ago

Are you on the latest version?

rawnsley commented 1 week ago

Iā€™m on Core 2024.4.3 with Frontend 20240404.2

jpbede commented 1 week ago

Would it be possible for you to upgrade to the latest release? It contains a bit more logging