MQTT, discovery and ghost entries in entity_registry

Ok, so I decided to get with the program and try using discovery for MQTT. Being the cautious type I started with one Sonoff (which I call sonoff05). As usual in HA it doen’t seem to be plain sailing :wink:

All did seem to be ok at first, except that in the entity registry I have two instances of this sonoff switch with one being suffixed with _2

The newly discovered sonoff is switch.sonof05_2 and what must be the pre-discovery version being switch.sonoff05.

How do I remove the ghost entity? It does not appear either in the MQTT Integration nor the new Entity registry UI.

In my ‘storage’, I have ONLY the following in core.entity_registry

                "config_entry_id": "6bd29288c639478ea6cdcabfc9c8f2ee",
                "device_id": "270baf0544e64284b55d71ef55eb72bd",
                "disabled_by": null,
                "entity_id": "binary_sensor.sonoff05_btn_2",
                "name": null,
                "platform": "mqtt",
                "unique_id": "7A53EE_BTN_1"

(I don’t even know what binary_sensor.sonoff05_btn_2 is!)
And in core.restore_state I have BOTH this

            "last_seen": "2019-02-15T15:50:59.014206+00:00",
            "state": {
                "attributes": {
                    "friendly_name": "Sonoff05"
                },
                "context": {
                    "id": "33b2d50897c74c389bd6f3064203096b",
                    "user_id": null
                },
                "entity_id": "switch.sonoff05",
                "last_changed": "2019-02-15T15:32:47.613078+00:00",
                "last_updated": "2019-02-15T15:32:47.613078+00:00",
                "state": "off"

AND

            "last_seen": "2019-02-15T15:50:59.014206+00:00",
            "state": {
                "attributes": {
                    "friendly_name": "Sonoff05"
                },
                "context": {
                    "id": "b55a04c6b51245ccaf1adb684f844783",
                    "user_id": null
                },
                "entity_id": "switch.sonoff05_2",
                "last_changed": "2019-02-15T15:49:06.806896+00:00",
                "last_updated": "2019-02-15T15:49:06.806896+00:00",
                "state": "on"

try this

OR the last bit about deleting entites in here