ESPHome device shows offline but connected when I check my router

I can’t seem to understand why the ESPHome device I is listed in my routers wifi connections but ESPHome sees it as offline. The only way to fix it is to reboot the router but this happens everytime the ESP device loses power.

Is there a way to fix this?

In the EspHome addon log it shows: edit?configuration=sprinkler_system.yaml (0.0.0.0) seems as if the IP is messed…

Device code:

esphome:
  name: sprinkler_system
  platform: ESP8266
  board: nodemcuv2
  includes:
    - shift_register_switch.h
  libraries:
    - [email protected]

wifi:
  ssid: "wifi_spot"
  password: "password"

switch:
  - platform: custom
    lambda: |-
      std::vector<switch_::Switch *> switches;
      for(int i = 0; i < 8; i++) {
          auto zone_switch = new ShiftRegisterSwitch(i);
          App.register_component(zone_switch);
          switches.push_back(zone_switch);
      }
      return switches;

    switches:
      -  name: "Sprinkler Zone 1"
         inverted: yes
      -  name: "Sprinkler Zone 2"
         inverted: yes
      -  name: "Sprinkler Zone 3"
         inverted: yes
      -  name: "Sprinkler Zone 4"
         inverted: yes
      -  name: "Sprinkler Zone 5"
         inverted: yes
      -  name: "Sprinkler Zone 6"
         inverted: yes
      -  name: "Sprinkler Zone 7"
         inverted: yes
      -  name: "Sprinkler Zone 8"
         inverted: yes

status_led:
    pin: 16

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

text_sensor:
  - platform: version
    name: esphome_sprinkler_system_esphome_version

Try using a static IP in your configuration. You could also try pinging “sprinkler_system.local” to see if mDNS is working properly. mDNS is how esphome determines if devices are on/offline, be default.

2 Likes

And if the suggestion from iridris isn’t working, you can set the option status_use_ping in the settings of your ESPHome installation (howeve you installed it). This changes the way ESPHome is looking for your device (with IP and not mDNS).

3 Likes

The static ip in the config did the trick, tks!

2 Likes

from HA yellow
image

from my pc

Pinging eh-switch-sonoff-m5-32ae70.local [192.168.50.121] with 32 bytes of data:
Reply from 192.168.50.121: bytes=32 time=479ms TTL=255
Reply from 192.168.50.121: bytes=32 time=71ms TTL=255
Reply from 192.168.50.121: bytes=32 time=91ms TTL=255
Reply from 192.168.50.121: bytes=32 time=127ms TTL=255

wifi signal is … OK thought the ping i ms seems quite high [23:22:15][C][wifi:367]: Signal strength: -52 dB ▂▄▆█

config

substitutions:
  hostname: eh-switch-sonoff-m5

esphome:
  name: $hostname
  comment: EH Shop Switch 2btn sonoff
  name_add_mac_suffix: True

wifi:
  use_address: 192.168.50.121

show as offline in eshome

name_add_mac_suffix is not resolved by the dashboard (makes sense)

1 Like

I know this thread is old, but if someone encounters this problem do the following:
-assign a static IP address to the ESP Device then define its address in the config
-remove the line „name_add_mac_suffix” from the config

  # Optional manual IP
  manual_ip:
    static_ip: 192.168.0.123
    gateway: 192.168.0.1
    subnet: 255.255.255.0
3 Likes

The issue for showing a device as offline in the esphome dashboard (while it is online and working) has two valid solutions:

  • fix mDNS in your network (Frequently Asked Questions — ESPHome)

    By default ESPHome uses mDNS to show online/offline state in the dashboard view.

  • set status_use_ping

    Alternatively, you can make esphome use ICMP pings to check the status of the device with the Home Assistant add-on "status_use_ping": true

3 Likes

Since you sound really confident about the valid solutions, can you tell me why my online device is still showing offline?

I have status_use_ping: true, and the status detection in esphome dashboard worked fine until I added a second device. Connection to device works fine, including viewing the logs wirelessly (from the esphome dashboard, ironically). I have since removed one of the devices, but nothing changed.

Both devices were unique in every aspect, IP, hostname, api key and ota password, so I’m just clueless.

There is also another issue, where it shows the update button (and HA notification) when the device has an esp firmware update available, but it doesn’t go away after pushing the update to the device. So, I’m wondering if there are some general issues in the whole device status thing in esphome.

I am neither confident nor knowledgeable but I have had everything go wrong at one time or another… so far I have found a fix for everything … however I usually sleep on the problem… do some more reading and find a solution on here somewhere!! For the nodes which showed as offline… I think I didn’t pursue it but eventually a new flash, firmware update and reboot sorted it… and worse case was a complete nuke of the dashboard and folders. A post of your yaml might be a good place to start.

Clearly there is, because ESPHome devices do not work like any other device. They’re not cable of stable MDNS and according to forum, require static IPs, which is a silly to suggest.

I forgot to get back to this, because I eventually switched from home assistant OS to core + esphome and the issues just went away. Same configs and all, so my guess now is that it had something to do with containers. And yes, they had (and have) static IPs

I’m on HASSOS+esphome and the problem persists.

1 Like

same. i got static IP.
esphome shows offline but i can easily connect and update yml code without any problem
image

can view logs too

I am seeing this more often lately. I haven’t tried this, but here is something I found:

By default, ESPHome utilizes mDNS to display the online/offline status of devices in the dashboard view. This method relies on the network’s ability to handle mDNS traffic effectively.

ESPHome can be configured to use pings to check the status of the device. This is done by setting status_use_ping: true in the device configuration.

1 Like

I found similar with one of my handfull of devices, the only one thats cb3s based.
It stopped once I added power_save_mode: none to it’s wifi: section

2 Likes

“None” is the default for ESP. I don’t know about the Tuya cb3s module.

This solved an issue I’ve been having for years! I always thought it was something specific on the ESP32 regarding MDNS - turns out it was the wifi power settings.

For the record, ESPHome documentation lists the power save mode default as NONE for ESP8266 and LIGHT for ESP32. Since my issue was always with the ESP32, flipping the mode to NONE on those fixed the issue.

1 Like

This helped with showing online in esphome, but HA still sees it unavailable because it constantly flips between online and offline…

The device itself worked until the latest update and is still pingable on both mDNS and IP and I do use static IP on all my nodes

I can also still update it in esphome, but it refuses to get logs. Sometimes with just time out and other times socket errors.

Is there a way to downgrade esphome so I can revert back to a working version for this particular node? Because this is pretty frustrating and it is only this one that fails now after the update.


nevermind about the downgrade of ESPHome, I just restored the old version from the backup.

But it seems to have something to do with this latest particular version (2024.5.0) because after the rollback and flashing the device again, it straigh on came back online again.

1 Like