MQTT_ROOM: Changed "name" attribute in YAML but sensors are not removed

I configured mqtt_room with 4 devices in configuration.yaml like this:

sensor:
  - platform: mqtt_room
    device_id: jimsiphone
    name: JimsBTPhone

A sensor.jimtBTiPhone was created, but an hour later I decided I didn’t like the name, so I changed it in the configuration.yaml and restarted HA:

sensor:
  - platform: mqtt_room
    device_id: jimsiphone
    name: Jimsiphone

The device_id: didn’t change - only the value of the “name:” attribute.
After the restart, the new sensor “sensor.Jimsiphone” was created - but the old one “sensor.jimsBTphone” was still present but it is unable to be deleted.

I saw a similar post about sensors that couldn’t be deleted: the advice that was given was to delete the integration, restart, delete the sensor and then reinstall the integration. I’m not sure how to delete the MQTT_room integration - but I did remove the MQTT_room configuration from the configuration.yaml and restarted - but the entities are still not delete-able. The message that is displayed is:

This entity ('sensor.jimsbtphone') does not have a unique ID, therefore its settings cannot be managed from the UI. See the [documentation](https://www.home-assistant.io/faq/unique_id) for more detail.

I’ve just shown one here - but there are 4 of them.
How can I get rid of them?

Where’s your state_topic?

That is a required configuration option.

Use MQTT Explorer to delete any retained messages for the old sensor from the broker then restart home assistant.

Hi Tom,

Thanks for your reply.

Hmm…. is it really required to have a state_topic? Or is there a default that gets used when it is not defined? (because it appears to be mostly working even without one). Nonetheless, I will try adding one. Thanks for pointing out the missing configuration.

As far as Mqtt Explorer is concerned, it doesn’t know anything about the friendly “name” attribute that I’ve defined in my configuration.yaml - it only knows about the actual “id” of the devices. I did look through MQTT anyways though and was not able to find any references to the friendly name used for the sensor entities.

Here’s another question about the stuff in MQTT.
So far I’ve added 1 iPhone, 2 iPads and 1 Apple Watch - but under /espresence/settings, I only see entries for the 3 iOS devices I paired. The watch does not show up there. Should it? I have added the Watch (correctly?) by finding it’s irk and adding it to the ESP32 configuration in the “Known BLE identity resolving keys” box.

I just went back to add it to my configuration.yaml - and it’s already there… :man_facepalming: (which probably explains why it’s “mostly working”)

I just didn’t include it in my original question because I didn’t think it could possibly be related to the problem I’m having with deleting sensors that no longer exist and I wanted to demonstrate that the “name” attribute was the thing that was changing. Having said that though, I’m not 100% sure I’m using the correct topic so I’ll paste the full configuration block now. I’m using that exact same topic for all of the devices.

sensor:
  - platform: mqtt_room
    device_id: jimsiphone
    name: Jimsiphone
    state_topic: "espresense/rooms"


(I’m using all of the defaults from the ESP32)