jpmens / homie-ota

OTA "server" in Python for Homie
127 stars 50 forks source link

Remove devices from inventory #34

Closed snikch closed 7 years ago

snikch commented 7 years ago

Fixes #18.

This adds a delete link to the device specific details page.

When delete is called, it adds a new subscription to all of a device's topics, and a special delete handler. The delete handler will respond to any non 0 byte payloads with a publish of 0 bytes (aka, delete). It waits a bit for the topics to get deleted, then removes the subscription and deletes the key from the inventory db. It's a bit lazy in that it just has a 2 second sleep rather than some sort of heuristic to know it's received all the messages, but it seems to work well!

cobii commented 7 years ago

Thanks a lot for the new functionality!

jpmens commented 7 years ago

Thanks a bunch for this. I haven't been able to test myself but Christoph tells me

It just misses the deletion of the entry in the sensors db. It only clears the inventory db

Even so, and contrary to how I usually handle things, I will merge this now (b/c I cannot test for the next three weeks or so). If you have improvements to make, I'll gladly take them.

snikch commented 7 years ago

Thanks for the quick responses. I'll get the sensors db sorted asap 👍