Can homeassistant send device del message

What is the mechanism for receiving the message that the homeassistant terminal device is deleted

Please explain

the homeassistant terminal device is that i use mqtt add to homeassistant

when i delete it can my mqtt client get the delete message

when i delete it can my mqtt client get the delete message

Yes, just listen to the topic

which topic

Everything in MQTT is done with a topic

yes, but how to let homeassistant send message to my mqtt client when i deleted devcie on homeassistant

Ok, now I understand the question. You want a MQTT client to detect you deleted a device (or entity ?) in HA.

Question: any device/entity, or just the ones that were created using MQTT discovery ?

Yeah, that’s it

The ‘or’ in that sentence means you have to choose one or the other. :wink:

device create using MQTT disvovery

device created using MQTT discovery,like this

{
  "~": "homeassistant/light/moorgen",
  "name": "moorgen",
  "uniq_id": "moorgen",
  "cmd_t": "~/set",
  "stat_t": "~/state",
  "availability":
  [
	{
		"topic":"~/online",
		"value_template": "{{ value_json.state }}"
	}
  ],
  "schema": "json",
  "brightness": true,
  "brightness_scale":100,
  "retain":true,
  "optimistic":false,
  "device":
  {
	"name":"moorgen",
	"model":"moorgen",
	"manufacturer":"moorgen",
	"identifiers":"moorgen"
  }
}

HA deletes it by sending an empty message to the topic that created it.

i try it but not receive delete message

topic: homeassistant/light/moorgen/config

when deleted receive tcp message but not mqtt message

not delete by mqtt client, deleted by HA can send message to my mqtt client

You can easily test it. Install mqtt explorer (https://mqtt-explorer.com/) and delete a device create by mqtt discovery. When you delete it in HA, you will see that HA sends an empty message to the topic that created it, which deletes it from the broker.