Ejemplo n.º 1
0
async def async_get_trigger_capabilities(
        hass: HomeAssistant, config: ConfigType) -> dict[str, vol.Schema]:
    """List trigger capabilities."""
    try:
        options = get_capability(hass, config[CONF_ENTITY_ID],
                                 ATTR_OPTIONS) or []
    except HomeAssistantError:
        options = []

    return {
        "extra_fields":
        vol.Schema({
            vol.Optional(CONF_FROM): vol.In(options),
            vol.Optional(CONF_TO): vol.In(options),
            vol.Optional(CONF_FOR): cv.positive_time_period_dict,
        })
    }
Ejemplo n.º 2
0
async def async_get_condition_capabilities(hass, config):
    """List condition capabilities."""
    condition_type = config[CONF_TYPE]

    fields = {}

    if condition_type == "is_mode":
        try:
            modes = (get_capability(hass, config[ATTR_ENTITY_ID],
                                    const.ATTR_AVAILABLE_MODES) or [])
        except HomeAssistantError:
            modes = []

        fields[vol.Required(ATTR_MODE)] = vol.In(modes)

        return {"extra_fields": vol.Schema(fields)}

    return await toggle_entity.async_get_condition_capabilities(hass, config)
Ejemplo n.º 3
0
async def async_get_action_capabilities(hass, config):
    """List action capabilities."""
    action_type = config[CONF_TYPE]

    fields = {}

    if action_type == "set_humidity":
        fields[vol.Required(const.ATTR_HUMIDITY)] = vol.Coerce(int)
    elif action_type == "set_mode":
        try:
            available_modes = (get_capability(hass, config[ATTR_ENTITY_ID],
                                              const.ATTR_AVAILABLE_MODES)
                               or [])
        except HomeAssistantError:
            available_modes = []
        fields[vol.Required(ATTR_MODE)] = vol.In(available_modes)
    else:
        return {}

    return {"extra_fields": vol.Schema(fields)}