コード例 #1
0
def test_enum():
    """Test enum validator."""
    class TestEnum(enum.Enum):
        """Test enum."""

        value1 = "Value 1"
        value2 = "Value 2"

    schema = vol.Schema(cv.enum(TestEnum))

    with pytest.raises(vol.Invalid):
        schema('value3')
コード例 #2
0
def test_enum():
    """Test enum validator."""
    class TestEnum(enum.Enum):
        """Test enum."""

        value1 = "Value 1"
        value2 = "Value 2"

    schema = vol.Schema(cv.enum(TestEnum))

    with pytest.raises(vol.Invalid):
        schema('value3')
コード例 #3
0
class LightSchema:
    """Voluptuous schema for KNX lights."""

    CONF_STATE_ADDRESS = CONF_STATE_ADDRESS
    CONF_BRIGHTNESS_ADDRESS = "brightness_address"
    CONF_BRIGHTNESS_STATE_ADDRESS = "brightness_state_address"
    CONF_COLOR_ADDRESS = "color_address"
    CONF_COLOR_STATE_ADDRESS = "color_state_address"
    CONF_COLOR_TEMP_ADDRESS = "color_temperature_address"
    CONF_COLOR_TEMP_STATE_ADDRESS = "color_temperature_state_address"
    CONF_COLOR_TEMP_MODE = "color_temperature_mode"
    CONF_RGBW_ADDRESS = "rgbw_address"
    CONF_RGBW_STATE_ADDRESS = "rgbw_state_address"
    CONF_MIN_KELVIN = "min_kelvin"
    CONF_MAX_KELVIN = "max_kelvin"

    DEFAULT_NAME = "KNX Light"
    DEFAULT_COLOR_TEMP_MODE = "absolute"
    DEFAULT_MIN_KELVIN = 2700  # 370 mireds
    DEFAULT_MAX_KELVIN = 6000  # 166 mireds

    SCHEMA = vol.Schema({
        vol.Required(CONF_ADDRESS):
        cv.string,
        vol.Optional(CONF_NAME, default=DEFAULT_NAME):
        cv.string,
        vol.Optional(CONF_STATE_ADDRESS):
        cv.string,
        vol.Optional(CONF_BRIGHTNESS_ADDRESS):
        cv.string,
        vol.Optional(CONF_BRIGHTNESS_STATE_ADDRESS):
        cv.string,
        vol.Optional(CONF_COLOR_ADDRESS):
        cv.string,
        vol.Optional(CONF_COLOR_STATE_ADDRESS):
        cv.string,
        vol.Optional(CONF_COLOR_TEMP_ADDRESS):
        cv.string,
        vol.Optional(CONF_COLOR_TEMP_STATE_ADDRESS):
        cv.string,
        vol.Optional(CONF_COLOR_TEMP_MODE, default=DEFAULT_COLOR_TEMP_MODE):
        cv.enum(ColorTempModes),
        vol.Optional(CONF_RGBW_ADDRESS):
        cv.string,
        vol.Optional(CONF_RGBW_STATE_ADDRESS):
        cv.string,
        vol.Optional(CONF_MIN_KELVIN, default=DEFAULT_MIN_KELVIN):
        vol.All(vol.Coerce(int), vol.Range(min=1)),
        vol.Optional(CONF_MAX_KELVIN, default=DEFAULT_MAX_KELVIN):
        vol.All(vol.Coerce(int), vol.Range(min=1)),
    })
コード例 #4
0
ファイル: alexa.py プロジェクト: jaharkes/home-assistant

class CardType(enum.Enum):
    """The Alexa card types."""

    simple = "Simple"
    link_account = "LinkAccount"


CONFIG_SCHEMA = vol.Schema({
    DOMAIN: {
        CONF_INTENTS: {
            cv.string: {
                vol.Optional(CONF_ACTION): cv.SCRIPT_SCHEMA,
                vol.Optional(CONF_CARD): {
                    vol.Required(CONF_TYPE): cv.enum(CardType),
                    vol.Required(CONF_TITLE): cv.template,
                    vol.Required(CONF_CONTENT): cv.template,
                },
                vol.Optional(CONF_SPEECH): {
                    vol.Required(CONF_TYPE): cv.enum(SpeechType),
                    vol.Required(CONF_TEXT): cv.template,
                }
            }
        },
        CONF_FLASH_BRIEFINGS: {
            cv.string: vol.All(cv.ensure_list, [{
                vol.Required(CONF_UID, default=str(uuid.uuid4())): cv.string,
                vol.Optional(CONF_DATE, default=datetime.utcnow()): cv.string,
                vol.Required(CONF_TITLE): cv.template,
                vol.Optional(CONF_AUDIO): cv.template,
コード例 #5
0
TOKEN_FILE = f".{DOMAIN}.token"

PLATFORMS = ["calendar"]

CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN:
        vol.Schema({
            vol.Required(CONF_CLIENT_ID):
            cv.string,
            vol.Required(CONF_CLIENT_SECRET):
            cv.string,
            vol.Optional(CONF_TRACK_NEW, default=True):
            cv.boolean,
            vol.Optional(CONF_CALENDAR_ACCESS, default="read_write"):
            cv.enum(FeatureAccess),
        })
    },
    extra=vol.ALLOW_EXTRA,
)

_SINGLE_CALSEARCH_CONFIG = vol.All(
    cv.deprecated(CONF_MAX_RESULTS),
    vol.Schema({
        vol.Required(CONF_NAME): cv.string,
        vol.Required(CONF_DEVICE_ID): cv.string,
        vol.Optional(CONF_IGNORE_AVAILABILITY, default=True): cv.boolean,
        vol.Optional(CONF_OFFSET): cv.string,
        vol.Optional(CONF_SEARCH): cv.string,
        vol.Optional(CONF_TRACK): cv.boolean,
        vol.Optional(CONF_MAX_RESULTS): cv.positive_int,  # Now unused
コード例 #6
0
    heatpump = "heatpump"


CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN: vol.Schema(
            {
                vol.Required(CONF_USERNAME): cv.string,
                vol.Required(CONF_PASSWORD): cv.string,
                vol.Optional(CONF_SCAN_INTERVAL, default=60): vol.All(
                    cv.time_period, lambda value: value.total_seconds()
                ),
                vol.Optional(CONF_CIRCUIT): int,
                vol.Optional(CONF_NAME, default="ViCare"): cv.string,
                vol.Optional(CONF_HEATING_TYPE, default=DEFAULT_HEATING_TYPE): cv.enum(
                    HeatingType
                ),
            }
        )
    },
    extra=vol.ALLOW_EXTRA,
)


def setup(hass, config):
    """Create the ViCare component."""
    conf = config[DOMAIN]
    params = {"token_file": hass.config.path(STORAGE_DIR, "vicare_token.save")}
    if conf.get(CONF_CIRCUIT) is not None:
        params["circuit"] = conf[CONF_CIRCUIT]
コード例 #7
0
class LightSchema(KNXPlatformSchema):
    """Voluptuous schema for KNX lights."""

    PLATFORM = Platform.LIGHT

    CONF_STATE_ADDRESS = CONF_STATE_ADDRESS
    CONF_BRIGHTNESS_ADDRESS = "brightness_address"
    CONF_BRIGHTNESS_STATE_ADDRESS = "brightness_state_address"
    CONF_COLOR_ADDRESS = "color_address"
    CONF_COLOR_STATE_ADDRESS = "color_state_address"
    CONF_COLOR_TEMP_ADDRESS = "color_temperature_address"
    CONF_COLOR_TEMP_STATE_ADDRESS = "color_temperature_state_address"
    CONF_COLOR_TEMP_MODE = "color_temperature_mode"
    CONF_HUE_ADDRESS = "hue_address"
    CONF_HUE_STATE_ADDRESS = "hue_state_address"
    CONF_RGBW_ADDRESS = "rgbw_address"
    CONF_RGBW_STATE_ADDRESS = "rgbw_state_address"
    CONF_SATURATION_ADDRESS = "saturation_address"
    CONF_SATURATION_STATE_ADDRESS = "saturation_state_address"
    CONF_XYY_ADDRESS = "xyy_address"
    CONF_XYY_STATE_ADDRESS = "xyy_state_address"
    CONF_MIN_KELVIN = "min_kelvin"
    CONF_MAX_KELVIN = "max_kelvin"

    DEFAULT_NAME = "KNX Light"
    DEFAULT_COLOR_TEMP_MODE = "absolute"
    DEFAULT_MIN_KELVIN = 2700  # 370 mireds
    DEFAULT_MAX_KELVIN = 6000  # 166 mireds

    CONF_INDIVIDUAL_COLORS = "individual_colors"
    CONF_RED = "red"
    CONF_GREEN = "green"
    CONF_BLUE = "blue"
    CONF_WHITE = "white"

    _hs_color_inclusion_msg = (
        "'hue_address', 'saturation_address' and 'brightness_address'"
        " are required for hs_color configuration"
    )
    HS_COLOR_SCHEMA = {
        vol.Optional(CONF_HUE_ADDRESS): ga_list_validator,
        vol.Optional(CONF_HUE_STATE_ADDRESS): ga_list_validator,
        vol.Optional(CONF_SATURATION_ADDRESS): ga_list_validator,
        vol.Optional(CONF_SATURATION_STATE_ADDRESS): ga_list_validator,
    }

    INDIVIDUAL_COLOR_SCHEMA = vol.Schema(
        {
            vol.Optional(KNX_ADDRESS): ga_list_validator,
            vol.Optional(CONF_STATE_ADDRESS): ga_list_validator,
            vol.Required(CONF_BRIGHTNESS_ADDRESS): ga_list_validator,
            vol.Optional(CONF_BRIGHTNESS_STATE_ADDRESS): ga_list_validator,
        }
    )

    ENTITY_SCHEMA = vol.All(
        vol.Schema(
            {
                vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
                vol.Optional(KNX_ADDRESS): ga_list_validator,
                vol.Optional(CONF_STATE_ADDRESS): ga_list_validator,
                vol.Optional(CONF_BRIGHTNESS_ADDRESS): ga_list_validator,
                vol.Optional(CONF_BRIGHTNESS_STATE_ADDRESS): ga_list_validator,
                vol.Exclusive(CONF_INDIVIDUAL_COLORS, "color"): {
                    vol.Inclusive(
                        CONF_RED,
                        "individual_colors",
                        msg="'red', 'green' and 'blue' are required for individual colors configuration",
                    ): INDIVIDUAL_COLOR_SCHEMA,
                    vol.Inclusive(
                        CONF_GREEN,
                        "individual_colors",
                        msg="'red', 'green' and 'blue' are required for individual colors configuration",
                    ): INDIVIDUAL_COLOR_SCHEMA,
                    vol.Inclusive(
                        CONF_BLUE,
                        "individual_colors",
                        msg="'red', 'green' and 'blue' are required for individual colors configuration",
                    ): INDIVIDUAL_COLOR_SCHEMA,
                    vol.Optional(CONF_WHITE): INDIVIDUAL_COLOR_SCHEMA,
                },
                vol.Exclusive(CONF_COLOR_ADDRESS, "color"): ga_list_validator,
                vol.Optional(CONF_COLOR_STATE_ADDRESS): ga_list_validator,
                vol.Optional(CONF_COLOR_TEMP_ADDRESS): ga_list_validator,
                vol.Optional(CONF_COLOR_TEMP_STATE_ADDRESS): ga_list_validator,
                vol.Optional(
                    CONF_COLOR_TEMP_MODE, default=DEFAULT_COLOR_TEMP_MODE
                ): vol.All(vol.Upper, cv.enum(ColorTempModes)),
                **HS_COLOR_SCHEMA,
                vol.Exclusive(CONF_RGBW_ADDRESS, "color"): ga_list_validator,
                vol.Optional(CONF_RGBW_STATE_ADDRESS): ga_list_validator,
                vol.Exclusive(CONF_XYY_ADDRESS, "color"): ga_list_validator,
                vol.Optional(CONF_XYY_STATE_ADDRESS): ga_list_validator,
                vol.Optional(CONF_MIN_KELVIN, default=DEFAULT_MIN_KELVIN): vol.All(
                    vol.Coerce(int), vol.Range(min=1)
                ),
                vol.Optional(CONF_MAX_KELVIN, default=DEFAULT_MAX_KELVIN): vol.All(
                    vol.Coerce(int), vol.Range(min=1)
                ),
                vol.Optional(CONF_ENTITY_CATEGORY): ENTITY_CATEGORIES_SCHEMA,
            }
        ),
        vol.Any(
            vol.Schema(
                {vol.Required(KNX_ADDRESS): object},
                extra=vol.ALLOW_EXTRA,
            ),
            vol.Schema(  # brightness addresses are required in INDIVIDUAL_COLOR_SCHEMA
                {vol.Required(CONF_INDIVIDUAL_COLORS): object},
                extra=vol.ALLOW_EXTRA,
            ),
            msg="either 'address' or 'individual_colors' is required",
        ),
        vol.Any(
            vol.Schema(  # 'brightness' is non-optional for hs-color
                {
                    vol.Inclusive(
                        CONF_BRIGHTNESS_ADDRESS, "hs_color", msg=_hs_color_inclusion_msg
                    ): object,
                    vol.Inclusive(
                        CONF_HUE_ADDRESS, "hs_color", msg=_hs_color_inclusion_msg
                    ): object,
                    vol.Inclusive(
                        CONF_SATURATION_ADDRESS, "hs_color", msg=_hs_color_inclusion_msg
                    ): object,
                },
                extra=vol.ALLOW_EXTRA,
            ),
            vol.Schema(  # hs-colors not used
                {
                    vol.Optional(CONF_HUE_ADDRESS): None,
                    vol.Optional(CONF_SATURATION_ADDRESS): None,
                },
                extra=vol.ALLOW_EXTRA,
            ),
            msg=_hs_color_inclusion_msg,
        ),
    )
コード例 #8
0
async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Setup the sensor platform."""
    _LOGGER.debug("Initialising renaultze platform")

    g_url = None
    g_key = None
    k_url = None
    k_key = None
    k_account_id = config.get(CONF_K_ACCOUNTID, '')

    cred = CredentialStore()
    cred.clear()

    url = 'https://renault-wrd-prod-1-euw1-myrapp-one.s3-eu-west-1.amazonaws.com/configuration/android/config_{0}.json'.format(
        config.get(CONF_ANDROID_LNG))
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as response:
            responsetext = await response.text()
            if responsetext == '':
                responsetext = '{}'
            jsonresponse = json.loads(responsetext)

            g_url = jsonresponse['servers']['gigyaProd']['target']
            g_key = jsonresponse['servers']['gigyaProd']['apikey']
            k_url = jsonresponse['servers']['wiredProd']['target']
            k_key = jsonresponse['servers']['wiredProd']['apikey']

    g = Gigya(api_key=g_key, root_url=g_url)
    if not g.login(config.get(CONF_USERNAME), config.get(CONF_PASSWORD)):
        raise RenaultZEError("Login failed")
    g.account_info()

    k = Kamereon(api_key=k_key, root_url=k_url, gigya=g)
    if k_account_id != '':
        k.set_account_id(k_account_id)

    v = Vehicle(config.get(CONF_VIN), k)

    devices = [RenaultZESensor(v, config.get(CONF_NAME, config.get(CONF_VIN)))]
    async_add_entities(devices)

    platform = entity_platform.current_platform.get()

    platform.async_register_entity_service(
        SERVICE_AC_START,
        {
            vol.Optional(ATTR_WHEN): cv.datetime,
            vol.Optional(ATTR_TEMPERATURE): cv.positive_int,
        },
        "ac_start",
    )
    platform.async_register_entity_service(
        SERVICE_AC_CANCEL,
        {},
        "ac_cancel",
    )
    platform.async_register_entity_service(
        SERVICE_CHARGE_START,
        {},
        "charge_start",
    )
    platform.async_register_entity_service(
        SERVICE_CHARGE_SET_MODE,
        {
            vol.Required(ATTR_CHARGE_MODE): cv.enum(ChargeMode),
        },
        "charge_set_mode",
    )
    platform.async_register_entity_service(
        SERVICE_CHARGE_SET_SCHEDULES,
        {
            vol.Required(ATTR_SCHEDULES): dict,
        },
        "charge_set_schedules",
    )
コード例 #9
0
ファイル: alexa.py プロジェクト: krzynio/home-assistant

class CardType(enum.Enum):
    """The Alexa card types."""

    simple = "Simple"
    link_account = "LinkAccount"


CONFIG_SCHEMA = vol.Schema({
    DOMAIN: {
        CONF_INTENTS: {
            cv.string: {
                vol.Optional(CONF_ACTION): cv.SCRIPT_SCHEMA,
                vol.Optional(CONF_CARD): {
                    vol.Required(CONF_TYPE): cv.enum(CardType),
                    vol.Required(CONF_TITLE): cv.template,
                    vol.Required(CONF_CONTENT): cv.template,
                },
                vol.Optional(CONF_SPEECH): {
                    vol.Required(CONF_TYPE): cv.enum(SpeechType),
                    vol.Required(CONF_TEXT): cv.template,
                }
            }
        },
        CONF_FLASH_BRIEFINGS: {
            cv.string: vol.All(cv.ensure_list, [{
                vol.Required(CONF_UID, default=str(uuid.uuid4())): cv.string,
                vol.Optional(CONF_DATE, default=datetime.utcnow()): cv.string,
                vol.Required(CONF_TITLE): cv.template,
                vol.Optional(CONF_AUDIO): cv.template,
コード例 #10
0
ファイル: schema.py プロジェクト: uzbekdev1/core-2
class LightSchema:
    """Voluptuous schema for KNX lights."""

    CONF_STATE_ADDRESS = CONF_STATE_ADDRESS
    CONF_BRIGHTNESS_ADDRESS = "brightness_address"
    CONF_BRIGHTNESS_STATE_ADDRESS = "brightness_state_address"
    CONF_COLOR_ADDRESS = "color_address"
    CONF_COLOR_STATE_ADDRESS = "color_state_address"
    CONF_COLOR_TEMP_ADDRESS = "color_temperature_address"
    CONF_COLOR_TEMP_STATE_ADDRESS = "color_temperature_state_address"
    CONF_COLOR_TEMP_MODE = "color_temperature_mode"
    CONF_RGBW_ADDRESS = "rgbw_address"
    CONF_RGBW_STATE_ADDRESS = "rgbw_state_address"
    CONF_MIN_KELVIN = "min_kelvin"
    CONF_MAX_KELVIN = "max_kelvin"

    DEFAULT_NAME = "KNX Light"
    DEFAULT_COLOR_TEMP_MODE = "absolute"
    DEFAULT_MIN_KELVIN = 2700  # 370 mireds
    DEFAULT_MAX_KELVIN = 6000  # 166 mireds

    CONF_INDIVIDUAL_COLORS = "individual_colors"
    CONF_RED = "red"
    CONF_GREEN = "green"
    CONF_BLUE = "blue"
    CONF_WHITE = "white"

    COLOR_SCHEMA = vol.Schema({
        vol.Optional(KNX_ADDRESS):
        ga_list_validator,
        vol.Optional(CONF_STATE_ADDRESS):
        ga_list_validator,
        vol.Required(CONF_BRIGHTNESS_ADDRESS):
        ga_list_validator,
        vol.Optional(CONF_BRIGHTNESS_STATE_ADDRESS):
        ga_list_validator,
    })

    SCHEMA = vol.All(
        vol.Schema(
            {
                vol.Optional(CONF_NAME, default=DEFAULT_NAME):
                cv.string,
                vol.Optional(KNX_ADDRESS):
                ga_list_validator,
                vol.Optional(CONF_STATE_ADDRESS):
                ga_list_validator,
                vol.Optional(CONF_BRIGHTNESS_ADDRESS):
                ga_list_validator,
                vol.Optional(CONF_BRIGHTNESS_STATE_ADDRESS):
                ga_list_validator,
                vol.Exclusive(CONF_INDIVIDUAL_COLORS, "color"): {
                    vol.Inclusive(CONF_RED, "colors"): COLOR_SCHEMA,
                    vol.Inclusive(CONF_GREEN, "colors"): COLOR_SCHEMA,
                    vol.Inclusive(CONF_BLUE, "colors"): COLOR_SCHEMA,
                    vol.Optional(CONF_WHITE): COLOR_SCHEMA,
                },
                vol.Exclusive(CONF_COLOR_ADDRESS, "color"):
                ga_list_validator,
                vol.Optional(CONF_COLOR_STATE_ADDRESS):
                ga_list_validator,
                vol.Optional(CONF_COLOR_TEMP_ADDRESS):
                ga_list_validator,
                vol.Optional(CONF_COLOR_TEMP_STATE_ADDRESS):
                ga_list_validator,
                vol.Optional(CONF_COLOR_TEMP_MODE,
                             default=DEFAULT_COLOR_TEMP_MODE):
                vol.All(vol.Upper, cv.enum(ColorTempModes)),
                vol.Exclusive(CONF_RGBW_ADDRESS, "color"):
                ga_list_validator,
                vol.Optional(CONF_RGBW_STATE_ADDRESS):
                ga_list_validator,
                vol.Optional(CONF_MIN_KELVIN, default=DEFAULT_MIN_KELVIN):
                vol.All(vol.Coerce(int), vol.Range(min=1)),
                vol.Optional(CONF_MAX_KELVIN, default=DEFAULT_MAX_KELVIN):
                vol.All(vol.Coerce(int), vol.Range(min=1)),
            }),
        vol.Any(
            # either global "address" or all addresses for individual colors are required
            vol.Schema(
                {
                    vol.Required(CONF_INDIVIDUAL_COLORS): {
                        vol.Required(CONF_RED): {
                            vol.Required(KNX_ADDRESS): object
                        },
                        vol.Required(CONF_GREEN): {
                            vol.Required(KNX_ADDRESS): object
                        },
                        vol.Required(CONF_BLUE): {
                            vol.Required(KNX_ADDRESS): object
                        },
                    },
                },
                extra=vol.ALLOW_EXTRA,
            ),
            vol.Schema(
                {
                    vol.Required(KNX_ADDRESS): object,
                },
                extra=vol.ALLOW_EXTRA,
            ),
        ),
    )
コード例 #11
0
ファイル: services.py プロジェクト: KTibow/hassRenaultZE
})
SERVICE_AC_START = "ac_start"
SERVICE_AC_START_SCHEMA = vol.Schema({
    vol.Required(SCHEMA_VIN):
    cv.matches_regex(REGEX_VIN),
    vol.Optional(SCHEMA_WHEN):
    cv.datetime,
    vol.Optional(SCHEMA_TEMPERATURE):
    cv.positive_int,
})
SERVICE_CHARGE_SET_MODE = "charge_set_mode"
SERVICE_CHARGE_SET_MODE_SCHEMA = vol.Schema({
    vol.Required(SCHEMA_VIN):
    cv.matches_regex(REGEX_VIN),
    vol.Required(SCHEMA_CHARGE_MODE):
    cv.enum(ChargeMode),
})
SERVICE_CHARGE_SET_SCHEDULES = "charge_set_schedules"
SERVICE_CHARGE_SET_SCHEDULES_SCHEMA = vol.Schema({
    vol.Required(SCHEMA_VIN):
    cv.matches_regex(REGEX_VIN),
    vol.Required(SCHEMA_SCHEDULES):
    dict,
})
SERVICE_CHARGE_START = "charge_start"
SERVICE_CHARGE_START_SCHEMA = vol.Schema({
    vol.Required(SCHEMA_VIN):
    cv.matches_regex(REGEX_VIN),
})

コード例 #12
0
    DATA_ZHA_GATEWAY,
    DEFAULT_BAUDRATE,
    DEFAULT_RADIO_TYPE,
    DOMAIN,
    RadioType,
)
from .core.registries import establish_device_mappings

DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({vol.Optional(ha_const.CONF_TYPE): cv.string})

CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN: vol.Schema(
            {
                vol.Optional(CONF_RADIO_TYPE, default=DEFAULT_RADIO_TYPE): cv.enum(
                    RadioType
                ),
                CONF_USB_PATH: cv.string,
                vol.Optional(CONF_BAUDRATE, default=DEFAULT_BAUDRATE): cv.positive_int,
                vol.Optional(CONF_DATABASE): cv.string,
                vol.Optional(CONF_DEVICE_CONFIG, default={}): vol.Schema(
                    {cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}
                ),
                vol.Optional(CONF_ENABLE_QUIRKS, default=True): cv.boolean,
            }
        )
    },
    extra=vol.ALLOW_EXTRA,
)

# Zigbee definitions
コード例 #13
0
    'zigpy-homeassistant==0.3.0',
    'zigpy-xbee-homeassistant==0.1.2',
    'zha-quirks==0.0.6',
    'zigpy-deconz==0.1.2'
]

DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({
    vol.Optional(ha_const.CONF_TYPE): cv.string,
})

CONFIG_SCHEMA = vol.Schema({
    DOMAIN: vol.Schema({
        vol.Optional(
            CONF_RADIO_TYPE,
            default=DEFAULT_RADIO_TYPE
        ): cv.enum(RadioType),
        CONF_USB_PATH: cv.string,
        vol.Optional(CONF_BAUDRATE, default=DEFAULT_BAUDRATE): cv.positive_int,
        vol.Optional(CONF_DATABASE): cv.string,
        vol.Optional(CONF_DEVICE_CONFIG, default={}):
            vol.Schema({cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}),
        vol.Optional(ENABLE_QUIRKS, default=True): cv.boolean,
    })
}, extra=vol.ALLOW_EXTRA)

# Zigbee definitions
CENTICELSIUS = 'C-100'

# Internal definitions
_LOGGER = logging.getLogger(__name__)
コード例 #14
0
ファイル: light.py プロジェクト: fbradyirl/home-assistant
    absolute = "DPT-7.600"
    relative = "DPT-5.001"


PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_ADDRESS): cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_STATE_ADDRESS): cv.string,
    vol.Optional(CONF_BRIGHTNESS_ADDRESS): cv.string,
    vol.Optional(CONF_BRIGHTNESS_STATE_ADDRESS): cv.string,
    vol.Optional(CONF_COLOR_ADDRESS): cv.string,
    vol.Optional(CONF_COLOR_STATE_ADDRESS): cv.string,
    vol.Optional(CONF_COLOR_TEMP_ADDRESS): cv.string,
    vol.Optional(CONF_COLOR_TEMP_STATE_ADDRESS): cv.string,
    vol.Optional(CONF_COLOR_TEMP_MODE, default=DEFAULT_COLOR_TEMP_MODE):
        cv.enum(ColorTempModes),
    vol.Optional(CONF_MIN_KELVIN, default=DEFAULT_MIN_KELVIN):
        vol.All(vol.Coerce(int), vol.Range(min=1)),
    vol.Optional(CONF_MAX_KELVIN, default=DEFAULT_MAX_KELVIN):
        vol.All(vol.Coerce(int), vol.Range(min=1)),
})


async def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):
    """Set up lights for KNX platform."""
    if discovery_info is not None:
        async_add_entities_discovery(hass, discovery_info, async_add_entities)
    else:
        async_add_entities_config(hass, config, async_add_entities)
コード例 #15
0
ALARM_CONTROL_PANEL_SCHEMA = vol.Schema({
    vol.Optional(CONF_VALUE_TEMPLATE):
    cv.template,
    vol.Optional(CONF_DISARM_ACTION):
    cv.SCRIPT_SCHEMA,
    vol.Optional(CONF_ARM_AWAY_ACTION):
    cv.SCRIPT_SCHEMA,
    vol.Optional(CONF_ARM_HOME_ACTION):
    cv.SCRIPT_SCHEMA,
    vol.Optional(CONF_ARM_NIGHT_ACTION):
    cv.SCRIPT_SCHEMA,
    vol.Optional(CONF_CODE_ARM_REQUIRED, default=True):
    cv.boolean,
    vol.Optional(CONF_CODE_FORMAT, default=CodeFormat.number.name):
    cv.enum(CodeFormat),
    vol.Optional(CONF_NAME):
    cv.string,
    vol.Optional(CONF_UNIQUE_ID):
    cv.string,
})

PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend({
    vol.Required(CONF_ALARM_CONTROL_PANELS):
    cv.schema_with_slug_keys(ALARM_CONTROL_PANEL_SCHEMA),
})


async def _async_create_entities(hass, config):
    """Create Template Alarm Control Panels."""
    alarm_control_panels = []
コード例 #16
0
    PLATFORMS,
    SIGNAL_ADD_ENTITIES,
    RadioType,
)
from .core.discovery import GROUP_PROBE

DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({vol.Optional(ha_const.CONF_TYPE): cv.string})
ZHA_CONFIG_SCHEMA = {
    vol.Optional(CONF_BAUDRATE): cv.positive_int,
    vol.Optional(CONF_DATABASE): cv.string,
    vol.Optional(CONF_DEVICE_CONFIG, default={}): vol.Schema(
        {cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}
    ),
    vol.Optional(CONF_ENABLE_QUIRKS, default=True): cv.boolean,
    vol.Optional(CONF_ZIGPY): dict,
    vol.Optional(CONF_RADIO_TYPE): cv.enum(RadioType),
    vol.Optional(CONF_USB_PATH): cv.string,
    vol.Optional(CONF_CUSTOM_QUIRKS_PATH): cv.isdir,
}
CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN: vol.Schema(
            vol.All(
                cv.deprecated(CONF_USB_PATH),
                cv.deprecated(CONF_BAUDRATE),
                cv.deprecated(CONF_RADIO_TYPE),
                ZHA_CONFIG_SCHEMA,
            ),
        ),
    },
    extra=vol.ALLOW_EXTRA,
コード例 #17
0

CONF_BAUDRATE = 'baudrate'
CONF_DATABASE = 'database_path'
CONF_DEVICE_CONFIG = 'device_config'
CONF_RADIO_TYPE = 'radio_type'
CONF_USB_PATH = 'usb_path'
DATA_DEVICE_CONFIG = 'zha_device_config'

DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({
    vol.Optional(ha_const.CONF_TYPE): cv.string,
})

CONFIG_SCHEMA = vol.Schema({
    DOMAIN: vol.Schema({
        vol.Optional(CONF_RADIO_TYPE, default='ezsp'): cv.enum(RadioType),
        CONF_USB_PATH: cv.string,
        vol.Optional(CONF_BAUDRATE, default=57600): cv.positive_int,
        CONF_DATABASE: cv.string,
        vol.Optional(CONF_DEVICE_CONFIG, default={}):
            vol.Schema({cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}),
    })
}, extra=vol.ALLOW_EXTRA)

ATTR_DURATION = 'duration'
ATTR_IEEE = 'ieee_address'

SERVICE_PERMIT = 'permit'
SERVICE_REMOVE = 'remove'
SERVICE_SCHEMAS = {
    SERVICE_PERMIT: vol.Schema({
コード例 #18
0
    vol.Optional(ATTR_TARGET, default=[]): [cv.string],
    vol.Optional(ATTR_TITLE, default=""):
    cv.string,
    vol.Optional(ATTR_DATA):
    NOTIFY_DATA_SCHEMA,
})

CALENDAR_SERVICE_RESPOND_SCHEMA = vol.Schema({
    vol.Optional(ATTR_ENTITY_ID):
    cv.string,
    vol.Required(ATTR_EVENT_ID):
    cv.string,
    vol.Required(ATTR_CALENDAR_ID):
    cv.string,
    vol.Optional(ATTR_RESPONSE, None):
    cv.enum(EventResponse),
    vol.Optional(ATTR_SEND_RESPONSE, True):
    bool,
    vol.Optional(ATTR_MESSAGE, None):
    cv.string,
})

ATTENDEE_SCHEMA = vol.Schema({
    vol.Required(ATTR_EMAIL): cv.string,
    vol.Required(ATTR_TYPE): cv.enum(AttendeeType),
})

CALENDAR_SERVICE_CREATE_SCHEMA = vol.Schema({
    vol.Optional(ATTR_ENTITY_ID):
    cv.string,
    vol.Required(ATTR_CALENDAR_ID):
コード例 #19
0
)

NOTIFY_BASE_SCHEMA = vol.Schema(
    {
        vol.Optional(ATTR_TARGET, default=[]): [cv.string],
        vol.Optional(ATTR_TITLE, default=""): cv.string,
        vol.Optional(ATTR_DATA): NOTIFY_DATA_SCHEMA,
    }
)

CALENDAR_SERVICE_RESPOND_SCHEMA = vol.Schema(
    {
        vol.Optional(ATTR_ENTITY_ID): cv.string,
        vol.Required(ATTR_EVENT_ID): cv.string,
        vol.Required(ATTR_CALENDAR_ID): cv.string,
        vol.Optional(ATTR_RESPONSE, None): cv.enum(EventResponse),
        vol.Optional(ATTR_SEND_RESPONSE, True): bool,
        vol.Optional(ATTR_MESSAGE, None): cv.string,
    }
)

ATTENDEE_SCHEMA = vol.Schema(
    {
        vol.Required(ATTR_EMAIL): cv.string,
        vol.Required(ATTR_TYPE): cv.enum(AttendeeType),
    }
)

CALENDAR_SERVICE_CREATE_SCHEMA = vol.Schema(
    {
        vol.Optional(ATTR_ENTITY_ID): cv.string,
コード例 #20
0

CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN:
        vol.Schema({
            vol.Required(CONF_USERNAME):
            cv.string,
            vol.Required(CONF_PASSWORD):
            cv.string,
            vol.Optional(CONF_CIRCUIT):
            int,
            vol.Optional(CONF_NAME, default="ViCare"):
            cv.string,
            vol.Optional(CONF_HEATING_TYPE, default=DEFAULT_HEATING_TYPE):
            cv.enum(HeatingType),
        })
    },
    extra=vol.ALLOW_EXTRA,
)


def setup(hass, config):
    """Create the ViCare component."""
    conf = config[DOMAIN]
    params = {"token_file": hass.config.path(STORAGE_DIR, "vicare_token.save")}
    if conf.get(CONF_CIRCUIT) is not None:
        params["circuit"] = conf[CONF_CIRCUIT]

    heating_type = conf[CONF_HEATING_TYPE]
コード例 #21
0
    absolute = "DPT-7.600"
    relative = "DPT-5.001"


PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_ADDRESS): cv.string,
    vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
    vol.Optional(CONF_STATE_ADDRESS): cv.string,
    vol.Optional(CONF_BRIGHTNESS_ADDRESS): cv.string,
    vol.Optional(CONF_BRIGHTNESS_STATE_ADDRESS): cv.string,
    vol.Optional(CONF_COLOR_ADDRESS): cv.string,
    vol.Optional(CONF_COLOR_STATE_ADDRESS): cv.string,
    vol.Optional(CONF_COLOR_TEMP_ADDRESS): cv.string,
    vol.Optional(CONF_COLOR_TEMP_STATE_ADDRESS): cv.string,
    vol.Optional(CONF_COLOR_TEMP_MODE, default=DEFAULT_COLOR_TEMP_MODE):
        cv.enum(ColorTempModes),
    vol.Optional(CONF_RGBW_ADDRESS): cv.string,
    vol.Optional(CONF_RGBW_STATE_ADDRESS): cv.string,
    vol.Optional(CONF_MIN_KELVIN, default=DEFAULT_MIN_KELVIN):
        vol.All(vol.Coerce(int), vol.Range(min=1)),
    vol.Optional(CONF_MAX_KELVIN, default=DEFAULT_MAX_KELVIN):
        vol.All(vol.Coerce(int), vol.Range(min=1)),
})


async def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):
    """Set up lights for KNX platform."""
    if discovery_info is not None:
        async_add_entities_discovery(hass, discovery_info, async_add_entities)
    else:
コード例 #22
0
ファイル: schema.py プロジェクト: uzbekdev1/core-2
class ClimateSchema:
    """Voluptuous schema for KNX climate devices."""

    CONF_SETPOINT_SHIFT_ADDRESS = "setpoint_shift_address"
    CONF_SETPOINT_SHIFT_STATE_ADDRESS = "setpoint_shift_state_address"
    CONF_SETPOINT_SHIFT_MODE = "setpoint_shift_mode"
    CONF_SETPOINT_SHIFT_MAX = "setpoint_shift_max"
    CONF_SETPOINT_SHIFT_MIN = "setpoint_shift_min"
    CONF_TEMPERATURE_ADDRESS = "temperature_address"
    CONF_TEMPERATURE_STEP = "temperature_step"
    CONF_TARGET_TEMPERATURE_ADDRESS = "target_temperature_address"
    CONF_TARGET_TEMPERATURE_STATE_ADDRESS = "target_temperature_state_address"
    CONF_OPERATION_MODE_ADDRESS = "operation_mode_address"
    CONF_OPERATION_MODE_STATE_ADDRESS = "operation_mode_state_address"
    CONF_CONTROLLER_STATUS_ADDRESS = "controller_status_address"
    CONF_CONTROLLER_STATUS_STATE_ADDRESS = "controller_status_state_address"
    CONF_CONTROLLER_MODE_ADDRESS = "controller_mode_address"
    CONF_CONTROLLER_MODE_STATE_ADDRESS = "controller_mode_state_address"
    CONF_HEAT_COOL_ADDRESS = "heat_cool_address"
    CONF_HEAT_COOL_STATE_ADDRESS = "heat_cool_state_address"
    CONF_OPERATION_MODE_FROST_PROTECTION_ADDRESS = (
        "operation_mode_frost_protection_address")
    CONF_OPERATION_MODE_NIGHT_ADDRESS = "operation_mode_night_address"
    CONF_OPERATION_MODE_COMFORT_ADDRESS = "operation_mode_comfort_address"
    CONF_OPERATION_MODE_STANDBY_ADDRESS = "operation_mode_standby_address"
    CONF_OPERATION_MODES = "operation_modes"
    CONF_CONTROLLER_MODES = "controller_modes"
    CONF_ON_OFF_ADDRESS = "on_off_address"
    CONF_ON_OFF_STATE_ADDRESS = "on_off_state_address"
    CONF_ON_OFF_INVERT = "on_off_invert"
    CONF_MIN_TEMP = "min_temp"
    CONF_MAX_TEMP = "max_temp"
    CONF_CREATE_TEMPERATURE_SENSORS = "create_temperature_sensors"

    DEFAULT_NAME = "KNX Climate"
    DEFAULT_SETPOINT_SHIFT_MODE = "DPT6010"
    DEFAULT_SETPOINT_SHIFT_MAX = 6
    DEFAULT_SETPOINT_SHIFT_MIN = -6
    DEFAULT_TEMPERATURE_STEP = 0.1
    DEFAULT_ON_OFF_INVERT = False

    SCHEMA = vol.All(
        # deprecated since September 2020
        cv.deprecated("setpoint_shift_step",
                      replacement_key=CONF_TEMPERATURE_STEP),
        vol.Schema({
            vol.Optional(CONF_NAME, default=DEFAULT_NAME):
            cv.string,
            vol.Optional(CONF_SETPOINT_SHIFT_MODE,
                         default=DEFAULT_SETPOINT_SHIFT_MODE):
            vol.All(vol.Upper, cv.enum(SetpointShiftMode)),
            vol.Optional(CONF_SETPOINT_SHIFT_MAX,
                         default=DEFAULT_SETPOINT_SHIFT_MAX):
            vol.All(int, vol.Range(min=0, max=32)),
            vol.Optional(CONF_SETPOINT_SHIFT_MIN,
                         default=DEFAULT_SETPOINT_SHIFT_MIN):
            vol.All(int, vol.Range(min=-32, max=0)),
            vol.Optional(CONF_TEMPERATURE_STEP,
                         default=DEFAULT_TEMPERATURE_STEP):
            vol.All(float, vol.Range(min=0, max=2)),
            vol.Required(CONF_TEMPERATURE_ADDRESS):
            ga_list_validator,
            vol.Required(CONF_TARGET_TEMPERATURE_STATE_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_TARGET_TEMPERATURE_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_SETPOINT_SHIFT_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_SETPOINT_SHIFT_STATE_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_OPERATION_MODE_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_OPERATION_MODE_STATE_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_CONTROLLER_STATUS_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_CONTROLLER_STATUS_STATE_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_CONTROLLER_MODE_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_CONTROLLER_MODE_STATE_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_HEAT_COOL_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_HEAT_COOL_STATE_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_OPERATION_MODE_FROST_PROTECTION_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_OPERATION_MODE_NIGHT_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_OPERATION_MODE_COMFORT_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_OPERATION_MODE_STANDBY_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_ON_OFF_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_ON_OFF_STATE_ADDRESS):
            ga_list_validator,
            vol.Optional(CONF_ON_OFF_INVERT, default=DEFAULT_ON_OFF_INVERT):
            cv.boolean,
            vol.Optional(CONF_OPERATION_MODES):
            vol.All(cv.ensure_list, [vol.In({**PRESET_MODES})]),
            vol.Optional(CONF_CONTROLLER_MODES):
            vol.All(cv.ensure_list, [vol.In({**CONTROLLER_MODES})]),
            vol.Optional(CONF_MIN_TEMP):
            vol.Coerce(float),
            vol.Optional(CONF_MAX_TEMP):
            vol.Coerce(float),
            vol.Optional(CONF_CREATE_TEMPERATURE_SENSORS, default=False):
            cv.boolean,
        }),
    )
コード例 #23
0
ファイル: __init__.py プロジェクト: pgenera/home-assistant
    @property
    def scope(self) -> str:
        """Google calendar scope for the feature."""
        return self._scope


CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN: vol.Schema(
            {
                vol.Required(CONF_CLIENT_ID): cv.string,
                vol.Required(CONF_CLIENT_SECRET): cv.string,
                vol.Optional(CONF_TRACK_NEW): cv.boolean,
                vol.Optional(CONF_CALENDAR_ACCESS, default="read_write"): cv.enum(
                    FeatureAccess
                ),
            }
        )
    },
    extra=vol.ALLOW_EXTRA,
)

_SINGLE_CALSEARCH_CONFIG = vol.All(
    cv.deprecated(CONF_MAX_RESULTS),
    vol.Schema(
        {
            vol.Required(CONF_NAME): cv.string,
            vol.Required(CONF_DEVICE_ID): cv.string,
            vol.Optional(CONF_IGNORE_AVAILABILITY, default=True): cv.boolean,
            vol.Optional(CONF_OFFSET): cv.string,
コード例 #24
0
class ClimateSchema(KNXPlatformSchema):
    """Voluptuous schema for KNX climate devices."""

    PLATFORM = Platform.CLIMATE

    CONF_ACTIVE_STATE_ADDRESS = "active_state_address"
    CONF_SETPOINT_SHIFT_ADDRESS = "setpoint_shift_address"
    CONF_SETPOINT_SHIFT_STATE_ADDRESS = "setpoint_shift_state_address"
    CONF_SETPOINT_SHIFT_MODE = "setpoint_shift_mode"
    CONF_SETPOINT_SHIFT_MAX = "setpoint_shift_max"
    CONF_SETPOINT_SHIFT_MIN = "setpoint_shift_min"
    CONF_TEMPERATURE_ADDRESS = "temperature_address"
    CONF_TEMPERATURE_STEP = "temperature_step"
    CONF_TARGET_TEMPERATURE_ADDRESS = "target_temperature_address"
    CONF_TARGET_TEMPERATURE_STATE_ADDRESS = "target_temperature_state_address"
    CONF_OPERATION_MODE_ADDRESS = "operation_mode_address"
    CONF_OPERATION_MODE_STATE_ADDRESS = "operation_mode_state_address"
    CONF_CONTROLLER_STATUS_ADDRESS = "controller_status_address"
    CONF_CONTROLLER_STATUS_STATE_ADDRESS = "controller_status_state_address"
    CONF_CONTROLLER_MODE_ADDRESS = "controller_mode_address"
    CONF_CONTROLLER_MODE_STATE_ADDRESS = "controller_mode_state_address"
    CONF_COMMAND_VALUE_STATE_ADDRESS = "command_value_state_address"
    CONF_HEAT_COOL_ADDRESS = "heat_cool_address"
    CONF_HEAT_COOL_STATE_ADDRESS = "heat_cool_state_address"
    CONF_OPERATION_MODE_FROST_PROTECTION_ADDRESS = (
        "operation_mode_frost_protection_address"
    )
    CONF_OPERATION_MODE_NIGHT_ADDRESS = "operation_mode_night_address"
    CONF_OPERATION_MODE_COMFORT_ADDRESS = "operation_mode_comfort_address"
    CONF_OPERATION_MODE_STANDBY_ADDRESS = "operation_mode_standby_address"
    CONF_OPERATION_MODES = "operation_modes"
    CONF_CONTROLLER_MODES = "controller_modes"
    CONF_DEFAULT_CONTROLLER_MODE = "default_controller_mode"
    CONF_ON_OFF_ADDRESS = "on_off_address"
    CONF_ON_OFF_STATE_ADDRESS = "on_off_state_address"
    CONF_ON_OFF_INVERT = "on_off_invert"
    CONF_MIN_TEMP = "min_temp"
    CONF_MAX_TEMP = "max_temp"

    DEFAULT_NAME = "KNX Climate"
    DEFAULT_SETPOINT_SHIFT_MODE = "DPT6010"
    DEFAULT_SETPOINT_SHIFT_MAX = 6
    DEFAULT_SETPOINT_SHIFT_MIN = -6
    DEFAULT_TEMPERATURE_STEP = 0.1
    DEFAULT_ON_OFF_INVERT = False

    ENTITY_SCHEMA = vol.All(
        # deprecated since September 2020
        cv.deprecated("setpoint_shift_step", replacement_key=CONF_TEMPERATURE_STEP),
        # deprecated since 2021.6
        cv.deprecated("create_temperature_sensors"),
        vol.Schema(
            {
                vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
                vol.Optional(
                    CONF_SETPOINT_SHIFT_MAX, default=DEFAULT_SETPOINT_SHIFT_MAX
                ): vol.All(int, vol.Range(min=0, max=32)),
                vol.Optional(
                    CONF_SETPOINT_SHIFT_MIN, default=DEFAULT_SETPOINT_SHIFT_MIN
                ): vol.All(int, vol.Range(min=-32, max=0)),
                vol.Optional(
                    CONF_TEMPERATURE_STEP, default=DEFAULT_TEMPERATURE_STEP
                ): vol.All(float, vol.Range(min=0, max=2)),
                vol.Required(CONF_TEMPERATURE_ADDRESS): ga_list_validator,
                vol.Required(CONF_TARGET_TEMPERATURE_STATE_ADDRESS): ga_list_validator,
                vol.Optional(CONF_TARGET_TEMPERATURE_ADDRESS): ga_list_validator,
                vol.Inclusive(
                    CONF_SETPOINT_SHIFT_ADDRESS,
                    "setpoint_shift",
                    msg="'setpoint_shift_address' and 'setpoint_shift_state_address' "
                    "are required for setpoint_shift configuration",
                ): ga_list_validator,
                vol.Inclusive(
                    CONF_SETPOINT_SHIFT_STATE_ADDRESS,
                    "setpoint_shift",
                    msg="'setpoint_shift_address' and 'setpoint_shift_state_address' "
                    "are required for setpoint_shift configuration",
                ): ga_list_validator,
                vol.Optional(CONF_SETPOINT_SHIFT_MODE): vol.Maybe(
                    vol.All(vol.Upper, cv.enum(SetpointShiftMode))
                ),
                vol.Optional(CONF_ACTIVE_STATE_ADDRESS): ga_list_validator,
                vol.Optional(CONF_COMMAND_VALUE_STATE_ADDRESS): ga_list_validator,
                vol.Optional(CONF_OPERATION_MODE_ADDRESS): ga_list_validator,
                vol.Optional(CONF_OPERATION_MODE_STATE_ADDRESS): ga_list_validator,
                vol.Optional(CONF_CONTROLLER_STATUS_ADDRESS): ga_list_validator,
                vol.Optional(CONF_CONTROLLER_STATUS_STATE_ADDRESS): ga_list_validator,
                vol.Optional(CONF_CONTROLLER_MODE_ADDRESS): ga_list_validator,
                vol.Optional(CONF_CONTROLLER_MODE_STATE_ADDRESS): ga_list_validator,
                vol.Optional(CONF_HEAT_COOL_ADDRESS): ga_list_validator,
                vol.Optional(CONF_HEAT_COOL_STATE_ADDRESS): ga_list_validator,
                vol.Optional(
                    CONF_OPERATION_MODE_FROST_PROTECTION_ADDRESS
                ): ga_list_validator,
                vol.Optional(CONF_OPERATION_MODE_NIGHT_ADDRESS): ga_list_validator,
                vol.Optional(CONF_OPERATION_MODE_COMFORT_ADDRESS): ga_list_validator,
                vol.Optional(CONF_OPERATION_MODE_STANDBY_ADDRESS): ga_list_validator,
                vol.Optional(CONF_ON_OFF_ADDRESS): ga_list_validator,
                vol.Optional(CONF_ON_OFF_STATE_ADDRESS): ga_list_validator,
                vol.Optional(
                    CONF_ON_OFF_INVERT, default=DEFAULT_ON_OFF_INVERT
                ): cv.boolean,
                vol.Optional(CONF_OPERATION_MODES): vol.All(
                    cv.ensure_list, [vol.In(PRESET_MODES)]
                ),
                vol.Optional(CONF_CONTROLLER_MODES): vol.All(
                    cv.ensure_list, [vol.In(CONTROLLER_MODES)]
                ),
                vol.Optional(
                    CONF_DEFAULT_CONTROLLER_MODE, default=HVAC_MODE_HEAT
                ): vol.In(HVAC_MODES),
                vol.Optional(CONF_MIN_TEMP): vol.Coerce(float),
                vol.Optional(CONF_MAX_TEMP): vol.Coerce(float),
                vol.Optional(CONF_ENTITY_CATEGORY): ENTITY_CATEGORIES_SCHEMA,
            }
        ),
    )
コード例 #25
0
import homeassistant.helpers.config_validation as cv
from homeassistant import core
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

from .const import CONF_COUNTRY, CONF_WISHLIST, DOMAIN, SCAN_INTERVAL
from .eshop import Country, EShop

_LOGGER = logging.getLogger(__name__)
CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN:
        vol.Schema({
            vol.Required(CONF_WISHLIST): cv.ensure_list,
            vol.Required(CONF_COUNTRY): cv.enum(Country),
        })
    },
    # The full HA configurations gets passed to `async_setup` so we need to allow
    # extra keys.
    extra=vol.ALLOW_EXTRA,
)


async def async_setup(hass: core.HomeAssistant, config: dict) -> bool:
    """Set up the platform.

    @NOTE: `config` is the full dict from `configuration.yaml`.

    :returns: A boolean to indicate that initialization was successful.
    """
コード例 #26
0
ファイル: climate.py プロジェクト: arnonym/xknx
 vol.All(float, vol.Range(min=0, max=2)),
 vol.Optional(CONF_SETPOINT_SHIFT_MAX,
              default=DEFAULT_SETPOINT_SHIFT_MAX):
 vol.All(int, vol.Range(min=0, max=32)),
 vol.Optional(CONF_SETPOINT_SHIFT_MIN,
              default=DEFAULT_SETPOINT_SHIFT_MIN):
 vol.All(int, vol.Range(min=-32, max=0)),
 vol.Required(CONF_TEMPERATURE_ADDRESS):
 cv.string,
 vol.Required(CONF_TARGET_TEMPERATURE_STATE_ADDRESS):
 cv.string,
 vol.Optional(CONF_TARGET_TEMPERATURE_ADDRESS):
 cv.string,
 vol.Optional(CONF_SETPOINT_SHIFT_MODE,
              default=DEFAULT_SETPOINT_SHIFT_MODE):
 cv.enum(SetpointShiftMode),
 vol.Optional(CONF_SETPOINT_SHIFT_ADDRESS):
 cv.string,
 vol.Optional(CONF_SETPOINT_SHIFT_STATE_ADDRESS):
 cv.string,
 vol.Optional(CONF_OPERATION_MODE_ADDRESS):
 cv.string,
 vol.Optional(CONF_OPERATION_MODE_STATE_ADDRESS):
 cv.string,
 vol.Optional(CONF_CONTROLLER_STATUS_ADDRESS):
 cv.string,
 vol.Optional(CONF_CONTROLLER_STATUS_STATE_ADDRESS):
 cv.string,
 vol.Optional(CONF_CONTROLLER_MODE_ADDRESS):
 cv.string,
 vol.Optional(CONF_CONTROLLER_MODE_STATE_ADDRESS):
コード例 #27
0
    no_code = None
    number = FORMAT_NUMBER
    text = FORMAT_TEXT


ALARM_CONTROL_PANEL_SCHEMA = vol.Schema(
    {
        vol.Optional(CONF_VALUE_TEMPLATE): cv.template,
        vol.Optional(CONF_DISARM_ACTION): cv.SCRIPT_SCHEMA,
        vol.Optional(CONF_ARM_AWAY_ACTION): cv.SCRIPT_SCHEMA,
        vol.Optional(CONF_ARM_HOME_ACTION): cv.SCRIPT_SCHEMA,
        vol.Optional(CONF_ARM_NIGHT_ACTION): cv.SCRIPT_SCHEMA,
        vol.Optional(CONF_CODE_ARM_REQUIRED, default=True): cv.boolean,
        vol.Optional(CONF_CODE_FORMAT, default=CodeFormat.number.name): cv.enum(
            CodeFormat
        ),
        vol.Optional(CONF_NAME): cv.string,
        vol.Optional(CONF_UNIQUE_ID): cv.string,
    }
)

PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
    {
        vol.Required(CONF_ALARM_CONTROL_PANELS): cv.schema_with_slug_keys(
            ALARM_CONTROL_PANEL_SCHEMA
        ),
    }
)

コード例 #28
0
DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema(
    {vol.Optional(ha_const.CONF_TYPE): cv.string})
ZHA_CONFIG_SCHEMA = {
    vol.Optional(CONF_BAUDRATE):
    cv.positive_int,
    vol.Optional(CONF_DATABASE):
    cv.string,
    vol.Optional(CONF_DEVICE_CONFIG, default={}):
    vol.Schema({cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}),
    vol.Optional(CONF_ENABLE_QUIRKS, default=True):
    cv.boolean,
    vol.Optional(CONF_ZIGPY):
    dict,
    vol.Optional(CONF_RADIO_TYPE):
    cv.enum(RadioType),
    vol.Optional(CONF_USB_PATH):
    cv.string,
    vol.Optional(CONF_CUSTOM_QUIRKS_PATH):
    cv.isdir,
}
CONFIG_SCHEMA = vol.Schema(
    {
        DOMAIN:
        vol.Schema(
            vol.All(
                cv.deprecated(CONF_USB_PATH),
                cv.deprecated(CONF_BAUDRATE),
                cv.deprecated(CONF_RADIO_TYPE),
                ZHA_CONFIG_SCHEMA,
            ), ),
コード例 #29
0
class DetailsFormat(Enum):
    """Values for CONF_DETAILS_FORMAT."""

    upcoming = "upcoming"  # list of "<date> <type1, type2, ...>"
    appointment_types = "appointment_types"  # list of "<type> <date>"
    generic = "generic"  # all values in separate attributes


PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_NAME):
    cv.string,
    vol.Optional(CONF_SOURCE_INDEX, default=0):
    cv.positive_int,
    vol.Optional(CONF_DETAILS_FORMAT, default="upcoming"):
    cv.enum(DetailsFormat),
    vol.Optional(CONF_COUNT):
    cv.positive_int,
    vol.Optional(CONF_LEADTIME):
    cv.positive_int,
    vol.Optional(CONF_APPOINTMENT_TYPES):
    cv.ensure_list,
    vol.Optional(CONF_VALUE_TEMPLATE):
    cv.template,
    vol.Optional(CONF_DATE_TEMPLATE):
    cv.template,
})


async def async_setup_platform(hass,
                               config,
コード例 #30
0

CONF_BAUDRATE = 'baudrate'
CONF_DATABASE = 'database_path'
CONF_DEVICE_CONFIG = 'device_config'
CONF_RADIO_TYPE = 'radio_type'
CONF_USB_PATH = 'usb_path'
DATA_DEVICE_CONFIG = 'zha_device_config'

DEVICE_CONFIG_SCHEMA_ENTRY = vol.Schema({
    vol.Optional(ha_const.CONF_TYPE): cv.string,
})

CONFIG_SCHEMA = vol.Schema({
    DOMAIN: vol.Schema({
        vol.Optional(CONF_RADIO_TYPE, default='ezsp'): cv.enum(RadioType),
        CONF_USB_PATH: cv.string,
        vol.Optional(CONF_BAUDRATE, default=57600): cv.positive_int,
        CONF_DATABASE: cv.string,
        vol.Optional(CONF_DEVICE_CONFIG, default={}):
            vol.Schema({cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}),
    })
}, extra=vol.ALLOW_EXTRA)

ATTR_DURATION = 'duration'
ATTR_IEEE = 'ieee_address'

SERVICE_PERMIT = 'permit'
SERVICE_REMOVE = 'remove'
SERVICE_SCHEMAS = {
    SERVICE_PERMIT: vol.Schema({
コード例 #31
0
    GB = 'UK/Ireland'
    IT = 'Italy'
    NL = 'Netherlands'
    PT = 'Portugal'
    RU = 'Russia'
    US = 'United States'
    ZA = 'South Africa'


CONF_COUNTRY = 'country'
CONF_WISHLIST = 'wishlist'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_WISHLIST):
    cv.ensure_list,
    vol.Required(CONF_COUNTRY):
    cv.enum(Country),
})

# These are specific to European countries.
EU_SEARCH_URL = 'https://searching.nintendo-europe.com/{language}/select?q=*&fq=type%3AGAME%20AND%20((playable_on_txt%3A%22HAC%22)%20AND%20(price_has_discount_b%3A%22true%22))%20AND%20sorting_title%3A*%20AND%20*%3A*&sort=price_discount_percentage_f%20desc%2C%20price_lowest_f%20desc&start=0&rows=500&wt=json&bf=linear(ms(priority%2CNOW%2FHOUR)%2C1.1e-11%2C0)'  # noqa
EU_PRICE_URL = 'https://api.ec.nintendo.com/v1/price'

# Below constants used by North America (US and CA)
APP_ID = 'U3B6GR4UA3'
API_KEY = '9a20c93440cf63cf1a7008d75f7438bf'
QUERIES = [
    {
        'indexName':
        'noa_aem_game_en_us',
        'params':
        'query=&hitsPerPage=350&maxValuesPerFacet=30&page=0&facets=%5B%22generalFilters%22%2C%22platform%22%2C%22availability%22%2C%22categories%22%2C%22filterShops%22%2C%22virtualConsole%22%2C%22characters%22%2C%22priceRange%22%2C%22esrb%22%2C%22filterPlayers%22%5D&tagFilters=&facetFilters=%5B%5B%22generalFilters%3ADeals%22%5D%2C%5B%22platform%3ANintendo%20Switch%22%5D%5D'  # noqa