[solved] Ping host working from VM, not from LXC: any ideas?

I’m using the on/offline state of my pc (with a binary sensor) to control power from display, speakers and light with ping.
This was working fine with v2021.12.5 but now with 2022.2, it fails somehow and I can’t find the reason why.

- platform: ping
  host: 172.16.0.20
  name: Pc
  count: 2
  scan_interval: 3
- platform: template
  sensors:
    desktop_onoffline:
      friendly_name: "Desktop OnOffline"
      delay_off:
        minutes: 2
      value_template: >-
        {{ states('binary_sensor.Pc')}}

I cant see how this would ever have worked:

Entity ids do not have capital letters.

Hi Tom, thanks for your help!
I don’t have a clue how this capital got there because I have not changed anything to that section and before it worked. I have another sensor/template (not used currently) that has a capital as well…

Changing it to lowercase doesn’t make a difference, the sensor stays off:

From the logs:

Logger: homeassistant.components.ping.binary_sensor
Source: /srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/ping/binary_sensor.py:249
Integration: Ping (ICMP) (documentation, issues)
First occurred: 9:38:41 AM (447 occurrences)
Last logged: 9:46:05 AM

Error running command: `ping -n -q -c 2 -W1 172.16.0.28`, return code: 2
Error running command: `ping -n -q -c 2 -W1 172.16.0.20`, return code: 2
Error running command: `ping -n -q -c 2 -W1 172.16.0.30`, return code: 2
NoneType: None

The ‘issues’ leads me to this: https://github.com/home-assistant/core/issues/60781

I removed 2 of them to leave only the one of my pc (which I’m using now) but the state remains off.

Your LAN is on 172.16.0.0/12 ?
Unless you using Core and thus not docker, I can see a potential for conflicts, here…

Hi Chris, it’s on /24 and using Core.

And ping -n -q -c 2 -W1 172.16.0.28 works from a shell?

Yes it does.

Same here! With the new or actual Update the Ping Function with binary_sensor is not working …

@Lucky92: what kind of HA installation do you run?

Hi there,
I’m having a very similar issue as the one reported by @Lucky92 and @Nick4.
I’m on a fresh install (RPi 4B 4 Gb RAM - haos7.5 64bit).

My device tracker entity looks like this:

device_tracker:
  - platform: ping
    interval_seconds: 60
    consider_home: 120
    hosts:
      my_mobile: XXX.XXX.XXX.XXX # a valid ip address (which btw is static)

If I ping that ip from the terminal of “ssh+Web terminal” add on I get responses, as expected.
Anybody has a clue of what’s up?

FYI while googling I’ve found this (Device_tracker.ping entity not appearing) older solution, albeit for an “exotic” installation.

I’ll give it a shot and update this reply.

UPDATE:

apt-get install -y iputils

Returns:
“zsh: commnd not found: apt-get”.

After a quick lookup I found that apparently it is not a good practice to force installations through shell command…

Thus, I’m officially stuck too.

I still have this issue and as a test, I installed Home Assistant OS (on same proxmox box) and there it does work.

@SebastianoCurreli & @Lucky92: are you still experiencing this, any progress?
@Lucky92: what kind of HA setup do you run?

Any help is highly appreciated!

Hi @Nick4,
Yes, I confirm the issue is still there on my side. I think I’ll give it another shot after the upcoming round of updates (HA core 2022.4.6).
I’ll keep you posted.

Still not working for me after the recent june update.

Strange that some of use (seemingly few) are experiencing this whereas I would think that more people are using this as a sensor.

Anyone else in this configuration?

I recently experienced something similar in a different context: having the lan on 172.x.x.x conflicted with docker, leading to some packets being lost.

Hi Chris, I’m on 172.16.0.0/24, not using docker but Proxmox containers.
When running from the shell I do get a reply.

EDIT: ‘Ho’ should have been ‘Hi’ :blush:

Since a few releases I also have the same issue. I am running in a Docker environment and when I start the terminal within Home Assistant I cannot ping the PC anymore. So something with the route must have been changed.

UPDATE:
In my case I was pinging a local machine on my network. This machine got a new version of Eset Anti Virus with a firewall enabled. The firewall would block all local traffic to the machine. The issue was resolved by creating an exception in the firewall for local traffic.

I have the same. Cannot find the log entries that should show the issue.
Have read that log entries are truncated to 50 (but none regarding the ping platform).

My summery, this has (somehow) lost its functionality. perhaps valuable to create a ticket on this.

I have a similar problem, running latest , but for me some of my pings work, however two devices don’t respond. But I can get a ping response from the same ip in the HA terminal. Anyone know what additional logging I could turn on to see what comes back?

I got this far enabling debug for the ping binary_sensor:

023-01-09 17:04:39.381 DEBUG (MainThread) [homeassistant.components.ping.binary_sensor] ping address: 194.168.0.7

…but I don’t know how to get the response logged?

Running 2023.1.2

Here I have the same problem, running 2023.1.2 OS.
In my configuration I have the following:
binary_sensor:

  • platform: ping
    host: 192.168.2.61
    name: laptop
    scan_interval: 30

But the state of the sensor keeps only disconnected, when I ping the address with my laptop I get an response. My Home assistant has IP address 192.168.2.85 so it should be able to ping my laptop on the network right?