Problems with old UIDs for Zigbee devices

Hello,
I’m restructuring my Openhab-Network including Nous-Zigbee-switches.
Configuration is : Openhab 5.0.3 with zigbee2MQTT and mosquitto
The first experimental configuration worked fine and without problems.

Then I decided to implement a new configuration with new Device-names/UIDs.
Zigbee2MQTT still works fine with the rediscovered devices and I’m able to switch power with the zigbee2MQTT-GUI.

I’m also able to add the switches as new things from the Inbox in Openhab, but I’m not able to switch power from Openhab. Instead I can see the error messages

debug: z2m:mqtt: Received MQTT message on ‘zigbee2mqtt/Tuya-Switch-3_0xa4c1380993d3d455/set’ with data ‘OFF’
error: z2m: Entity ‘Tuya-Switch-3_0xa4c1380993d3d455’ is unknown
debug: z2m:mqtt: Received MQTT message on ‘zigbee2mqtt/Tuya-Switch-3_0xa4c1380993d3d455/set’ with data ‘ON’
error: z2m: Entity ‘Tuya-Switch-3_0xa4c1380993d3d455’ is unknown

“Tuya-Switch-3” is the old identifier which I had added previously to the UID. Openhab is using the old names as MQTT-topics has obviously not replaced them by the new ones!

Does anybody know how to proceed correctly:

  • can I delete this kind of old informations in Openhab?? Deleting the things doesn’t help.
  • can I advise Openhab to take the new modified names from Zigbee2MQTT-discovery?

Thanks in advance for help
Hans-Peter

Have you linked these new Things to your Items?

Have your removed the links from these Items to the old Things?

What I’ve done:
-I removed the old thing

  • then I created the the same thing with another name from Inbox
  • then I created an equipment from this thing with all its channels selected
  • in the model I navigate to the new equipment, toggle it and then always receive this error

So maybe this procedure was not ok due to my poor knowledge. I thought that with the removal of the thing all sub-objects like (orphaned?) links to it were also gone and that they are recreated with the creation of the equipment.
In the Inbox the Nous-switches appeared with their old name ( not with the new name visible in zigbee2MQTT !!) but to be consistenI with zigbee2MQTT I replaced the the name with same name as in zigbee2MQTT.

I can’t see any parameter in the channels and links which shows the old name of the thing and I don’t know where to look for it.
Do you have a link to a description of how to procede in this case with removing things and links and recreate them?
Thanks for your help

With development utilities I’ve dumped the thing definitions and extracted the relevant part:

the label of my switch has the same new user friendly name as the zigbee2MQTT-object,
but there is also a config section (which is otherwise hidden in the GUI?) which show the old previous name “Tuya-Switch-3” (e.g. object_id, command_topic,…).

Since toggle with zigbee2MQTT works fine, I suppose that these old data are stored in Openhab???

———————————————————————————————-
mqtt:homeassistant:f58b8fb22f:zigbee2mqtt_5F0xa4c1380993d3d455:
bridge: mqtt:broker:f58b8fb22f
label: NEW USER_FRIENDLY_NAME_0xa4c1380993d3d455
config:
topics:

    - switch/0xa4c1380993d3d455/switch

channels:
  switch:
    type: ha-switch
    label: MQTT Switch
    config:
      component: switch
      nodeid: 0xa4c1380993d3d455
      objectid:
        - switch
      config:
        - "{\"availability\":[{\"topic\":\"zigbee2mqtt/bridge/state\",\"value_template\":\"{{ value_json.state }}\"}],\"command_topic\":\"zigbee2mqtt/Tuya-Switch-3_0xa4c1380993d3d455/set\",\"device\":{\"identifiers\":[\"zigbee2mqtt_0xa4c1380993d3d455\"],\"manufacturer\":\"Tuya\",\"model\":\"Smart plug (with power monitoring) (TS011F_plug_1)\",\"name\":\"Tuya-Switch-3_0xa4c1380993d3d455\",\"via_device\":\"zigbee2mqtt_bridge_0x00124b0026b68201\"},\"name\":null,\"object_id\":\"tuya-switch-3_0xa4c1380993d3d455\",\"origin\":{\"name\":\"Zigbee2MQTT\",\"sw\":\"1.42.0\",\"url\":\"https://www.zigbee2mqtt.io\"},\"payload_off\":\"OFF\",\"payload_on\":\"ON\",\"state_topic\":\"zigbee2mqtt/Tuya-Switch-3_0xa4c1380993d3d455\",\"unique_id\":\"0xa4c1380993d3d455_switch_zigbee2mqtt\",\"value_template\":\"{{ value_json.state }}\"}"

When you removed the old Thing did you remove the links to the Items? Did you remove the Items?

Those options are on the Channels tab. If you are not going to recreate the Thing with the same UID it’s best to remove at least the Links. Sometimes it makes sense to remove the Items too.

If you didn’t remove the old links and Items, they are still around, possibly being used by your rules, sitemaps, MainUI, etc.

There are lots of reasons one might remove a Thing and not all of them would it be desired to remove the Links and Items too. That’s why it’s a separate step.

A Thing doesn’t really have a “name”. Do you mean the UID or the label?

At this point you need to find the old Equipment and the Items under that and delete those Items. The Health system should pick up the orphaned links and when you go to the settings page eventually it will pop up with a warning about some health problems and let you remove the orphaned links.

Everything OH gets with the new Thing comes from the messages posted to the MQTT topics . So if it’s there that means zigbee2mqtt published that information.

I find it very helpful to use a tool like MQTT Explorer to monitor the messages between Z2M and OpenHAB so you can see exactly what’s going on..

Thanks for your suggestions. I’ll try to check that during the next weekend.:+1:

I think I’ve solved my problem with the help of the MQTT-Explorer and by tracing mqtt-messages
by

  • deleting everything I could find in Openhab (links, items,…) related to my switches
  • cleaning the openhab cache
  • deleting the mosquitto-database
  • restarting all openhab/zigbee2mqtt/mosquitto-services

I’m not sure but I think that all these steps are necessary because otherwise the old thing-names are still around somewhere in a database or cache.

To beginners like me it’s a little bit annoying that you are allowed to rename objects and thereby destroy the communication because the old name are kept in some places under the surface and are still essential for communication. It’s also confusing that you have lots of names, labels, ids and . object_ids. Maybe they are only relevant to the developer and should not be visible in the GUI?

Thanks for your hints and help
Hans-Peter