From a84c096c6d4b989d449ea8f012f4c31efe391448 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 7 Apr 2024 21:49:44 +0200 Subject: [PATCH] Bugfix to use size and position in templates for the rectangle --- custom_components/divoom_pixoo/const.py | 2 +- custom_components/divoom_pixoo/manifest.json | 2 +- custom_components/divoom_pixoo/sensor.py | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/custom_components/divoom_pixoo/const.py b/custom_components/divoom_pixoo/const.py index 72752fd..f7eee83 100644 --- a/custom_components/divoom_pixoo/const.py +++ b/custom_components/divoom_pixoo/const.py @@ -1,3 +1,3 @@ DOMAIN = "divoom_pixoo" -VERSION = "1.9.0" +VERSION = "1.10.1" CURRENT_ENTRY_VERSION = 2 diff --git a/custom_components/divoom_pixoo/manifest.json b/custom_components/divoom_pixoo/manifest.json index d80c357..c90b356 100644 --- a/custom_components/divoom_pixoo/manifest.json +++ b/custom_components/divoom_pixoo/manifest.json @@ -7,5 +7,5 @@ "iot_class": "local_polling", "issue_tracker": "https://github.com/gickowtf/pixoo-homeassistant/issues", "requirements": [], - "version": "1.9.0" + "version": "1.10.1" } diff --git a/custom_components/divoom_pixoo/sensor.py b/custom_components/divoom_pixoo/sensor.py index 125aeb0..c630305 100644 --- a/custom_components/divoom_pixoo/sensor.py +++ b/custom_components/divoom_pixoo/sensor.py @@ -231,9 +231,15 @@ def _render_page(self, page): elif component['type'] == "rectangle": try: rendered_color = render_color(component.get('color'), self.hass, variables=rendered_variables) - position = ( int(Template(str(component['position'][0])).async_render()), int(Template(str(component['position'][1])).async_render(variables=rendered_variables)) ) - size = ( int(Template(str(component['size'][0])).async_render()), int(Template(str(component['size'][1])).async_render(variables=rendered_variables)) ) - size = (size[0] - 1, size[1] - 1) + + position = [ + int(Template(str(position), self.hass).async_render(variables=rendered_variables)) for position in + component['position'] + ] + size = [ + int(Template(str(size), self.hass).async_render(variables=rendered_variables)) for size in + component['size'] + ] rendered_fill = bool(Template(str(component.get('filled', True)), self.hass).async_render(variables=rendered_variables))