Is it possible to rename a MQTT entity?

Hello,

I create a entity via

mosquitto_pub -h "$addr" -p "$port" -u "$username" -P "$password" -t "homeassistant/switch/SW_test/config" -m "{"name": "test name", "object_id": "SW_test", "state_topic": "homeassistant/switch/SW_test/state", "unique_id": "some_SW_test", "command_topic": "homeassistant/switch/SW_test/state", "device": {"identifiers": ["Some device"], "name": "MyDevice", "sw_version": "1.0"}}"

Is it possible to change the name later? I thought of something similar to this

mosquitto_pub -h "$addr" -p "$port" -u "$username" -P "$password" -t "homeassistant/switch/SW_test/config" -m "{"name": "another name"}"

But it doesn’t work.

I don’t know. I do know, when you choose rename in Zigbee2MQTT, it deletes the device and creates a new one with the new name.

You’re right. At least the config topic has to be deleted and recreated with the new name. The state data isn’t lost as long as object_id/unique_id remain unchanged.