Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions apps/hassgraph/hass_graph.star
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 = []
Expand All @@ -245,6 +250,10 @@ def render_graph_column(config, current_value, points, unit, label):
width = 12,
height = 12,
))
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"))
align = "space_between" if label else "end"
return render.Column(
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion apps/hassgraph/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ tags:
- sports
- utility
published: '2024-06-19T15:18:22Z'
updated: '2026-06-05T00:54:23Z'
updated: '2026-07-06T22:24:02Z'