Updating ping binary_sensor took longer than the scheduled update interval

Log Details (WARNING)
Mon Aug 20 2018 20:57:12 GMT+1200 (New Zealand Standard Time)

Updating ping binary_sensor took longer than the scheduled update interval 0:00:02

I use the ping sensor (interval: 2s count: 2) to monitor of my tv power state. My About page in hass.io error log is full of the error above. Is there a way to exclude this ping error from the error log?

Yes. But note that what you’re seeing is a warning, not an error. This is important because you can exclude things based on their log level. See Logger.

Basically, in your configuration.yaml, for logger:, change the log level for homeassistant.components.binary_sensor.ping to something higher than warning. E.g.:

logger:
  logs:
    homeassistant.components.binary_sensor.ping: error

This will only log messages for the ping binary sensor with a log level of error or higher.

1 Like

Thank you pnbeucker

hmm that doesn’t work it still shows the error

logger:
  default: warning
  logs:
    homeassistant.components.light.yeelight: fatal
    homeassistant.components.binary_sensor: error
    homeassistant.components.binary_sensor.ping: error
    homeassistant.components.ping: error

eg.

Updating ping binary_sensor took longer than the scheduled update interval 0:00:02

4:20 PM helpers/entity_platform.py (WARNING)

Updating ping binary_sensor took longer than the scheduled update interval 0:00:02

4:20 PM helpers/entity_platform.py (WARNING)

So I just tried it myself. What I found is the messages don’t go into home-assistant.log anymore, but for some reason they still show up on the Info page in the frontend. I have no idea how this is possible.

I have these warnings for the ping binary_sensor as well. The state doesn’t get updated anymore once these appear and I noticed the Waze sensor gives the same warnings and doesn’t update anymore as well.

I disabled the ping binary_sensor for now to see if that solves the issue with Waze.

I’ve started seeing this with the ping binary_sensor too.

Edit: Should be fixed in the next release - https://github.com/home-assistant/home-assistant/pull/17606

In the meantime, you can manually revert the change by using this commit as a custom_component

Sorry to resurrect an old thread but this seems to still be an issue - have contributed to a GitHub report here: https://github.com/home-assistant/home-assistant/issues/24899

I am running HassOS/Hass.io on a Pi 3B+ and currently only have 2 ping binary sensors to detect on/off status of my dumb TV and dumb AV receiver to act as a virtual media player entity. Each sensor is set to refresh every minute, or a one-off update at a set interval following a command to turn on/off the entity. Timeout is left as the default 30s, I reduced count to 1 to try to improve stability, config.yaml is at the bottom of this post.

I wouldn’t have thought this would be over-taxing on the ping binary sensor component but usually within 24hrs following a restart I get the following error:

Updating ping binary_sensor took longer than the scheduled update interval 0:01:00
12:01 PM helpers/entity_platform.py (WARNING) - message first occured at July 29, 2019, 9:59 PM and shows up 830 times

It seems once the sensor fails to update, it then crashes itself completely and can’t be restarted without a reboot. The same problem occurs when using ping as part of a command line binary sensor as below:

binary_sensor:
  - platform: command_line
    name: AV Receiver
    command: ping -W 1 -c 1 192.168.1.147 > /dev/null 2>&1 && echo success || echo fail
    scan_interval: 10
    command_timeout: 10
    payload_on: "success"
    payload_off: "fail"

Unfortunately beyond the standard error logging I have been unable to find any further details on what is causing the errors and the timeouts but it would appear that the ping function needs modifications to the way it handles errors in-line.

I would be more than happy to try and get more a more in-depth error report if someone can point me in the right direction!

config.yaml:

binary_sensor:
  - platform: ping
    host: 192.168.1.147
    name: AV Receiver
    count: 1
    scan_interval: 60

  - platform: ping
    host: 192.168.1.192
    name: TV
    count: 1
    scan_interval: 60

media_player:
  - platform: universal
    name: AV Receiver
    commands:
      turn_on:
        service: script.av_receiver_switch_on
      turn_off:
        service: script.av_receiver_switch_off
      volume_up:
        service: script.av_receiver_volume_up
      volume_down:
        service: script.av_receiver_volume_down
      select_source:
        service: script.turn_on
        data_template:
          entity_id: >
            {% if source ==  'PC' %}
              script.av_receiver_PC
            {% elif source ==  'Cast' %}
              script.av_receiver_cast
            {% elif source ==  'XBOX 360' %}
              script.av_receiver_xbox_360
            {% elif source ==  'Audio' %}
              script.av_receiver_audio
            {% elif source ==  'USB' %}
              script.av_receiver_usb
            {% elif source ==  'TV' %}
              script.av_receiver_tv
            {% else %}
            {% endif %}
    attributes:
      state: binary_sensor.av_receiver
      source: input_select.av_receiver
  - platform: universal
    name: TV
    commands:
      turn_on:
        service: script.tv_switch_on
      turn_off:
        service: script.tv_switch_off
      select_source:
        service: script.turn_on
        data_template:
          entity_id: >
            {% if source ==  'TV' %}
              script.tv_input_tv
            {% elif source ==  'HDMI' %}
              script.tv_input_hdmi
            {% else %}
            {% endif %}
    attributes:
      state: binary_sensor.tv
      source: input_select.tv

My ping sensor seems fine, however I’m only pinging a single IP address.

Have you tried the nmap device tracker for seeing if your devices are on the network?

I found the nmap is good for multiple devices.

I have tried with NMAP and it works but for one reason or another (possibly to do with my router?) it is very slow to pick up when entities have disconnected from the network - ping works much, much faster, and given I’m using these sensors as a virtual switch I need the better responsiveness.

You can tweak nmap and change scan internal and timeout period. I’m pretty sure it’s just a glorified ping sensor though, so I think ping is better.

You can, but as scan_interval and consider_home are global settings then I would have to muck around with, and potentially break, the accuracy of my other device trackers (Google Maps, Bluetooth and BT Smart Hub scanners for presence detection)

EDIT: have tried to migrate everything to NMAP but struggling to get something passable. Ideally I want the sensors to update within 10 seconds so the template switches are responsive - but NMAP can’t seem to deal with a fast scan interval. With ping, I can set it to scan once a minute, but update the entity quickly after HA sends commands to turn the switch on or off. Just a shame it won’t work consistently!

Hi all

Hoping I don’t jinx it by saying this but I think it’s all fixed now. Tried many, many different ways to fix it but ended up settling with using my wifi device tracking and modifying the consider_home values on a per-device basis to get a good level of response.

For those suffering with lots of ‘took longer than the scheduled update interval’ problems - I eventually swore loudly and committed to a total reinstallation of HA. Immediately ran into issues with my SD card being corrupted - new card in, reinstalled, and now, now problems (I hope).

I can only conclude that these errors were getting caused by either a) a bloated installation requiring a reinstall and refresh OR b) the corrupted blocks on my SD card.

So do consider reinstallation or replacing your SD cards!

EDIT: nope, jinxed it. Problem still happening. I’m at a loss now.
See https://github.com/home-assistant/home-assistant/issues/24899 for latest updates

I might have foud a workround for this, at least it work for me using hassio on NUC. I ping around 45 systems and I do not have anymore the error messages.

You have to edit the source code, and reduce the ping interval.
If you run hassio, you have to edit the docker overlay. I do not want to go in the detail, but the step are.

1- docker exec -it homeassistant bash
2- edit the file /usr/src/homeassistant/homeassistant/components/ping/binary_sensor.py
3- add the parameter to reduce ping interval, I set mine to 0.2, from a defaul to 1.

      if sys.platform == "win32":
          self._ping_cmd = [
              "ping",
              "-n",
              str(self._count),
              "-w",
              "1000",
              self._ip_address,
          ]
      else:
          self._ping_cmd = [
              "ping",
              "-n",
              "-q",
              "-i0.2",  <===========  add this line
              "-c",
              str(self._count),
              "-W1",
              self._ip_address,
          ]

For windows based system, you have to edit the other ping command. This may not work on other platform, you have to check if your ping command support the interval parameter like in linux.

This will not survive a hassio update, you have to do it again.

I wonder if this could not be a fix by adding an interval parameter to te ping component.

This error has appeared again after 115 update but based on last GitHub issue opened for it was ignored don’t hold out much hope this time.