mirror of
https://github.com/esphome/esphome.git
synced 2025-11-08 02:51:49 +00:00
Merge remote-tracking branch 'upstream/dev' into integration
This commit is contained in:
@@ -138,6 +138,7 @@ def _concat_nodes_override(values: Iterator[Any]) -> Any:
|
|||||||
values = chain(head, values)
|
values = chain(head, values)
|
||||||
raw = "".join([str(v) for v in values])
|
raw = "".join([str(v) for v in values])
|
||||||
|
|
||||||
|
result = None
|
||||||
try:
|
try:
|
||||||
# Attempt to parse the concatenated string into a Python literal.
|
# Attempt to parse the concatenated string into a Python literal.
|
||||||
# This allows expressions like "1 + 2" to be evaluated to the integer 3.
|
# This allows expressions like "1 + 2" to be evaluated to the integer 3.
|
||||||
@@ -145,11 +146,16 @@ def _concat_nodes_override(values: Iterator[Any]) -> Any:
|
|||||||
# fall back to returning the raw string. This is consistent with
|
# fall back to returning the raw string. This is consistent with
|
||||||
# Home Assistant's behavior when evaluating templates
|
# Home Assistant's behavior when evaluating templates
|
||||||
result = literal_eval(raw)
|
result = literal_eval(raw)
|
||||||
|
except (ValueError, SyntaxError, MemoryError, TypeError):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if isinstance(result, set):
|
||||||
|
# Sets are not supported, return raw string
|
||||||
|
return raw
|
||||||
|
|
||||||
if not isinstance(result, str):
|
if not isinstance(result, str):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
except (ValueError, SyntaxError, MemoryError, TypeError):
|
|
||||||
pass
|
|
||||||
return raw
|
return raw
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -33,3 +33,4 @@ test_list:
|
|||||||
{{{ "x", "79"}, { "y", "82"}}}
|
{{{ "x", "79"}, { "y", "82"}}}
|
||||||
- '{{{"AA"}}}'
|
- '{{{"AA"}}}'
|
||||||
- '"HELLO"'
|
- '"HELLO"'
|
||||||
|
- '{ 79, 82 }'
|
||||||
|
|||||||
@@ -34,3 +34,4 @@ test_list:
|
|||||||
{{{ "x", "${ position.x }"}, { "y", "${ position.y }"}}}
|
{{{ "x", "${ position.x }"}, { "y", "${ position.y }"}}}
|
||||||
- ${ '{{{"AA"}}}' }
|
- ${ '{{{"AA"}}}' }
|
||||||
- ${ '"HELLO"' }
|
- ${ '"HELLO"' }
|
||||||
|
- '{ ${position.x}, ${position.y} }'
|
||||||
|
|||||||
Reference in New Issue
Block a user