So it still disconnects with mostly bare config, interesting.
Do you still have any abort/crash messages in logs? (It looked like they were coming from temperature sensor code that you removed, but who knows if they’d be caused somewhere else)
The bare minimum configuration you quoted above should work fine, what you’re experiencing means that either something is wrong with your particular device (unlikely but possible)
… or there’s a software problem, ie. something is wrong with the code that many others are relying on, but many others might be lucky to not hit the same set of conditions as you are… This latter option, even though it’s less likely makes the issue you’re experiencing worth investigating.
You could perhaps run it with log_level: VERBOSE or log_level: VERY_VERBOSE.
Perhaps you could strip down the config even further, I’m thinking along the lines of disabling dns and gateway, removing ota since you have serial, perhaps even removing API component, which makes it impossible for it to talk to home assistant but it should still be able to hold its wifi and not reboot.
At that point I’d say you’d have enough useful information to file an official bug with @OttoWinter.
If nothing else, Otto might be able to narrow it down even more, or perhaps sprinkle some more logging to make this easier to debug.
Perhaps we should include some general debugging/troubleshooting workflows in a doc/post somewhere.
A couple of example scenarios and what ifs.
Can you share the code for how you implemented the uptime sensor? I’m having the exact same issue with all my NodeMCUs. I’d like to track iuptime as well to see just how bad it is. I really like the ESPhome features, especially the ease of deployment and monitoring. It would be a real shame to have to go back to MQTT, but this is driving me nuts.
When you say “exactly the same issue”, do you mean crashes/aborts in logs, or wifi disconnects, or reboots, or stuckness, … there’s a couple of people with different underlying problems in this thread. Also, which version of nodemcu do you have, what do you have currently connected to your GPIO?
The disconnects which then resets the device- at least that’s what shows in the log. I have a dozen of these: CP2102 ESP-12E, they are ESP8266 Boards. Absolutely Rock solid using NodeMCU firmware and MQTT, even several hundred feet away from WiFi on 2.4 or 5ghz.
Right now the one under test just has a 3v relay and a push button and an led indicator. I keep it toggled on, but it randomly toggles off by itself. I installed the dev branch 1.15.0 last nite at 2am just for kicks, and toggled the switch on. It was still on at 8am when I just checked it.
I used to get log entries of connect/disconnect every few minutes but it cluttered the log so I suppressed those msgs. If it helps, I can reenable the log and post it here.
Uptime Sensor installed successfully.
Jeff
More investigation has revealed that the relay/gpio I set up is cycling exactly 5 minutes all by itself. On,off,on,off,etc. no automation or script is tied to this device. The uptime sensor is at 100%, so it doesn’t appear to be WiFi or connection related.
Im very vexed. And perplexed. It happed even if I swap out the esp module with another one.
I used Various configurations, displays, sensors, relays, etc. a royal pain to upload and modify/debug but I used this for a year before I discovered home assistant. Rock solid using mqtt.
Try and disable logger and see if that resolves your network connection issues.
#logger:
I have many Sonoff Basics running ESPHome and suffered with network connection issues for a long time and went deep down the rabbit hole of troubleshooting. I finally read a thread where Otto recommended trying to disable logger. That fixed my issue. Seems logger was causing something to crash/restart that affects network, but not the uptime counter for the device. My NodeMCU and D1 Mini devices with more RAM didn’t have this issue. Good luck!
I was having similar device unavailable issues.
Since updating ESPHome to 1.15.0-dev, running Clean Build Files and then updating the node firmwares, I have no problems.