ESPHome MQTT Entities Not avail

Hello guys…

In my current Home Assistant project, I am facing the following problem: MQTT-based entities are displayed in the frontend but are marked as “unavailable.” I am using an ESPHome device connected to the Mosquitto broker, and the connection itself seems stable. The broker correctly receives the messages, but Home Assistant does not seem to interpret or process the payloads.

Since I am relatively new to MQTT, I kindly ask for guidance and tips on what I might have overlooked or misconfigured.

Bullet Point Error Description:
1. Entity Display: The switches are correctly displayed in Home Assistant under “Devices” and “Entities.”
2. Status “Unavailable”: Despite being displayed, the entities are not usable and remain marked as “unavailable.”
3. MQTT Connection Successful: The broker receives the messages, as confirmed using MQTT Explorer.
4. Payload Issue: The data sent to the state_topic and availability topics does not seem to be recognized by Home Assistant.
5. Discovery Functionality Uncertain: Although the discovery function is enabled, I am unsure if Home Assistant is correctly processing the configuration messages.

Code Configuration:

Here is the code from my ESPHome YAML file, which I use for the MQTT integration and switches:

 
mqtt:
  broker: 192.168.178.123
  username: !secret mqtt_user
  password: !secret mqtt_password
  port: 1883
  client_id: doorbell
  topic_prefix: homeassistant
  discovery: true
  discovery_prefix: homeassistant

switch:
  - platform: template
    id: "0G"
    optimistic: True
    availability:
      topic: doorbell/0G/status
      payload_available: online
      payload_not_available: offline
    state_topic: doorbell/0G
    command_topic: doorbell/0G/set

  - platform: template
    id: "EG"
    optimistic: True
    availability:
      topic: doorbell/EG/status
      payload_available: online
      payload_not_available: offline
    state_topic: doorbell/EG
    command_topic: doorbell/EG/set

Can someone help me with this?

First of all, is there a reason you are using the mqtt connection instead of the esphome API?

I had the Problem that the API lost connections to homeassistant.

So i decided to try somthing new.

I don’t use mqtt. Your 2 entities have no name only an id. When using the api not setting a name makes the entity hidden and not available outside the esp itself. I assume this is the same with mqtt.

1 Like