ESPHome device working but showing "unavailable" in HA

I have several ESPhome devices but one is giving me issues. If I view the logs of the device on the ESPhome menu everything looks fine. It connects to the device and the logs show the state changes. But in HA the entities show as “unavailable” and I’m getting this in my logs:

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:520
Integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 10:51:34 PM (6 occurrences)
Last logged: 11:07:47 PM

* Platform esphome does not generate unique IDs. ID air-compressor-controlsensorair_tank_pressure already exists - ignoring sensor.air_tank_pressure
* Platform esphome does not generate unique IDs. ID air-compressor-controlsensorair_line_pressure already exists - ignoring sensor.air_line_pressure

Any idea how to fix this?

I think you should remove the device in devices and integrations, then re-add it again.

I tried that but the problem persisted.

Just a thought… does another device with the same name already exist?

Nope, that’s the only device with that name.

This weekend I had an IP address conflict with this ESP device and a TV. I corrected that conflict, rebooted my router, HA, and the ESP device.

Try removing the integration as well as the sensors:
air-compressor-controlsensorair_tank_pressure and
air-compressor-controlsensorair_line_pressure

And just a question…do you use static IP’s, or DNS name?
Could be an issue with MDNS :-/

I got it figured out. Somehow another ESPhome integration added my air compressor control ESP board to it’s integration. I have no idea how that happened, especially since the ESP integration that it was added to is for an ESP board that I’m not currently using. Very odd.

I removed the air compressor ESP integration and the integration that had falsely adopted the air compressor ESP board, did a restart, then added the air compressor board back on.

Sorry to revive this thread, but I found this because I was having the same behavior but it ended up being a difference root cause:

I had an IP conflict on my network, so the device would work fine when the other device wasn’t connected (sometimes for hours at a time) but fail to connect when the IP was taken.

Solution: narrow my DHCP server’s range of assignable IPs to not overlap with the static IP that I had given the ESPHome. I actually ended up putting my ESPHome devices on a separate subnet also, but that was after I resolved this issue.

Hope this helps someone.