Working ESPHome Sensor reported as Unknown in HA - how to debug

I have an outdoor temperature sensor which, when looking at the ESPHome Logs seems to send its status to HA without any issue. I use the native API (not MQTT).

But HA reports the device as “Unavailable” and there are no duplicate devices I can find which have been recreated instead. Any idea what could be going on or how to debug it?

Can you please copy and paste these beginning from rebooting the device.

Thanks for the prompt reply

INFO Reading configuration /config/esphome/bme280.yaml...
INFO Starting log output from 192.168.1.21 using esphome API
INFO Connecting to 192.168.1.21:6053 (192.168.1.21)
INFO Successfully connected to 192.168.1.21
[09:22:02][I][app:105]: ESPHome version 1.16.2 compiled on Apr 26 2021, 18:34:11
[09:22:02][C][status_led:019]: Status LED:
[09:22:02][C][status_led:020]:   Pin: GPIO15 (Mode: OUTPUT)
[09:22:02][C][wifi:443]: WiFi:
[09:22:02][C][wifi:303]:   SSID: 

[redacted]
[09:22:02][C][wifi:304]:   IP Address: 192.168.1.21
[09:22:02][C][wifi:306]:   BSSID: 

[redacted]
[09:22:02][C][wifi:307]:   Hostname: 'outside21'
[09:22:02][C][wifi:311]:   Signal strength: -70 dB ▂▄▆█
[09:22:02][C][wifi:315]:   Channel: 1
[09:22:02][C][wifi:316]:   Subnet: 255.255.255.0
[09:22:02][C][wifi:317]:   Gateway: 192.168.1.254
[09:22:02][C][wifi:318]:   DNS1: 8.8.8.8
[09:22:02][C][wifi:319]:   DNS2: 8.8.4.4
[09:22:02][C][i2c:028]: I2C Bus:
[09:22:02][C][i2c:029]:   SDA Pin: GPIO4
[09:22:02][C][i2c:030]:   SCL Pin: GPIO5
[09:22:02][C][i2c:031]:   Frequency: 50000 Hz
[09:22:02][I][i2c:033]: Scanning i2c bus for active devices...
[09:22:02][I][i2c:040]: Found i2c device at address 0x23
[09:22:03][I][i2c:040]: Found i2c device at address 0x76
[09:22:03][C][logger:185]: Logger:
[09:22:03][C][logger:186]:   Level: VERBOSE
[09:22:03][C][logger:187]:   Log Baud Rate: 115200
[09:22:03][C][logger:188]:   Hardware UART: UART0
[09:22:03][C][bme280.sensor:142]: BME280:
[09:22:03][C][bme280.sensor:143]:   Address: 0x76
[09:22:03][C][bme280.sensor:155]:   IIR Filter: OFF
[09:22:03][C][bme280.sensor:156]:   Update Interval: 90.0s
[09:22:03][C][bme280.sensor:158]:   Temperature 'Outside Temperature'
[09:22:03][C][bme280.sensor:158]:     Unit of Measurement: '°C'
[09:22:03][C][bme280.sensor:158]:     Accuracy Decimals: 1
[09:22:03][C][bme280.sensor:158]:     Icon: 'mdi:thermometer'
[09:22:03][C][bme280.sensor:159]:     Oversampling: 16x
[09:22:03][C][bme280.sensor:160]:   Pressure 'Outside Pressure'
[09:22:03][C][bme280.sensor:160]:     Unit of Measurement: 'hPa'
[09:22:03][C][bme280.sensor:160]:     Accuracy Decimals: 1
[09:22:03][C][bme280.sensor:160]:     Icon: 'mdi:gauge'
[09:22:03][C][bme280.sensor:161]:     Oversampling: 16x
[09:22:03][C][bme280.sensor:162]:   Humidity 'Outside Humidity'
[09:22:03][C][bme280.sensor:162]:     Unit of Measurement: '%'
[09:22:03][C][bme280.sensor:162]:     Accuracy Decimals: 1
[09:22:03][C][bme280.sensor:162]:     Icon: 'mdi:water-percent'
[09:22:03][C][bme280.sensor:163]:     Oversampling: 16x
[09:22:03][C][bh1750.sensor:027]: BH1750 'Outside Illuminance'
[09:22:03][C][bh1750.sensor:027]:   Unit of Measurement: 'lx'
[09:22:03][C][bh1750.sensor:027]:   Accuracy Decimals: 1
[09:22:03][C][bh1750.sensor:027]:   Icon: 'mdi:brightness-5'
[09:22:03][C][bh1750.sensor:028]:   Address: 0x23
[09:22:03][C][bh1750.sensor:048]:   Resolution: 0.5
[09:22:03][C][bh1750.sensor:049]:   Update Interval: 60.0s
[09:22:03][C][ota:029]: Over-The-Air Updates:
[09:22:03][C][ota:030]:   Address: 192.168.1.21:8266
[09:22:03][C][api:095]: API Server:
[09:22:03][C][api:096]:   Address: 192.168.1.21:6053
[09:22:55][D][bh1750.sensor:081]: 'Outside Illuminance': Got illuminance=1131.7lx
[09:22:55][V][sensor:013]: 'Outside Illuminance': Received new state 1131.666626
[09:22:55][D][sensor:092]: 'Outside Illuminance': Sending state 1131.66663 lx with 1 decimals of accuracy
[09:23:27][V][bme280.sensor:171]: Sending conversion request...
[09:23:27][D][bme280.sensor:197]: Got temperature=12.9°C pressure=1011.1hPa humidity=80.5%
[09:23:27][V][sensor:013]: 'Outside Temperature': Received new state 12.870000
[09:23:27][D][sensor:092]: 'Outside Temperature': Sending state 12.87000 °C with 1 decimals of accuracy
[09:23:27][V][sensor:013]: 'Outside Pressure': Received new state 1011.050781
[09:23:27][D][sensor:092]: 'Outside Pressure': Sending state 1011.05078 hPa with 1 decimals of accuracy
[09:23:27][V][sensor:013]: 'Outside Humidity': Received new state 80.483398
[09:23:27][D][sensor:092]: 'Outside Humidity': Sending state 80.48340 % with 1 decimals of accuracy
[09:23:55][D][bh1750.sensor:081]: 'Outside Illuminance': Got illuminance=1181.7lx
[09:23:55][V][sensor:013]: 'Outside Illuminance': Received new state 1181.666626
[09:23:55][D][sensor:092]: 'Outside Illuminance': Sending state 1181.66663 lx with 1 decimals of accuracy

This is how the device now shows in HA. It used to work fine until I upgraded HA a few days ago, first to 1.5.x (Can’t remember which) and now 1.6.1.

Try removing the device from Home Assistant and re-adding it manually.

If that’s the logs from boot, HA doesn’t make a connection. Similar section from my logs:

[09:33:33][C][captive_portal:169]: Captive Portal:
[09:33:33][C][ota:029]: Over-The-Air Updates:
[09:33:33][C][ota:030]:   Address: 192.168.1.39:8266
[09:33:33][C][ota:032]:   Using Password.
[09:33:33][C][api:095]: API Server:
[09:33:33][C][api:096]:   Address: 192.168.1.39:6053
[09:33:33][C][wifi_signal.sensor:009]: WiFi Signal 'Garage lux wifi signal'
[09:33:33][C][wifi_signal.sensor:009]:   Device Class: 'signal_strength'
[09:33:33][C][wifi_signal.sensor:009]:   Unit of Measurement: 'dB'
[09:33:33][C][wifi_signal.sensor:009]:   Accuracy Decimals: 0
[09:33:40][D][api.connection:617]: Client 'Home Assistant 2021.6.0 (192.168.1.7)' connected successfully!
[09:33:40][D][time:040]: Synchronized time: Fri Jun  4 09:33:40 2021
[09:33:40][D][bh1750.sensor:081]: 'Outside illuminance': Got illuminance=535.0lx
[09:33:40][D][sensor:099]: 'Outside illuminance': Sending state 535.00000 lx with 0 decimals of accuracy
[09:33:40][D][switch:021]: 'Garage light sensor onboard LED' Turning ON.
[09:33:40][D][switch:045]: 'Garage light sensor onboard LED': Sending state ON

Note the api.connection line. Try @tom_l’s suggestion (here’s how) first.

Thank you both - much appreciated and will revert when I have done so.

@tom_l - I’ve tried what you suggested. The new devices (different name) shows up in Home Assistant but the Sensor Entities are still listed as “Unavailable”

@Troon - the API Connection line does not seem to be there either on the new device.

Are there any errors in the log about it not having a unique id?

Apologies but I don’t think I ever had an error about not having a UniqueID? Is that in the device log or somewhere else?

Click this:

Open your Home Assistant instance and show your Home Assistant logs.

There is no reference to that sensor in that log…

And you definitely have this in your ESP config:

api:

Here’s the complete yaml file - which has worked for months:

esphome:
  name: outside
  platform: ESP8266
  board: d1_mini_pro

status_led:
  pin: GPIO15

wifi:
  manual_ip:
    static_ip: 192.168.1.21
    gateway: 192.168.1.254
    subnet: 255.255.255.0
    dns1: 8.8.8.8
    dns2: 8.8.4.4
  reboot_timeout: 45min
  networks:
  - said: <redacted>
    password: <redacted>

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Outside Sensors Fallback Hotspot"
    password: <redacted>

captive_portal:

# Enable logging
logger:
  level: VERBOSE

# Enable Home Assistant API
api:

ota:

sensor:
  - platform: bme280
    temperature:
      name: "Outside Temperature"
      oversampling: 16x
    pressure:
      name: "Outside Pressure"
    humidity:
      name: "Outside Humidity"
    address: 0x76
    update_interval: 90s
  # - platform: bh1750
    # name: "Outside Illuminance"
    # address: 0x23
    # update_interval: 90s

i2c:
  sda: D2
  scl: D1
  scan: true

typo ?

  networks:
  - said: <redacted>
    password: <redacted>
  networks:
  - ssid: <redacted>
    password: <redacted>
1 Like

Yes obviously that’s a typo - otherwise I would not receive the logs :slight_smile:

@tom_l - any further thoughts? (This doesn’t make any sense to me either…)

Does anyone have any further thoughts on this? The sensor randomly seems to start working/stop working. I can always retrieve the logs and upload the firmware so the wifi communication seems to work fine.

But the HA-API comms seems to fail regularly and unpredictably and when that happens the sensor shows as “Unavailable” in-home assistant?

Happy to spend some time debugging further but don’t know where to start.