From 6480e096b93adfa959a8eda2454f2b0b29082a7c Mon Sep 17 00:00:00 2001 From: Franz Schwartau Date: Sun, 29 Oct 2023 17:43:11 +0100 Subject: [PATCH 1/2] fix: get_text_len called with types other than string Setting temp_suffix to None results in an error: ERROR (MainThread) [homeassistant.components.automation.weather_display] Error rendering variables: TypeError: 'float' object is not iterable To solve this cast the string argument of get_text_len to string when iterating. --- blueprints/automation/awtrix_weatherflow.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blueprints/automation/awtrix_weatherflow.yaml b/blueprints/automation/awtrix_weatherflow.yaml index 9b502dc..e5e0bea 100644 --- a/blueprints/automation/awtrix_weatherflow.yaml +++ b/blueprints/automation/awtrix_weatherflow.yaml @@ -656,7 +656,7 @@ variables: text_len: >- {%- macro get_text_len(string) %} {%- set length = namespace(value=0) %} - {%- for char in string %} + {%- for char in string|string() %} {%- if char.isdigit() %} {%- set length.value = length.value + 3 %} {%- elif char == '°' %} From 8f72ac3dfb9910e6aa6899ab5700a1d982114467 Mon Sep 17 00:00:00 2001 From: Franz Schwartau Date: Sun, 29 Oct 2023 17:48:56 +0100 Subject: [PATCH 2/2] chore: rename argument for get_text_len to avoid confusion --- blueprints/automation/awtrix_weatherflow.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blueprints/automation/awtrix_weatherflow.yaml b/blueprints/automation/awtrix_weatherflow.yaml index e5e0bea..0b91d66 100644 --- a/blueprints/automation/awtrix_weatherflow.yaml +++ b/blueprints/automation/awtrix_weatherflow.yaml @@ -654,9 +654,9 @@ variables: text_available_width: > {%- if show_moon %}16{%- else %}24{%- endif %} text_len: >- - {%- macro get_text_len(string) %} + {%- macro get_text_len(text) %} {%- set length = namespace(value=0) %} - {%- for char in string|string() %} + {%- for char in text|string() %} {%- if char.isdigit() %} {%- set length.value = length.value + 3 %} {%- elif char == '°' %}