Fix template/switch cover example. Fixes #27

This commit is contained in:
Otto Winter 2018-06-01 22:58:23 +02:00
parent 4fa7bc196a
commit 7a393c1a3a
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
5 changed files with 6 additions and 6 deletions

View File

@ -100,7 +100,7 @@ ACTIONS_SCHEMA = vol.All(cv.ensure_list, [vol.All({
vol.Optional(CONF_SPEED): cv.templatable(fan.validate_fan_speed), vol.Optional(CONF_SPEED): cv.templatable(fan.validate_fan_speed),
}), }),
vol.Optional(CONF_LAMBDA): cv.lambda_, vol.Optional(CONF_LAMBDA): cv.lambda_,
}, cv.has_at_exactly_one_key(*ACTION_KEYS))]) }, cv.has_exactly_one_key(*ACTION_KEYS))])
# pylint: disable=invalid-name # pylint: disable=invalid-name
DelayAction = esphomelib_ns.DelayAction DelayAction = esphomelib_ns.DelayAction
@ -123,7 +123,7 @@ CONDITIONS_SCHEMA = vol.All(cv.ensure_list, [vol.All({
vol.Optional(CONF_BELOW): vol.Coerce(float), vol.Optional(CONF_BELOW): vol.Coerce(float),
}), cv.has_at_least_one_key(CONF_ABOVE, CONF_BELOW)), }), cv.has_at_least_one_key(CONF_ABOVE, CONF_BELOW)),
vol.Optional(CONF_LAMBDA): cv.lambda_, vol.Optional(CONF_LAMBDA): cv.lambda_,
}), cv.has_at_exactly_one_key(*CONDITION_KEYS)]) }), cv.has_exactly_one_key(*CONDITION_KEYS)])
# pylint: disable=invalid-name # pylint: disable=invalid-name
AndCondition = esphomelib_ns.AndCondition AndCondition = esphomelib_ns.AndCondition

View File

@ -14,7 +14,7 @@ PLATFORM_SCHEMA = vol.All(cover.PLATFORM_SCHEMA.extend({
vol.Optional(CONF_OPEN_ACTION): automation.ACTIONS_SCHEMA, vol.Optional(CONF_OPEN_ACTION): automation.ACTIONS_SCHEMA,
vol.Optional(CONF_CLOSE_ACTION): automation.ACTIONS_SCHEMA, vol.Optional(CONF_CLOSE_ACTION): automation.ACTIONS_SCHEMA,
vol.Optional(CONF_STOP_ACTION): automation.ACTIONS_SCHEMA, vol.Optional(CONF_STOP_ACTION): automation.ACTIONS_SCHEMA,
}).extend(cover.COVER_SCHEMA.schema), cv.has_at_exactly_one_key(CONF_LAMBDA, CONF_OPTIMISTIC)) }).extend(cover.COVER_SCHEMA.schema), cv.has_at_least_one_key(CONF_LAMBDA, CONF_OPTIMISTIC))
MakeTemplateCover = Application.MakeTemplateCover MakeTemplateCover = Application.MakeTemplateCover

View File

@ -44,7 +44,7 @@ FILTERS_SCHEMA = vol.All(cv.ensure_list, [vol.All({
vol.Optional(CONF_HEARTBEAT): cv.positive_time_period_milliseconds, vol.Optional(CONF_HEARTBEAT): cv.positive_time_period_milliseconds,
vol.Optional(CONF_DEBOUNCE): cv.positive_time_period_milliseconds, vol.Optional(CONF_DEBOUNCE): cv.positive_time_period_milliseconds,
vol.Optional(CONF_OR): validate_recursive_filter, vol.Optional(CONF_OR): validate_recursive_filter,
}, cv.has_at_exactly_one_key(*FILTER_KEYS))]) }, cv.has_exactly_one_key(*FILTER_KEYS))])
SENSOR_SCHEMA = cv.MQTT_COMPONENT_SCHEMA.extend({ SENSOR_SCHEMA = cv.MQTT_COMPONENT_SCHEMA.extend({
cv.GenerateID('mqtt_sensor', CONF_MQTT_ID): cv.register_variable_id, cv.GenerateID('mqtt_sensor', CONF_MQTT_ID): cv.register_variable_id,

View File

@ -13,7 +13,7 @@ PLATFORM_SCHEMA = vol.All(switch.PLATFORM_SCHEMA.extend({
vol.Optional(CONF_OPTIMISTIC): cv.boolean, vol.Optional(CONF_OPTIMISTIC): cv.boolean,
vol.Optional(CONF_TURN_OFF_ACTION): automation.ACTIONS_SCHEMA, vol.Optional(CONF_TURN_OFF_ACTION): automation.ACTIONS_SCHEMA,
vol.Optional(CONF_TURN_ON_ACTION): automation.ACTIONS_SCHEMA, vol.Optional(CONF_TURN_ON_ACTION): automation.ACTIONS_SCHEMA,
}).extend(switch.SWITCH_SCHEMA.schema), cv.has_at_exactly_one_key(CONF_LAMBDA, CONF_OPTIMISTIC)) }).extend(switch.SWITCH_SCHEMA.schema), cv.has_at_least_one_key(CONF_LAMBDA, CONF_OPTIMISTIC))
MakeTemplateSwitch = Application.MakeTemplateSwitch MakeTemplateSwitch = Application.MakeTemplateSwitch

View File

@ -194,7 +194,7 @@ def has_at_least_one_key(*keys):
return validate return validate
def has_at_exactly_one_key(*keys): def has_exactly_one_key(*keys):
def validate(obj): def validate(obj):
if not isinstance(obj, dict): if not isinstance(obj, dict):
raise vol.Invalid('expected dictionary') raise vol.Invalid('expected dictionary')