Adding MQTT Devices without discovery

Hi,

I am using Zigbee2MQTT and although it does an amazing job with discovery true, I have my all setup on yaml (so fare at least) and automated, I am trying to configure a MQTT sensor with the device information on it.

Even if I use the configuration as documented the device doesn’t appear in the device list and configuration doesnt show any warning or error.

Any clue what am I doign wrong?

- platform: "mqtt"
  unique_id: "0x00158d000232a9ad_linkquality_zigbee2mqtt"
  name: frontdoor_contact_linkquality
  state_topic: "zigbee2mqtt/0x00158d000232a9ad"
  availability_topic: "zigbee2mqtt/bridge/state"
  json_attributes_topic: "zigbee2mqtt/0x00158d000232a9ad"
  unit_of_measurement: "lqi"
  value_template: "{{ value_json.linkquality }}"
  device_class: signal_strength
  device:
    identifiers: ["zigbee2mqtt_0x00158d000232a9ad"]
    manufacturer: "Xiaomi"
    model: "Aqara door & window contact sensor (MCCGQ11LM)"
    name: "0x00158d000232a9ad"
    sw_version: "Zigbee2mqtt 1.12.2"

Mqtt devices show only in de device list when discovered. You should see it in the entities list.

yes, I see I misread the documentation, it will only work through discovery. :frowning:

Given that zigbee2mqtt supports Home Assistant’s MQTT Discovery, it’s advantageous to use it.

There is another option. You can continue to define the entity manually and use MQTT Discovery. Create a script that publishes the sensor’s configuration to the appropriate discovery topic.

For example, here’s a simple script that creates two binary_sensors via MQTT Discovery:

#script:
  create_entities:
    alias: Create entities via MQTT Discovery
    sequence:
      - service: mqtt.publish
        data:
          topic: homeassistant/binary_sensor/bathroom_door/config
          payload: '{"name": "Bathroom Door", "state_topic": "home/sensor1", "device_class": "door", "unique_id": "abc123xyz"}'
          retain: true
      - service: mqtt.publish
        data:
          topic: homeassistant/binary_sensor/hallway_motion/config
          payload: '{"name": "Hallway Motion", "state_topic": "home/sensor2", "device_class": "motion", "off_delay": 5, "unique_id": "jkl789mno"}'
          retain: true

In your case, payload’s value will need to be more complex. Here’s a partial example (you’ll need to complete it) of the payload:

'{"name": "frontdoor_contact_linkquality", "device_class": "signal_strength", "state_topic": "zigbee2mqtt/0x00158d000232a9ad", "unique_id": "0x00158d000232a9ad_linkquality_zigbee2mqtt", "device": {"identifiers": ["zigbee2mqtt_0x00158d000232a9ad"],"name": "0x00158d000232a9ad", "model": "Aqara door & window contact sensor (MCCGQ11LM)", "manufacturer": "Xiaomi", "sw_version": "Zigbee2mqtt 1.12.2"}}'

The topic will be:

homeassistant/sensor/frontdoor_contact_linkquality/config

Resulting (partial) example is this:

      - service: mqtt.publish
        data:
          topic: homeassistant/sensor/frontdoor_contact_linkquality/config
          payload: >
            {
              "name": "frontdoor_contact_linkquality",
              "device_class": "signal_strength",
              "state_topic": "zigbee2mqtt/0x00158d000232a9ad",
              "unique_id": "0x00158d000232a9ad_linkquality_zigbee2mqtt",
              "device": {
                  "identifiers": ["zigbee2mqtt_0x00158d000232a9ad"],
                  "name": "0x00158d000232a9ad",
                  "model": "Aqara door & window contact sensor (MCCGQ11LM)",
                  "manufacturer": "Xiaomi",
                  "sw_version": "Zigbee2mqtt 1.12.2"
              }
            }
1 Like