if device.deleted:
    return 0