I am puzzled by the API connection in ESPHome. This could be normal but I only detected this after using the status LED code (below) from @Protoncek in this thread.
When I first power up the ESP, I get the expected “not connected” flash pattern of “Lit, with quick off’s: No connection”. After 20-30 seconds the ESP connects to my WiFi network and I get the blink code of “Steady flashing: WiFi connection, no API”. And it stays that way. The API does not connect. When I open the log page on the ESPHome dashboard the blink pattern goes to “Short ‘on’ pulses: connected to WiFi and HA API”. When the logs window is closed, the blink pattern goes back to “Steady flashing: WiFi connection, no API”.
Is this normal?
#esp-test.yaml
substitutions:
device_name: esp-test
friendly_name: esp_test
led_pin: D4
packages:
wifi: !include common/wifi.yaml
device_base: !include common/esp8266.yaml
#Override the default board:
esp8266:
board: d1_mini
web_server:
port: 80
# Status light
# Lit, with quick off’s: No connection
# Steady flashing: WiFi connection, no API
# Short ‘on’ pulses: connected to HA API
#
interval:
- interval: 2s
then:
if:
condition:
wifi.connected:
then:
- if:
condition:
api.connected:
then:
- light.turn_on:
id: status_led
flash_length: 1950ms
else:
- light.turn_on:
id: status_led
flash_length: 1000ms
else:
- light.turn_on:
id: status_led
flash_length: 50ms
light:
- platform: binary
id: status_led
internal: true
output: status_led_out
output:
- id: status_led_out
platform: gpio
pin: ${led_pin}
######## Packages ########
#esp8266.yaml
esphome:
name: ${device_name}
esp8266:
board: esp01_1m
framework:
version: recommended
# Logger level "debug" is needed to get 1-Wire addresses, like the ds18b20.
logger:
level: DEBUG
# Set the log level for the light component to info
logs:
light: info
ota:
safe_mode: True
# Enable Home Assistant API
api:
#WiFi.yaml
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
sensor:
- platform: wifi_signal
name: ${friendly_name} WiFi Level
id: ${friendly_name}_WiFi_level
update_interval: 300s
# Get the WiFi details
text_sensor:
- platform: wifi_info
ip_address:
name: ${friendly_name} IP
ssid:
name: ${friendly_name} SSID
mac_address:
name: ${friendly_name} Mac Address