From 4d4be0008b1715656245836d2033bb1370d0e759 Mon Sep 17 00:00:00 2001 From: fakuivan Date: Tue, 5 Mar 2024 15:08:19 -0300 Subject: [PATCH 1/2] Update substitution documentation for esphome/esphome#6308 --- guides/configuration-types.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/guides/configuration-types.rst b/guides/configuration-types.rst index 29e32a906..97c6b130a 100644 --- a/guides/configuration-types.rst +++ b/guides/configuration-types.rst @@ -207,6 +207,30 @@ Two substitution passes are performed allowing compound replacements. something: test: ${bar_${foo}_value} +Additionally since version 2024.3.0, substitutions can be of any type besides strings, the only +requirements are that non-string values must not be interpolated or be used as keys. + +.. code-block:: yaml + substitutions: + devicename: livingroom + upper_devicename: Livingroom + pin_schema: + number: D8 + inverted: True + + esphome: + name: $devicename + # ... + + binary_sensor: + - platform: gpio + # interpolation allowed since ${upper_devicename} contains a string + name: ${upper_devicename} Binary input + # interpolation not allowed, but not needed since pin does not contain + # any other text than "$pin_schema" + pin: $pin_schema + # ... + .. _YAML-insertion-operator: YAML insertion operator From 4377a8717e6a9913ad1b6591bc1e5f50881a7c6b Mon Sep 17 00:00:00 2001 From: fakuivan Date: Tue, 5 Mar 2024 16:10:56 -0300 Subject: [PATCH 2/2] Fix formatting issues --- guides/configuration-types.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/guides/configuration-types.rst b/guides/configuration-types.rst index 97c6b130a..29ed5a2cb 100644 --- a/guides/configuration-types.rst +++ b/guides/configuration-types.rst @@ -211,6 +211,7 @@ Additionally since version 2024.3.0, substitutions can be of any type besides st requirements are that non-string values must not be interpolated or be used as keys. .. code-block:: yaml + substitutions: devicename: livingroom upper_devicename: Livingroom