diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index ed3c50cdb00..cbd1f4ffaba 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -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), diff --git a/tests/helpers/test_config_validation.py b/tests/helpers/test_config_validation.py index 62ae79ec5cc..daa8d11d601 100644 --- a/tests/helpers/test_config_validation.py +++ b/tests/helpers/test_config_validation.py @@ -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."""