twocolors / node-red-contrib-esphome

Node-RED nodes to ESPhome devices
MIT License
18 stars 5 forks source link

Is there a property I can query to get the IP address of an esphome node? #46

Closed DeeBeeKay closed 4 months ago

DeeBeeKay commented 4 months ago

Hi @twocolors

I am trying to implement a sort of "heartbeat" so that I can detect if an important device goes offline for some reason. But right now I have to maintain a list of IP addresses to ping; this is not very convenient and it becomes painful as the list grows longer.

It would be much easier if I could simply query the node what its IP is, because I could write more universal code.

Once again, many thanks for your work on this.

twocolors commented 4 months ago

you can ping device via mdns name

C:\Users\free>ping bathroom-light.local

Обмен пакетами с bathroom-light.local [192.168.0.119] с 32 байтами данных:
Ответ от 192.168.0.119: число байт=32 время=10мс TTL=255
Ответ от 192.168.0.119: число байт=32 время=1мс TTL=255
Ответ от 192.168.0.119: число байт=32 время=1мс TTL=255

read about mdns and util avahi

DeeBeeKay commented 4 months ago

Thank you. I did use ping in the end; had to learn how to use arrays. Thank you.