In case you have a defective device and want to disconnect it from your gateway, you need to run .remove for zigbee-shepard (https://github.com/zigbeer/zigbee-shepherd/wiki#removeieeeaddr-cfg-callback).
Ideal this would be an MQTT command that you can run.
yeah i agree.
I have a device which is causing un-handled exceptions and crashing the bridge.
@Koenkk Do you actually work on this ?
I think we should do:
var dev = shepherd.find($device, 1).getDevice();
shepherd._devbox, 'remove', dev._getId()
shepherd._devbox, 'sync', dev._getId()
What type of mqtt topic whould we do ?
I haven't worked on this yet.
The MQTT topic should be zigbee2mqtt/bridge/config/remove with the device friendly_name as the payload.
Functionality should be implemented here: https://github.com/Koenkk/zigbee2mqtt/blob/master/lib/controller.js#L153
@Koenkk : I work on this Issue but need some help for the remove function themselve:
Look at my Comments on: https://github.com/tb-killa/zigbee2mqtt
Maybe there are some Sort of Flawed thinking.
@tb-killa looks good, where can I find the comments?
@Koenkk: forget "comments" :) I made a mistake.
Could you please check my changes?
Maybe i forgot something in combination with the core - remove function, because sometimes i get the "Failed to removed" message.
@tb-killa please open a PR with your changes against this repo. Use WIP in title to know that this wont' be merged quite yet. We can then help easier with review
For my app was made forceRemove in controller:
forceRemove(deviceID, callback) {
const device = this.shepherd._findDevByAddr(deviceID);
// force
return this.shepherd._unregisterDev(device, (err, result) => {
return callback(err, result);
});
}
Okay I think it makes sense for us.
I will rework my "removedevice" function and will test again if i got the time.
@tb-killa xiaomi sensor "device" do not removed by classic method... but "router" do. if classic remove not success - force remove.
@kirovilya why did you need a callback on force remove?
@ciotlosm For waiting remove from shepherd and then delete other app objects.
Can you review my PR (I updated a bit the one from @tb-killa ) and let me know which other app objects to remove?
Hi @ciotlosm : Thanks for your work and finishing my code:
At the moment I'm mainly busy with the work, so I'm not getting any further here at the moment.
but looks good :)
@ciotlosm ok. I remove objects in my app: states, history...
@tb-killa no worries. Sometimes I'm busy and happy when people assist with mine 馃憤
@kirovilya states and history are not part of zigbee2mqtt right?
@ciotlosm yes, not zigbee2mqtt part
@kirovilya can you review code here: #99 and let me know if you are happy with implementation?
@ciotlosm sorry, not today and not tomorrow. birthday :)
Oh, no worries. Happy birthday. I'll have a drink for that!
@ciotlosm thank you! :)
Did this ever get implemented? I have devices which I don't use appear on my network map, I assume this is because they have entries in database.db, I would like to remove these. I guess it's not ok to just delete the relevant lines from database.db?
@pcb1962 you can delete them manually from the database.db. This feature has been implemented: https://koenkk.github.io/zigbee2mqtt/information/mqtt_topics_and_message_structure.html#zigbee2mqttbridgeconfigremove
Thank you, apologies for not finding the relevant mqtt topic, I'm going to study that page now.
Link is broken... new one:
https://www.zigbee2mqtt.io/information/mqtt_topics_and_message_structure.html#zigbee2mqttbridgeconfigremove
Does it perform any validation of the message? I just posted rubbish via Home Assistant interface

and I see the following in the log:
zigbee2mqtt:debug 7/14/2019, 1:51:34 PM Received MQTT message on 'zigbee2mqtt/bridge/config/remove' with data 'rubbish'
zigbee2mqtt:info 7/14/2019, 1:51:34 PM Successfully removed rubbish
zigbee2mqtt:info 7/14/2019, 1:51:34 PM MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"type":"device_removed","message":"rubbish"}'
It reports that it was successfully removed :)