MQTT auto discovery isn't working, but messages are visible

Yes.

The ‘6 devices’ and ‘56 entities’ reported by the MQTT Integration were all created via MQTT Discovery.

Screenshot from 2020-08-21 12-12-40

Previously, I had defined them in configuration.yaml. However, you cannot define devices this way, only through MQTT Discovery. So I scrapped all the MQTT-based entities I had in the config file and created scripts to generate them via MQTT Discovery.

Here’s a fragment of one script that creates binary_sensors (just the first binary_sensor is shown):

  create_binary_sensors:
    alias: "Create binary_sensors via MQTT Discovery"
    sequence:
      - service: mqtt.publish
        data:
          topic: homeassistant/binary_sensor/front_door/config
          retain: true
          payload: >
            {
              "name": "Front Door",
              "device_class": "door",
              "state_topic": "premise/frontdoor/sensor/dooropened",
              "unique_id": "elk_m1_front_door_contact_sensor",
              "payload_on": "1",
              "payload_off": "0",
              "device": {
                  "identifiers": ["elk_m1_security_panel"],
                  "name": "ELK M1",
                  "model": "M1 Gold",
                  "manufacturer": "ELK",
                  "sw_version": "4.XX"
              }
            }

      - service: mqtt.publish
        data:
          topic: homeassistant/binary_sensor/rear_door/config
          retain: true
          #... etc ...
1 Like