esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
416 stars 26 forks source link

New sensor: Ping #242

Closed mseefeldt closed 2 years ago

mseefeldt commented 5 years ago

Describe the problem you have/What new integration you would like

Currently ESPHome already supports the Wifi and ethernet network. A sensor which can regularly ping a host and report back the response time would be great. (Similar to the HomeAssistant sensor)

Please describe your use case for this integration and alternatives you've tried:

I have a remote network to supervise (in a basement) where there is no cellular or wifi network available (massive construction, tons of steel in the walls). I need to monitor the hosts in the network and report the data regularly. Power consumption is an issue here since the monitoring needs to be battery powered to work as well during a power outage. So any ESP is a must, i can't use a raspberry pi with HomeAssistant.

Having the ping sensor would solve half of my problem, only the transmission towards my host is an another issue. LoRaWan does reach the outer world though but that's another feature.

Additional context

OttoWinter commented 5 years ago

See status binary sensor - that probably is the solution to the problem.

Also ICMP pings are pretty hard because the ESP SDK does not expose the necessary APIs last time I looked (there are some undocumented ones but they do not work well).

xdss commented 5 years ago

also interested in something like this within esphome, would implementation be similar to https://github.com/dancol90/ESP8266Ping

bepstein111 commented 4 years ago

Have been looking for this exact same function for weeks. Binary ping sensor which could return a simple true or false for the presence of a device on the network. Would be HUGE, I'm tellin ya!

adrianmihalko commented 4 years ago

This would be great. Ping a device on the network and cycle relay if ping failed (modem, powerline adapters sometimes need a restart). Combined with fail counter would make it a nice failover device.

randybb commented 4 years ago

Normally I would disagree as this can be implemented on HA itself and both are "sitting" on the same network, but yes - ESP can act as "watchdog" or remote reset device and then ping/snmp/ssh/telnet/nmap are essential.

magiva commented 4 years ago

being able to ping HA to see if its alive and then reset it would be a bonus when away from home and HA locks up

bperkins011 commented 4 years ago

I'd also like a ping. Vacation home has a network. Between the cable modem, the Unifi gateway, switch, Home Assistant, etc. Something always dies and there is no network and no one there to reboot something. If there was a ping that I could put in an IP address (8.8.8.8) and it came back - great. Otherwise I have it toggle the smartplug outlet - wait 15 minutes for it all to come back up and check again. A router watchdog reset for the power strip is the goal...

rmrfus commented 4 years ago

+1 for the feature. ping sensor would be helpful for watchdog type of things.

Fusseldieb commented 4 years ago

I have a flaky ESP32Cam which streams just fine, but if it's not being "watched"/"used", the connection becomes unstable and when I access it again it needs several seconds to recover (and sometimes even doesn't at all).

With a ping sensor I could let it be "active" the whole time pinging the Home Assistant Interface. I know, this is an awkward workaround, but if it works... :)

Another thing I've considered in my scenario is to prerecord the stream inside HA, so it's active at all times. Overheating should not be an issue, since I use it at 1fps, 640x480 res and 25 'quality' (has compression, but not too high).

sergeolkhovik commented 4 years ago

Three is a status sensor, i think it should work for you. I'm checking ESPHome device availability exactly with that status sensor.

пн, 28 вер. 2020 р., 15:04 користувач Valentino Stillhardt < notifications@github.com> пише:

I have a flaky ESP32Cam which streams just fine, but if it's not being "watched"/"used", the connection becomes unstable and when I access it again it needs several seconds to recover.

With a ping sensor I could let it be "active" the whole time pinging the Home Assistant Interface. I know, this is an awkward workaround, but if it works... :)

Another thing I've considered in my scenario is to prerecord the stream inside HA.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/esphome/feature-requests/issues/242#issuecomment-699964293, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNKUZFRSEABIS4MYHL2TYLSIB3T7ANCNFSM4HO2OWRA .

wasyl00 commented 3 years ago

+1 for ping. I would love to have ping sensor to be able to reboot my router when it freezes.

sandervandegeijn commented 3 years ago

Good idea, same use cases relevant to me as already described.

trombik commented 3 years ago

as I also needed ICMP sensor and wanted to learn the custom sensor component, just hacked up one today, nothing more than PoC, however.

https://github.com/trombik/esphome-component-ping

if you have more knowledge of esphome and C++ than I do, you should be able to rewrite it as an external component.

trombik commented 3 years ago

if you have more knowledge of esphome and C++ than I do, you should be able to rewrite it as an external component.

after painful "banging head on wall" hours, the component is not a custom component anymore.

external_components:
  - source:
      type: local
      path: ../components

sensor:
  - platform: ping
    ip_address: 8.8.8.8
    num_attempts: 17
    timeout: 1sec
    loss:
      name: Packet loss
    latency:
      name: Latency
      accuracy_decimals: 3
pilotak commented 3 years ago

@trombik you should make a PR! this is awesome

trombik commented 3 years ago

I will not create a PR because:

if you would like the code to be merged, you are welcome to help fixing the issues above. adding another +1 will not make it happen.

adrianmihalko commented 3 years ago

This is awesome, I hope it will be merged at some point.

bepstein111 commented 3 years ago

I will not create a PR because:

  • the code is not tested on esp32

So, 8266? What has it been tested with?

trombik commented 3 years ago

now both esp8266 and esp32 should work. see the README.md in the repository. bug reports, comments, and anything about the component should go to https://github.com/trombik/esphome-component-ping from now on.

Kilowatt-W commented 2 years ago

Really nice component, hope it will get standard at all :-)

lsaadeh commented 2 years ago

any update on this one

bepstein111 commented 2 years ago

any update on this one

On what? The link above works (https://github.com/trombik/esphome-component-ping) and @trombik explained why it isn't being integrated. You're welcome to make those fixes though!

marianomd commented 2 years ago

I want to check if esp is alive from another esp, then send a telegram alert if it's down. Would this be the correct way? Or is there something integrated that would fulfill this functionality?