def purge_unused_tags!
      unused_tags.each do |tag|
        logger.info("Purging tag '#{tag}'")
        entries_with(label: tag).each do |entry|
          payload = Protocol::Device::SetTagLabels.new(tags: id_to_tags_field(entry.tag_id), label: '')
          context.send_message(target: Target.new(site_id: entry.site_id),
                               payload: payload,
                               acknowledge: true)
        end
      end
      Timeout.timeout(5) do
        while !unused_tags.empty?
          sleep 0.1
        end
      end
    end
def purge_unused_tags!
      unused_tags.each do |tag|
        logger.info("Purging tag '#{tag}'")
        entries_with(label: tag).each do |entry|
          payload = Protocol::Device::SetTagLabels.new(tags: id_to_tags_field(entry.tag_id), label: '')
          context.send_message(target: Target.new(site_id: entry.site_id),
                               payload: payload,
                               acknowledge: true)
        end
      end
      Timeout.timeout(5) do
        while !unused_tags.empty?
          sleep 0.1
        end
      end
    end
This will clear out tags that currently do not resolve to any devices.
 If used when devices that are tagged with a tag that is not attached to an
 active device, it will effectively untag them when they're back on.