def is_battery_level(value):
    """Validate that value is a valid battery level integer."""
    try:
        value = percent_int(value)
        return value
    except vol.Invalid:
        _LOGGER.warning(
            '%s is not a valid battery level, falling back to battery level 0',
            value)
        return 0
Validate that value is a valid battery level integer.