code: def is_battery_level(value):
      
      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
docs: Validate that value is a valid battery level integer.