Duplicated "mqtt_sensor" with zigbee2mqtt and discovery

Hello. Clearly I have managed to louse up my configuration, but I am not sure how.

TL;DR

Hass.io (supervisor v140?), Raspberry PI3b, Home Assistant 0.83.1, zigbee2mqtt v0.2.0
sensors talking zigbee to mqtt to home assistant have nice “Friendly Names” but also have a set of “MQTT_Sensor” duplicated copies each.
I would like to remove the duplicates, ideally ending up with each sensor named something under my control.
mqtt_sensors_1

Details

So I have a count of Xiaomi Aqara sensors talking zigbee to zigbee2mqtt talking to Home Assistant.

I have manually entered a “Friendly Name” for each sensor in zigbee2mqtt’s configuration.yaml, and sensors named for these appear in my history and I can attach groups to them, so that works nice.

But I also have a dozen “sensor.mqtt_sensor_$X” each with a friendly name of “MQTT Sensor”, showing as little red circles outside the groups in the image above. Ungrouped sensors show as red/blue circles with the friendly name - “router1”, “sense_door_1”, and so forth.

I suspect discovery and my manually entered values are fighting, but I am not sure how to fix things.

Back in 0.81, I only had one MQTT_sensor, so I set it to ‘hidden’ and carried on. But after updating to 0.83.1 and now I have a dozen or more so it may be time to fix things :wink:

Configuration Files

Main configuration.yaml:

homeassistant:
  name: Hame
  customize: !include customize.yaml
  # ...
frontend:
config:
updater:

mqtt:
  broker: core-mosquitto
  username: !secret mqtt_core_user
  password: !secret mqtt_core_password
  discovery: true
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'

discovery:

sensor:
  - platform: "mqtt"
    state_topic: "zigbee2mqtt/sense_thp_1"
    availability_topic: "zigbee2mqtt/bridge/state"
    unit_of_measurement: "°C"
    icon: "mdi:temperature-celsius"
    value_template: "{{ value_json.temperature }}"
    json_attributes: 
      - "battery"
      - "voltage"
      - "linkquality"
  - platform: "mqtt"
    state_topic: "zigbee2mqtt/sense_thp_1"
    availability_topic: "zigbee2mqtt/bridge/state"
    unit_of_measurement: "%"
    icon: "mdi:water-percent"
    value_template: "{{ value_json.humidity }}"
    json_attributes: 
      - "battery"
      - "voltage"
      - "linkquality"
  - platform: "mqtt"
    state_topic: "zigbee2mqtt/sense_thp_1"
    availability_topic: "zigbee2mqtt/bridge/state"
    unit_of_measurement: "Pa"
    icon: "mdi:speedometer"
    value_template: "{{ value_json.pressure }}"
    json_attributes: 
      - "battery"
      - "voltage"
      - "linkquality"
# ... repeat about 15 times ...

# Cloud (google, alexa, etc integration)
#cloud:

script: !include scripts.yaml
group: !include groups.yaml
automation: !include automations.yaml

I am using groups.yaml to group the sensors into little cards. No lovelace (yet).

  thp1_group:
    name: Environment Sensor 1
    icon: mdi:temperature-celsius
    entities:
      - sensor.sense_thp_1_linkquality
      - sensor.sense_thp_1_temperature
      - sensor.sense_thp_1_humidity
      - sensor.sense_thp_1_pressure
# ... repeat about 15 times ...

zigbee2mqtt configuration json has {“homeassistant”: true, “permit_join”: false}
zigbee2mqtt configuration.yaml:

devices:
  '0x00158d000234xxxx':
    friendly_name: sense_thp_1
    retain: true
# ... repeat about 15 times ...
homeassistant: true
mqtt:
  base_topic: zigbee2mqtt
  password: <password>
  reject_unauthorized: false
  server: mqtts://<ip>:<port>
  user: <user>
permit_join: false
serial:
  disable_led: true
  port: /dev/ttyACM0

(I can grab the MQTT messages on zigbee2mqtt start if that is useful, I have resisted so far, to prevent wall-of-text syndrome)

Next steps

I have experimented with turning off “discovery” in configuration.yaml, but that seems to make things worse. I figure I should ask for help before I break things even more completely! :slight_smile:
Does anyone have any suggestions for where I should look or what I should try next?

  • Should I try to delete my manually created sensors from the main configuration.yaml and look for a way to discriminate the Friendly Name: “MQTT Sensors” and rename them something useful?
  • or some other approach entirely?

Thanks!

Release 0.83.2 mentions discovery, hashes, and unique ids, leading me to github pull 18763. I wonder if this is relevant to my dozen duplicated devices…

I will update and test deleting entries from discovery to determine if the duplicated devices also depart.