Allow metadata in service call data (#66672)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com> Co-authored-by: Erik <erik@montnemery.com>pull/66691/head
parent
14e48bac3a
commit
ef34f070ee
|
@ -1058,6 +1058,8 @@ SERVICE_SCHEMA = vol.All(
|
||||||
),
|
),
|
||||||
vol.Optional(CONF_ENTITY_ID): comp_entity_ids,
|
vol.Optional(CONF_ENTITY_ID): comp_entity_ids,
|
||||||
vol.Optional(CONF_TARGET): vol.Any(TARGET_SERVICE_FIELDS, dynamic_template),
|
vol.Optional(CONF_TARGET): vol.Any(TARGET_SERVICE_FIELDS, dynamic_template),
|
||||||
|
# The frontend stores data here. Don't use in core.
|
||||||
|
vol.Remove("metadata"): dict,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
has_at_least_one_key(CONF_SERVICE, CONF_SERVICE_TEMPLATE),
|
has_at_least_one_key(CONF_SERVICE, CONF_SERVICE_TEMPLATE),
|
||||||
|
|
|
@ -410,10 +410,16 @@ def test_service_schema():
|
||||||
"entity_id": "all",
|
"entity_id": "all",
|
||||||
"alias": "turn on kitchen lights",
|
"alias": "turn on kitchen lights",
|
||||||
},
|
},
|
||||||
|
{"service": "scene.turn_on", "metadata": {}},
|
||||||
)
|
)
|
||||||
for value in options:
|
for value in options:
|
||||||
cv.SERVICE_SCHEMA(value)
|
cv.SERVICE_SCHEMA(value)
|
||||||
|
|
||||||
|
# Check metadata is removed from the validated output
|
||||||
|
assert cv.SERVICE_SCHEMA({"service": "scene.turn_on", "metadata": {}}) == {
|
||||||
|
"service": "scene.turn_on"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_entity_service_schema():
|
def test_entity_service_schema():
|
||||||
"""Test make_entity_service_schema validation."""
|
"""Test make_entity_service_schema validation."""
|
||||||
|
|
Loading…
Reference in New Issue