Enhance chore tracker: Set default icons for chores without specified icons and add warnings for missing icons during generation

This commit is contained in:
Joshua King
2026-02-28 12:48:44 -05:00
parent 9b4908c39b
commit 338025d55b
2 changed files with 24 additions and 1 deletions

View File

@@ -891,6 +891,7 @@ lvgl:
y: -34 y: -34
text: "󰋣" text: "󰋣"
text_font: font_mdi_small text_font: font_mdi_small
text_color: 0x4D96FF
- label: - label:
align: CENTER align: CENTER
y: 17 y: 17
@@ -927,6 +928,7 @@ lvgl:
y: -34 y: -34
text: "󰦩" text: "󰦩"
text_font: font_mdi_small text_font: font_mdi_small
text_color: 0x4D96FF
- label: - label:
align: CENTER align: CENTER
y: 17 y: 17
@@ -963,6 +965,7 @@ lvgl:
y: -34 y: -34
text: "󰆫" text: "󰆫"
text_font: font_mdi_small text_font: font_mdi_small
text_color: 0x4D96FF
- label: - label:
align: CENTER align: CENTER
y: 17 y: 17
@@ -999,6 +1002,7 @@ lvgl:
y: -34 y: -34
text: "󱜜" text: "󱜜"
text_font: font_mdi_small text_font: font_mdi_small
text_color: 0x4D96FF
- label: - label:
align: CENTER align: CENTER
y: 17 y: 17
@@ -1130,6 +1134,7 @@ lvgl:
y: -34 y: -34
text: "󰐂" text: "󰐂"
text_font: font_mdi_small text_font: font_mdi_small
text_color: 0xC77DFF
- label: - label:
align: CENTER align: CENTER
y: 17 y: 17
@@ -1166,6 +1171,7 @@ lvgl:
y: -34 y: -34
text: "󰇷" text: "󰇷"
text_font: font_mdi_small text_font: font_mdi_small
text_color: 0xC77DFF
- label: - label:
align: CENTER align: CENTER
y: 17 y: 17
@@ -1297,6 +1303,7 @@ lvgl:
y: -34 y: -34
text: "󰊩" text: "󰊩"
text_font: font_mdi_small text_font: font_mdi_small
text_color: 0xFF6B9D
- label: - label:
align: CENTER align: CENTER
y: 17 y: 17
@@ -1333,6 +1340,7 @@ lvgl:
y: -34 y: -34
text: "󰇷" text: "󰇷"
text_font: font_mdi_small text_font: font_mdi_small
text_color: 0xFF6B9D
- label: - label:
align: CENTER align: CENTER
y: 17 y: 17
@@ -1369,6 +1377,7 @@ lvgl:
y: -34 y: -34
text: "󰇷" text: "󰇷"
text_font: font_mdi_small text_font: font_mdi_small
text_color: 0xFF6B9D
- label: - label:
align: CENTER align: CENTER
y: 17 y: 17

View File

@@ -49,8 +49,15 @@ def eid(kid: dict, chore: dict) -> str:
def ha_switch(kid: dict, chore: dict) -> str: def ha_switch(kid: dict, chore: dict) -> str:
return f"switch.chore_tracker_{eid(kid, chore)}" return f"switch.chore_tracker_{eid(kid, chore)}"
# mdi:checkbox-marked-circle-outline — safe default if icon is omitted
DEFAULT_ICON = "\U000F0133"
def get_chores(kid: dict) -> list: def get_chores(kid: dict) -> list:
return kid["chores"] chores = kid["chores"]
for c in chores:
if "icon" not in c:
c["icon"] = DEFAULT_ICON
return chores
# ───────────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────────
@@ -461,6 +468,7 @@ def _gen_lvgl_pages(kids: list) -> str:
y: {icon_y} y: {icon_y}
text: "{chore['icon']}" text: "{chore['icon']}"
text_font: font_mdi_small text_font: font_mdi_small
text_color: 0x{kid['color']}
- label: - label:
align: CENTER align: CENTER
y: {label_y} y: {label_y}
@@ -900,6 +908,12 @@ def main():
print(" Add a 'chores:' list under each kid in chores_config.yaml") print(" Add a 'chores:' list under each kid in chores_config.yaml")
sys.exit(1) sys.exit(1)
# Warn about missing icons (will use default, not crash)
for k in kids:
for c in k.get("chores", []):
if "icon" not in c:
print(f"⚠️ {k['name']} / '{c['name']}' has no icon — using default")
total_chores = sum(len(get_chores(k)) for k in kids) total_chores = sum(len(get_chores(k)) for k in kids)
print(f"✅ Config loaded: {len(kids)} kid(s), {total_chores} total chores") print(f"✅ Config loaded: {len(kids)} kid(s), {total_chores} total chores")
for k in kids: for k in kids: