ESP8266 D1 mini wifi problem | unavailable

Hi there,

Since quit some time I have a problem with one of my ESP8266 D1 mini.
It worked well for over one year but now it becomes unavailable during the day.
The project I use is: https://github.com/Scriptman/ESPHome_ITHO_Eco_Fan_CC1101

My yaml code:

esphome:
  name: itho_eco_fan
  platform: ESP8266
  board: d1_mini
  includes: 
    - itho_eco_fan/itho/cc1101.h
  libraries:
    - SPI
    - Ticker
    - https://github.com/Scriptman/ESPHome_ITHO_Eco_Fan_CC1101.git

wifi:
  networks:
  - ssid: "XXXXX"
    password: "XXXXXX"
  manual_ip:
    static_ip: 192.168.xxx.xx
    gateway: 192.168.xxx.xx
    subnet: 255.255.255.0
    dns1: 8.8.8.8
    dns2: 8.8.4.4
  ap:
    ssid: "Itho Eco Fan Fallback Hotspot"
    password: "xxxxxxxxxxxx"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "xxxx"

ota:
  password: "xxxx"

switch:
- platform: custom
  lambda: |-
    auto fansendlow = new FanSendLow();
    App.register_component(fansendlow);
    return {fansendlow};
  switches:
    name: "FanSendLow"
    icon: mdi:fan

- platform: custom
  lambda: |-
    auto fansendmedium = new FanSendMedium();
    App.register_component(fansendmedium);
    return {fansendmedium};
  switches:
    name: "FanSendMedium"
    icon: mdi:fan

- platform: custom
  lambda: |-
    auto fansendhigh = new FanSendHigh();
    App.register_component(fansendhigh);
    return {fansendhigh};
  switches:
    name: "FanSendHigh"
    icon: mdi:fan

- platform: custom
  lambda: |-
    auto fansendt1 = new FanSendIthoTimer1();
    App.register_component(fansendt1);
    return {fansendt1};
  switches:
    name: "FanSendTimer1"

- platform: custom
  lambda: |-
    auto fansendt2 = new FanSendIthoTimer2();
    App.register_component(fansendt2);
    return {fansendt2};
  switches:
    name: "FanSendTimer2"

- platform: custom
  lambda: |-
    auto fansendt3 = new FanSendIthoTimer3();
    App.register_component(fansendt3);
    return {fansendt3};
  switches:
    name: "FanSendTimer3"

- platform: custom
  lambda: |-
    auto fansendjoin = new FanSendIthoJoin();
    App.register_component(fansendjoin);
    return {fansendjoin};
  switches:
    name: "FanSendJoin"

# Rinse/repeat for the timers
# see outstanding question in cc1101.h
# on multiple switches handling

text_sensor:
- platform: custom
  lambda: |-
    auto fanrecv = new FanRecv();
    App.register_component(fanrecv);
    return {fanrecv->fanspeed,fanrecv->fantimer};
  text_sensors:
    - name: "FanSpeed"
    - name: "FanTimer"

A snapshot from my logs:

Does anyone have a solution for me? I have searched but couldn’t find one.

Thanks in advance

Bastiaan

Please post also your device logs, the HA logs doesn’t give information about what’s happening with de device itself.

@jsuanet thanks for your answer.
Where can I find those logs? I looked at: system → Devices → esp-home → device and I get this:

Is this the one ?

No, it’s in the ESPHome dashboard or you can get it with esphome logs <devicename>.yaml if you are using the CLI version of ESPHome.

I only get this when I go to “logs” in ESPHome:

Well, there are already messages about “unknown state” from the custom component, that sounds not good. And you have to wait till the device becomes unavailable to get more information about the reason. Is it the Wifi, a reboot of the device or another error. If possible a serial log would be the best, then crashes and reboots are better visible.

Any chance you recently replaced your WiFi AccessPoint/router?

ESPHome has been seen randomly disconnecting from HA when connected via some AP’s. You may be experiencing that if the signal strength/quality between the ESP device and its AP is relatively low. Or it may be caused by an already-weak WiFi signal being pushed below the useful level by additional traffic (e.g. that only happens during the day).
[If this is the syndrome that’s causing your situation] the disconnects will not show up in the ESP’s logs, but HomeAssistant will show them as becoming ‘unavailable’ for brief moments, then they soon become available again.

@glyndon
thanks for your comment
I did have to reconfigure my router a while ago. Even set a different SSID and password. But the connection was fine after that.

@jsuanet
thanks for thinking along.

You can get a longer term esphome log by running from the commandline

esphome logs mydevice.yaml 

If you are using the esphome addon, you can enter the addon container to run it

docker exec -it addon addon_15ef4d2f_esphome-dev bash
cd /config/esphome

Then run the above. Your container name may be different. Check it with

docker ps|grep esphome
1 Like

Make sure you’re not doing too much delay()-ing inside the loop() method or even update() method.

This can cause devices to go offline.

2 Likes

@phillip1 Thanks but I’m not sure what you mean. Dit you see any delay or update in my code? Can I change those values?

He is just saying that you need to carefully check your code for excessive delays. That includes the libraries you import/include.

1 Like

@nickrout my mistake, thank you very much

Thanks for clarifying :grinning_face_with_smiling_eyes: