Madelena / hass-config-public

My Dashboards for Home Assistant - Advanced data visualizations, responsive design, a neat maximalist Metro Live Tile layout, and an ultraminimal tablet layout!
686 stars 54 forks source link

Chore tracker Done/To Do/Overdue error fix #26

Open Dae657 opened 9 months ago

Dae657 commented 9 months ago

I've been having a hard time getting "There are X chores done, X to do soon, and X overdue." to show. In the template file, I noticed that Chores Done was the only one of the three with " unit_of_measurement: "Tasks"", so I removed it, and it works now.

I know it's an old guide, but you may also want to add a way to have categories of chores in the guide. When I first installed it, I was confused on how your guide only had a way to set a whole chore group, but your screenshots had them categorized. So I named all of my chores e.g. 'chorekitchen' and set up individual automations for each category to set groups for object_id that start with 'chorekitchen' etc, then later learned that I could combine those into a single automation with multiple service calls. In your new code merge, I saw that you had a yaml file setting chore groups, which I've now incorporated and changed the automation back to just set a group for all chores, though I don't know which method makes more sense in this setting.

As a side note, I added a confirmation to completing chores with the tap action, because I was often accidentally marking chores as done while scrolling through the column on mobile.

confirmation: text: Are you sure you want to mark this as done?

Just for some context, I have no idea what I'm doing with code - I'm just fumbling through all this using patchwork code from various people and playing with it a bit, so I hope this is actually helpful. This chore tracker is probably the most useful thing I've had on Home Assistant, and my wife loves it. Thank you for putting it together!

Edit: Could you point me in the direction of changing how it calculates "to do soon"? I think I've found the bit that does it, but have no idea what to do with it. Asking because we have some things that we're tracking for a month+ and something for a full year, so it's coming up as a to-do task for weeks/months.

rikvanzoest commented 7 months ago

I'm actually struggling with getting the chores sensor to load. Actually any of the button_card sensors. I have the templates loaded from the lovelace-ui using:

button_card_templates: !include_dir_merge_named templates/button-card/

I must be missing a call to the sensors. I have this in configuration.yaml

sensor: !include_dir_merge_named config/sensors template: !include_dir_merge_named config/templates group: !include_dir_merge_named config/groups input_button: !include config/chores.yaml input_text: !include config/chores.yaml

I'll look further into to your question

Dae657 commented 7 months ago

When you say chores sensor, do you mean as a sensor.XXXXX entity, or just to appear as a card?

If it's sensor.XXXX, the only ones are sensor.chores_done, sensor.chores_to_do, and sensor.chores_overdue, which are made with the templates as far as I can tell. I don't have anything relevant in the sensors part of my configuration.yaml and it still works.

What happens if you add a trailing slash after your directories? You have it for your button card templates, but not the other directories. For example:

!include_dir_merge_named config/groups/

If that doesn't work, go into developer tools->states and type in "chore" (without the quotation marks) in the entity filter. Then ctrl+f for sensor, input_button, input_text, and group and see what does/doesn't come up. I assume you've done that, but just for the sake of saying it.

rikvanzoest commented 7 months ago

Its the template files found here: https://github.com/Madelena/hass-config-public/blob/main/config/templates/chores.yaml

I'll give the trailing slash a try. so you don't have any reference going to those templates inside your configuration.yaml?

I've searched for them under the developer tools-> states, and nothing has come up.

Would be nice to see a configuration.yaml for this setup, I've commented out anything that asks for 'secret' just to see if I can get things working, and i'm slowly getting it to work, tossing or replacing things.

Sorry its been a bit, I'm in the process of moving and haven't been able to plug in my HA. I'm thinking I may plug it in this evening when i'm sitting doing nothing.

Dae657 commented 7 months ago

The 3 relevant lines in my configuration.yaml are:

`template: !include_dir_merge_list config-3_0/templates/

input_button: !include config-3_0/chores.yaml

input_text: !include config-3_0/chores.yaml`

As far as I can tell, you should be getting input_button without the templates, though. As it says on the top of her template file, that is only to "Calculate the number of chores done, to do, or overdue."

Try the trailing slash. Also, do you have Lovelace Gen configured correctly, with# lovelace_gen at the top of the relevant yaml files?

rikvanzoest commented 7 months ago

I tried the trailing slash with no luck. Also I don't see anything about Lovelace Gen? I searched on this repository and the only hit is your mention of it just now?

Dae657 commented 7 months ago

Hmm, looking at it more, Lovelace Gen that may have just been something I had for something else or an old version of this.

So just to make sure I've got it right, you don't have any chore input buttons or input text? I just made a quick random test input button, and it loaded immediately. If you don't have any at all, that would be the first place to look.

rikvanzoest commented 7 months ago

I have the chore input buttons. Those work. Its the template that calculates the 'chores to do' etc. that doesn't seem to be loading. I've been looking in the logs and I seem to be getting an error from it so I think its loading but causing an error one way or another. Once I find a relevant error, i'll upload it or I may just upload the whole log as long as there isn't anything personal in there. Thanks

rikvanzoest commented 7 months ago

2024-03-05 13:01:27.948 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=(# Maintenance There are {{ state_attr('sensor.chores_done', 'entities')|length }} chores done, {{ state_attr('sensor.chores_to_do', 'entities')|length }} to do soon, and {{ state_attr('sensor.chores_overdue', 'entities')|length }} overdue.) renders=2> Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 572, in async_render render_result = _render_with_context(self.template, compiled, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2332, in _render_with_context return template.render(kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 1301, in render self.environment.handle_exception() File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 936, in handle_exception raise rewrite_traceback_stack(source=source) File "