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
Bram Kragten 2022-02-16 21:13:36 +01:00 committed by GitHub
parent 14e48bac3a
commit ef34f070ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -1058,6 +1058,8 @@ SERVICE_SCHEMA = vol.All(
),
vol.Optional(CONF_ENTITY_ID): comp_entity_ids,
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),

View File

@ -410,10 +410,16 @@ def test_service_schema():
"entity_id": "all",
"alias": "turn on kitchen lights",
},
{"service": "scene.turn_on", "metadata": {}},
)
for value in options:
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():
"""Test make_entity_service_schema validation."""