From 2208221d77ad3d5542b52bce7a2a1f52146b0461 Mon Sep 17 00:00:00 2001 From: Tavis Date: Mon, 6 Jul 2026 15:12:28 -0700 Subject: [PATCH 1/6] hass_graph feat: round value option --- apps/hassgraph/hass_graph.star | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/apps/hassgraph/hass_graph.star b/apps/hassgraph/hass_graph.star index c63fee36d..cda2cbb8c 100644 --- a/apps/hassgraph/hass_graph.star +++ b/apps/hassgraph/hass_graph.star @@ -5,6 +5,7 @@ load("images/img_2274bcef.bin", IMG_2274bcef_ASSET = "file") load("images/img_7b76fdf3.bin", IMG_7b76fdf3_ASSET = "file") load("images/img_adff806b.svg", IMG_adff806b_ASSET = "file") load("images/img_fbe29b76.svg", IMG_fbe29b76_ASSET = "file") +load("math.star", "math") load("render.star", "render") load("schema.star", "schema") load("time.star", "time") @@ -234,6 +235,10 @@ def render_app(config, current_value, points, stats, unit, label): child = render_graph_column(config, current_value, points, unit, label), ) +def round(num, precision): + """Round a float to the specified number of significant digits""" + return math.round(num * math.pow(10, precision)) / math.pow(10, precision) + def render_graph_column(config, current_value, points, unit, label): icon = get_icon(config) children = [] @@ -245,6 +250,10 @@ def render_graph_column(config, current_value, points, unit, label): width = 12, height = 12, )) + if (config.get("round_to", "none") != "none"): + decimal = int(config.get("round_to")) + val = round(float(current_value), decimal) + current_value = str(int(val)) if val == int(val) else str(val) children.append(render.Text(content = current_value + unit, font = "6x13")) align = "space_between" if label else "end" return render.Column( @@ -389,6 +398,31 @@ def get_schema(): icon = "filter", name = "Display range", ), + schema.Dropdown( + id = "round_to", + desc = "Round to which decimal", + icon = "filter", + name = "Round To", + default = "none", + options = [ + schema.Option( + display = "None", + value = "none", + ), + schema.Option( + display = "Ones", + value = "0", + ), + schema.Option( + display = "Tenths", + value = "1", + ), + schema.Option( + display = "Hundreths", + value = "2", + ), + ], + ), schema.Location( id = "location", name = "Location", From 00a7656e5f68c94bd040fae02f79ce5ef3098779 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 6 Jul 2026 22:13:09 +0000 Subject: [PATCH 2/6] chore: auto-update manifest metadata [skip ci] --- apps/hassgraph/manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/hassgraph/manifest.yaml b/apps/hassgraph/manifest.yaml index 02b1ecf58..b1b516a13 100644 --- a/apps/hassgraph/manifest.yaml +++ b/apps/hassgraph/manifest.yaml @@ -13,4 +13,4 @@ tags: - sports - utility published: '2024-06-19T15:18:22Z' -updated: '2026-06-05T00:54:23Z' +updated: '2026-07-06T22:12:28Z' From 1da81f92105b4518df9a9a9354b42f9cded83fc8 Mon Sep 17 00:00:00 2001 From: Tavis Date: Mon, 6 Jul 2026 15:18:51 -0700 Subject: [PATCH 3/6] use config.str and check for bad vals Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- apps/hassgraph/hass_graph.star | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/hassgraph/hass_graph.star b/apps/hassgraph/hass_graph.star index cda2cbb8c..45f787c6f 100644 --- a/apps/hassgraph/hass_graph.star +++ b/apps/hassgraph/hass_graph.star @@ -250,8 +250,9 @@ def render_graph_column(config, current_value, points, unit, label): width = 12, height = 12, )) - if (config.get("round_to", "none") != "none"): - decimal = int(config.get("round_to")) + round_to = config.str("round_to", "none") + if round_to != "none" and current_value not in ("unavailable", "unknown"): + decimal = int(round_to) val = round(float(current_value), decimal) current_value = str(int(val)) if val == int(val) else str(val) children.append(render.Text(content = current_value + unit, font = "6x13")) From 237d0bdd3aa56027cb95906be33000299c57aea8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 6 Jul 2026 22:19:11 +0000 Subject: [PATCH 4/6] chore: auto-update manifest metadata [skip ci] --- apps/hassgraph/manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/hassgraph/manifest.yaml b/apps/hassgraph/manifest.yaml index b1b516a13..fb8945dac 100644 --- a/apps/hassgraph/manifest.yaml +++ b/apps/hassgraph/manifest.yaml @@ -13,4 +13,4 @@ tags: - sports - utility published: '2024-06-19T15:18:22Z' -updated: '2026-07-06T22:12:28Z' +updated: '2026-07-06T22:18:51Z' From 7c50c71d47f2e03d6a9cc41415d085ba5c7025a5 Mon Sep 17 00:00:00 2001 From: Tavis Date: Mon, 6 Jul 2026 15:24:02 -0700 Subject: [PATCH 5/6] only do decimal if config.get returns 0,1,2 --- apps/hassgraph/hass_graph.star | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/hassgraph/hass_graph.star b/apps/hassgraph/hass_graph.star index 45f787c6f..0dadc5ac2 100644 --- a/apps/hassgraph/hass_graph.star +++ b/apps/hassgraph/hass_graph.star @@ -250,9 +250,8 @@ def render_graph_column(config, current_value, points, unit, label): width = 12, height = 12, )) - round_to = config.str("round_to", "none") - if round_to != "none" and current_value not in ("unavailable", "unknown"): - decimal = int(round_to) + if (config.str("round_to") in ["0", "1", "2"]): + decimal = int(config.get("round_to")) val = round(float(current_value), decimal) current_value = str(int(val)) if val == int(val) else str(val) children.append(render.Text(content = current_value + unit, font = "6x13")) From e8afc600759d98bffa84d12035fd2557cc4bbfdb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 6 Jul 2026 22:25:17 +0000 Subject: [PATCH 6/6] chore: auto-update manifest metadata [skip ci] --- apps/hassgraph/manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/hassgraph/manifest.yaml b/apps/hassgraph/manifest.yaml index fb8945dac..ddd3065c3 100644 --- a/apps/hassgraph/manifest.yaml +++ b/apps/hassgraph/manifest.yaml @@ -13,4 +13,4 @@ tags: - sports - utility published: '2024-06-19T15:18:22Z' -updated: '2026-07-06T22:18:51Z' +updated: '2026-07-06T22:24:02Z'