MQTT autodiscovery not working (zigbee2mqtt)

I’m trying to get zigbee2mqtt auto discovery in Home Assistant working, and somehow it’s not working for me.

  1. Home Assistant runs in Docker (v 2024.8.0) on the same machine as zigbee2mqtt and mosquitto
  2. HA can read and publish messages to mqtt (tested via mqtt config options)
  3. I have several manual mqtt sensors working, with HA both reading and writing to mqtt (tested by comparing mqtt messages with HA reported values, see config below)
  4. zigbee2mqtt does publish to homeassistant/# (see below)
  5. Home Assistant settings ‘enable newly added entities’ and ‘enable polling for updates’ are toggled on.

Any idea what might be going wrong? I feel I must be missing a simple toggle somewhere…

mqtt:
  sensor:
    - state_topic: 'smeter'
      name: 'smeter_consumption1'
      unique_id: 'smeter_consumption1'
      state_class: "total_increasing"
      unit_of_measurement: 'kWh'
      value_template: '{{ value_json.consumption1/3600/1000 | round(1) }}'
      device_class: energy
      force_update: true
      expire_after: 3600
    - state_topic: 'smeter'
      name: 'smeter_consumption2'
      unique_id: 'smeter_consumption2'
      state_class: "total_increasing"
      unit_of_measurement: 'kWh'
      value_template: '{{ value_json.consumption2/3600/1000 | round(1) }}'
      device_class: energy
      force_update: true
      expire_after: 3600
    - state_topic: 'smeter'
      name: 'smeter_production1'
      unique_id: 'smeter_production1'
      state_class: "total_increasing"
      unit_of_measurement: 'kWh'
      value_template: '{{ value_json.production1/3600/1000 | round(1) }}'
      device_class: energy
      force_update: true
      expire_after: 3600
    - state_topic: 'smeter'
      name: 'smeter_production2'
      unique_id: 'smeter_production2'
      state_class: "total_increasing"
      unit_of_measurement: 'kWh'
      value_template: '{{ value_json.production2/3600/1000 | round(1) }}'
      device_class: energy
      force_update: true
      expire_after: 3600
    - name: "itho_hru_co2"
      unique_id: "itho_hru_co2"
      state_topic: "itho/ithostatus"
      value_template: "{{ value_json['highest-received-co2-value_ppm'] }}"
      unit_of_measurement: "ppm"
      device_class: carbon_dioxide 
      state_class: 'measurement' 
      device: { identifiers: ["mqtt", "nrg-itho-28ac"] }
    - name: "itho_hru_exhaust_fan_actual"
      unique_id: "itho_hru_exhaust_fan_actual"
      state_topic: "itho/ithostatus"
      unit_of_measurement: "rpm"
      value_template: "{{ value_json['exhaust-fan-actual_rpm'] }}"
      device: { identifiers: ["mqtt", "nrg-itho-28ac"] }
    - name: "itho_hru_supply_fan_actual"
      unique_id: "itho_hru_supply_fan_actual"
      state_topic: "itho/ithostatus"
      unit_of_measurement: "rpm"
      value_template: "{{ value_json['supply-fan-actual_rpm'] }}"
      device: { identifiers: ["mqtt", "nrg-itho-28ac"] }
    - name: "itho_hru_exhaust_temp"
      unique_id: "itho_hru_exhaust_temp"
      state_topic: "itho/ithostatus"
      unit_of_measurement: "°C"
      device_class: temperature
      value_template: "{{ value_json['exhaust-temp_c'] }}"
      device: { identifiers: ["mqtt", "nrg-itho-28ac"] }
    - name: "itho_hru_supply_temp"
      unique_id: "itho_hru_supply_temp"
      state_topic: "itho/ithostatus"
      unit_of_measurement: "°C"
      device_class: temperature
      value_template: "{{ value_json['supply-temp_c'] }}"
      device: { identifiers: ["mqtt", "nrg-itho-28ac"] }
    - name: "itho_hru_summer_counter"
      unique_id: "itho_hru_summer_counter"
      state_topic: "itho/ithostatus"
      value_template: "{{ value_json['summercounter'] }}"
      unit_of_measurement: "h"
      device_class: duration
      state_class: 'measurement'
      device: { identifiers: ["mqtt", "nrg-itho-28ac"] }
    - name: "itho_hru_airfilter_counter"
      unique_id: "itho_hru_airfilter_counter"
      state_topic: "itho/ithostatus"
      value_template: "{{ value_json['airfilter-counter'] }}"
      unit_of_measurement: "h"
      device_class: duration
      state_class: 'measurement'
      device: { identifiers: ["mqtt", "nrg-itho-28ac"] }
  binary_sensor:
    - name: "itho_hru_bypass"
      unique_id: "itho_hru_bypass"
      state_topic: "itho/ithostatus"
      value_template: "{{ value_json['bypass-position'] }}"
      payload_off: 0
      payload_on: 1
      device_class: opening
      device: { identifiers: ["mqtt", "nrg-itho-28ac"] }
    - name: "itho_hru_summer"
      unique_id: "itho_hru_summer"
      state_topic: "itho/ithostatus"
      value_template: "{{ value_json['summerday_kmin'] }}"
      payload_off: 0
      payload_on: 1
      device_class: light
      device: { identifiers: ["mqtt", "nrg-itho-28ac"] }
  fan:
    - name: "itho_hru_fan"
      device:
        identifiers: ["mqtt", "nrg-itho-28ac"]
        model: ITHO Wifi Add-on
        name: itho_hru_fan_device
          #availability_topic: itho/state
      unique_id: itho_hru_fan
      state_topic: itho/lwt
      payload_on: "online"
      payload_off: "offline"
        #state_value_template: '{% if value == "online" %}ON{% else %}OFF{% endif %}'
        #      json_attributes_topic: itho/ithostatus
      command_topic: "itho/cmd"
      preset_mode_command_template: "{ vremote: '{{ value }}'}"
      preset_mode_command_topic: "itho/cmd"
      preset_mode_state_topic: "itho/ithostatus"
      preset_mode_value_template: >
       {% set am = value_json['actual-mode'] | int %}
         {% if am == 1 %}
           low
         {% elif am == 2 %}
           medium 
         {% elif am == 3 %}
           high
         {% elif am == 13 %}
            timer
         {% elif am == 24 %}
           auto
         {% elif am == 25 %}
           autonight
         {% else %}
           {{ am }}
         {% endif %}
      preset_modes:
       - "low"
       - "medium"
       - "high"
       - "auto"
       - "autonight"
       - "timer1"
       - "timer2"
       - "timer3" 
homeassistant/switch/0x00158d0003xxxxxx/switch/config {"availability":[{"topic":"zigbee2mqtt/bridge/state"}],"command_topic":"zigbee2mqtt/0x00158d0003xxxxxx/set","device":{"identifiers":["zigbee2mqtt_0x00158d0003xxxxxx"],"manufacturer":"Innr","model":"Smart plug (SP 120)","name":"0x00158d0003xxxxxx","sw_version":"2.0","via_device":"zigbee2mqtt_bridge_0x00212effff054066"},"json_attributes_topic":"zigbee2mqtt/0x00158d0003xxxxxx","name":null,"object_id":"0x00158d0003xxxxxx","origin":{"name":"Zigbee2MQTT","sw":"1.39.1","url":"https://www.zigbee2mqtt.io"},"payload_off":"OFF","payload_on":"ON","state_topic":"zigbee2mqtt/0x00158d0003xxxxxx","unique_id":"0x00158d0003xxxxxx_switch_zigbee2mqtt","value_template":"{{ value_json.state }}"}

Is auto-discovery enabled ?

Thanks, apparently that was the switch I missed! :slight_smile: