def boolean(value):
    if isinstance(value, str):
        value = value.lower()
        if value in ('1', 'true', 'yes', 'on', 'enable'):
            return True
        if value in ('0', 'false', 'no', 'off', 'disable'):
            return False
        raise vol.Invalid('invalid boolean value {}'.format(value))
    return bool(value)
Validate and coerce a boolean value.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/helpers/config_validation.py/boolean