Enhance chore tracker: Set default icons for chores without specified icons and add warnings for missing icons during generation
This commit is contained in:
@@ -891,6 +891,7 @@ lvgl:
|
||||
y: -34
|
||||
text: ""
|
||||
text_font: font_mdi_small
|
||||
text_color: 0x4D96FF
|
||||
- label:
|
||||
align: CENTER
|
||||
y: 17
|
||||
@@ -927,6 +928,7 @@ lvgl:
|
||||
y: -34
|
||||
text: ""
|
||||
text_font: font_mdi_small
|
||||
text_color: 0x4D96FF
|
||||
- label:
|
||||
align: CENTER
|
||||
y: 17
|
||||
@@ -963,6 +965,7 @@ lvgl:
|
||||
y: -34
|
||||
text: ""
|
||||
text_font: font_mdi_small
|
||||
text_color: 0x4D96FF
|
||||
- label:
|
||||
align: CENTER
|
||||
y: 17
|
||||
@@ -999,6 +1002,7 @@ lvgl:
|
||||
y: -34
|
||||
text: ""
|
||||
text_font: font_mdi_small
|
||||
text_color: 0x4D96FF
|
||||
- label:
|
||||
align: CENTER
|
||||
y: 17
|
||||
@@ -1130,6 +1134,7 @@ lvgl:
|
||||
y: -34
|
||||
text: ""
|
||||
text_font: font_mdi_small
|
||||
text_color: 0xC77DFF
|
||||
- label:
|
||||
align: CENTER
|
||||
y: 17
|
||||
@@ -1166,6 +1171,7 @@ lvgl:
|
||||
y: -34
|
||||
text: ""
|
||||
text_font: font_mdi_small
|
||||
text_color: 0xC77DFF
|
||||
- label:
|
||||
align: CENTER
|
||||
y: 17
|
||||
@@ -1297,6 +1303,7 @@ lvgl:
|
||||
y: -34
|
||||
text: ""
|
||||
text_font: font_mdi_small
|
||||
text_color: 0xFF6B9D
|
||||
- label:
|
||||
align: CENTER
|
||||
y: 17
|
||||
@@ -1333,6 +1340,7 @@ lvgl:
|
||||
y: -34
|
||||
text: ""
|
||||
text_font: font_mdi_small
|
||||
text_color: 0xFF6B9D
|
||||
- label:
|
||||
align: CENTER
|
||||
y: 17
|
||||
@@ -1369,6 +1377,7 @@ lvgl:
|
||||
y: -34
|
||||
text: ""
|
||||
text_font: font_mdi_small
|
||||
text_color: 0xFF6B9D
|
||||
- label:
|
||||
align: CENTER
|
||||
y: 17
|
||||
|
||||
@@ -49,8 +49,15 @@ def eid(kid: dict, chore: dict) -> str:
|
||||
def ha_switch(kid: dict, chore: dict) -> str:
|
||||
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:
|
||||
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}
|
||||
text: "{chore['icon']}"
|
||||
text_font: font_mdi_small
|
||||
text_color: 0x{kid['color']}
|
||||
- label:
|
||||
align: CENTER
|
||||
y: {label_y}
|
||||
@@ -900,6 +908,12 @@ def main():
|
||||
print(" Add a 'chores:' list under each kid in chores_config.yaml")
|
||||
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)
|
||||
print(f"✅ Config loaded: {len(kids)} kid(s), {total_chores} total chores")
|
||||
for k in kids:
|
||||
|
||||
Reference in New Issue
Block a user