From cb96bd9d0b46899cac433fbd32002d9ce4f95739 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 28 Nov 2020 13:19:58 +0100 Subject: [PATCH] Blueprint config to override blueprint (#43724) --- homeassistant/components/blueprint/models.py | 2 +- tests/components/blueprint/test_models.py | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/blueprint/models.py b/homeassistant/components/blueprint/models.py index 6e79b6da842..73417722dcc 100644 --- a/homeassistant/components/blueprint/models.py +++ b/homeassistant/components/blueprint/models.py @@ -172,7 +172,7 @@ class BlueprintInputs: processed = placeholder.substitute( self.blueprint.data, self.inputs_with_default ) - combined = {**self.config_with_inputs, **processed} + combined = {**processed, **self.config_with_inputs} # From config_with_inputs combined.pop(CONF_USE_BLUEPRINT) # From blueprint diff --git a/tests/components/blueprint/test_models.py b/tests/components/blueprint/test_models.py index f5d94a9301a..3680889e56b 100644 --- a/tests/components/blueprint/test_models.py +++ b/tests/components/blueprint/test_models.py @@ -133,15 +133,24 @@ def test_blueprint_validate(): ) -def test_blueprint_inputs(blueprint_1): +def test_blueprint_inputs(blueprint_2): """Test blueprint inputs.""" inputs = models.BlueprintInputs( - blueprint_1, - {"use_blueprint": {"path": "bla", "input": {"test-placeholder": 1}}}, + blueprint_2, + { + "use_blueprint": { + "path": "bla", + "input": {"test-placeholder": 1, "test-placeholder-default": 12}, + }, + "example-default": {"overridden": "via-config"}, + }, ) inputs.validate() - assert inputs.inputs == {"test-placeholder": 1} - assert inputs.async_substitute() == {"example": 1} + assert inputs.inputs == {"test-placeholder": 1, "test-placeholder-default": 12} + assert inputs.async_substitute() == { + "example": 1, + "example-default": {"overridden": "via-config"}, + } def test_blueprint_inputs_validation(blueprint_1):