ESPHOME NODEMCU: LEDs become unavailable

Hi,
I am using LEDs connected to ESPHome NodeMCU 8266 to indicate Arm (Red) & Disarm (Green) state of my manual alarm. The issue is that the LEDs randomly become unavailable and goes off. Logbook:

7:54 AM [Red LED] turned off
7:54 AM [Green LED] turned off
7:54 AM [Red LED] changed to unavailable
7:54 AM [Green LED] changed to unavailable
7:27 AM [Red LED] turned off
7:27 AM [Green LED] turned off
7:27 AM [Red LED] changed to unavailable
7:27 AM [Green LED] changed to unavailable

Below is the configuration file (.yaml)
. . .
esphome:
name: hallway
platform: ESP8266
board: nodemcuv2

wifi:
ssid: “my_ssid”
password: “my_password”
fast_connect: true
manual_ip:
static_ip: 192.168.1.151
gateway: 192.168.1.1
subnet: 255.255.255.0
dns1: 192.168.1.1

output:

  • platform: gpio
    pin: D1
    id: ‘red_led’
  • platform: gpio
    pin: D2
    id: ‘green_led’

light :

  • platform: binary
    name: “Red LED”
    output: ‘red_led’
    restore_mode: ALWAYS_OFF
  • platform: binary
    name: “Green LED”
    output: ‘green_led’
    restore_mode: ALWAYS_OFF
    . . .
    Any advise what’s going wrong here. I am using Call Service (through Node-Red) to switch LEDs on/off.

Thanks,

I would turn on the esphome wifi signal strength monitor to see how well your wifi system is being received by the 8266.

The signal strength is around -13 dB. In fact, I kept the NodeMCU close to the router to rule out any signal problem but still the issue continues. Interestingly ESPHome shows online on the dashboard but the LEDs goes unavailable.

Please format your code properly.

Perhaps the 8266 was busy the first time the state was requested or it couldn’t respond fast enough for HA? BTW if you click on the icon </> on the bar at the top of the input text window it created a text section that you can paste your code into and it preserved spaces correctly, etc. Makes reading code easier.

esphome:
  name: hallway
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "myssid"
  password: "mypassword"
  fast_connect: true
  manual_ip:
    static_ip: 192.168.1.151
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    dns1: 192.168.1.1
    
# Enable logging
logger:
  level: VERBOSE

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

ota:
  password: "mypassword"


    
output:
  - platform: gpio
    pin: D1
    id: 'red_led'
  - platform: gpio
    pin: D2
    id: 'green_led'
    
    
light :
  - platform: binary
    name: "Red LED"
    output: 'red_led'
    restore_mode: ALWAYS_OFF
  - platform: binary
    name: "Green LED"
    output: 'green_led'
    restore_mode: ALWAYS_OFF

Thanks, so much easier to read!

What are your esphome logs saying? Click on Show Logs in the gui, or run

esphome filename.yaml logs

redirect to a file if you want to look through it later or post here

esphome filename.yaml logs > filename.txt
INFO Reading configuration...
INFO Starting log output from 192.168.1.151 using esphome API
INFO Connecting to 192.168.1.151:6053 (192.168.1.151)
INFO Successfully connected to 192.168.1.151
[10:06:04][I][app:096]: esphome version 1.13.6 compiled on Oct 25 2019, 22:01:33
[10:06:04][C][wifi:372]: WiFi:
[10:06:04][C][wifi:254]:   SSID: [redacted]
[10:06:04][C][wifi:255]:   IP Address: 192.168.1.151
[10:06:04][C][wifi:257]:   BSSID: [redacted]
[10:06:04][C][wifi:258]:   Hostname: 'hallway'
[10:06:04][C][wifi:262]:   Signal strength: -49 dB ▂▄▆█
[10:06:04][C][wifi:263]:   Channel: 9
[10:06:04][C][wifi:264]:   Subnet: 255.255.255.0
[10:06:04][C][wifi:265]:   Gateway: 192.168.1.1
[10:06:04][C][wifi:266]:   DNS1: 192.168.1.1
[10:06:04][C][wifi:267]:   DNS2: 0.0.0.0
[10:06:04][C][gpio.output:010]: GPIO Binary Output:
[10:06:04][C][gpio.output:011]:   Pin: GPIO5 (Mode: OUTPUT)
[10:06:04][C][gpio.output:010]: GPIO Binary Output:
[10:06:04][C][gpio.output:011]:   Pin: GPIO4 (Mode: OUTPUT)
[10:06:04][C][logger:137]: Logger:
[10:06:04][C][logger:138]:   Level: VERBOSE
[10:06:04][C][logger:139]:   Log Baud Rate: 115200
[10:06:04][C][logger:140]:   Hardware UART: UART0
[10:06:04][C][light:174]: Light 'Red LED'
[10:06:04][C][light:174]: Light 'Green LED'
[10:06:04][C][ota:029]: Over-The-Air Updates:
[10:06:04][C][ota:030]:   Address: 192.168.1.151:8266
[10:06:04][C][ota:032]:   Using Password.
[10:06:04][C][api:103]: API Server:
[10:06:04][C][api:104]:   Address: 192.168.1.151:6053

I have posted the Log output. Thanks to micque and nickrout for looking into this. Based on your inputs that problem can be related to Signal strength, I kept the NodeMCU a bit far from the router. I read that too strong signal (-13dB) can also be an issue. Will monitor for a day and let you know.

How did your testing go after monitoring for a day?