Building an activity tracker in Home Assistant ...that your kids want to use
Home Assistant’s extensibility is probably one of my favorite things about the platform. Recently, I was thinking of ways to encourage my kids to be more consistent in their chores without constant reminding from my wife and I. To be successful in my goal, I figured I needed to address visibility into which chores were outstanding and then motivation so they willingly chose to do them. Of course, technology is not a solution for all things, but in this case, there seemed to be potential to get some help from Home Assistant. We have a family dashboard for events and locations, so I added a separate chore list to the dashboard for each of my kids (11 & 6) as shown below.
Completing a chore adds to their weekly “earnings”. The chores are loosely expected to be completed each day but don’t have to be. Naturally, doing more, earns more (…and yes, it is honor system based). At the end of the week, the accumulated total rolls into the Last week column and they start at zero again (…for permanent storage eventhing goes into Grafana).
There’s a few steps required to pull this together in Home Assistant so here’s the breakdown if interested.
Part I - Create Entities
Step 1
Create unique chores with input booleans.
input_boolean:
sydney_empty_dishwasher:
name: "Empty Dishwasher"
icon: mdi:dishwasher
Step 2
Use input numbers to store “points” earned for completed chores.
For my use case, I created this entity at the person level*, but depending on your level of complexity it could also be done at the chore type level or even on a per chore basis.
input_number:
points_this_week_4sydney:
name: Sydney Points This Week
icon: mdi:clock-start
min: 0
max: 1000
step: 1
*Note: I am actually using two input numbers to store points. One each for “This week” and “Last week” as shown in the image at the top of this post
Step 3
Create a template sensor to display the input number total in the UI.
Why not just display the input number directly instead? Well, for starters, input numbers are designed to be controlled from the UI via a slider or an input box, which in this case, would expose too much control. Secondly, input numbers only display the raw number, so if you want to format the value, like to display a currency, you’ll need to use the templating platform. Lastly, this is a convenient place to make any adjustment calculations. For example, my son is 6 and has very basic chores so I have arbitrarily decided they should be worth 50 cents a piece (I know…). His point total is therefore adjusted by 0.5 to get the dollar equivalent.
- platform: template
sensors:
chore_total_this_week_carson:
friendly_name: "Carson's weekly total:"
value_template: >-
{% set amt = states("input_number.points_this_week_4carson") | float %}
{% if amt >0 %}
{% set total = amt * 0.5 %}
{% else %}
{% set total = 0.00 %}
{% endif %}
{{ '${:,.2f}'.format(float(total)) }}
Part II - Create Automations
After the entities have been created, the next step is to create automations to get the expected working behavior. I use Node-Red for my automations and that is what you will see in the following examples. The logic is easy enough and shouldn’t vary much even if you are using a different automation platform, like say Home Assistant’s yaml based automation engine.
Step 4
Create a process to increment/decrement the input number whenever an input boolean is toggled on/off
.
Here’s how the flow looks in Node-Red:
Get the codeExplanation:
- Whenever a chore (input boolean) is toggled
ON
the input number will be increased by one. - Whenever a chore is toggled
OFF
, between 12:01am and 11:59pm, the input number is decreased by 1- Without the decrease function, the process could be gamed by repetitively toggling a chore
ON/OFF
which would cause the input number to continously increase. - The time range function is used to create a two minute window each night around midnight to allow the chores to be reset to the
OFF
postition without decreasing the point totals earned for the day).
- Without the decrease function, the process could be gamed by repetitively toggling a chore
Step 5
Create a process to reset the chore input booleans each night. As evidenced below, nothing fancy is going on here.
Get the codeExplanation:
- After being triggered at midnight each night, the Clear Sydney Chores node is setting each of Sydney’s chores (i.e. the input booleans) back to the off position.
Step 6
Create a process to replace the Last week value with the This week value and then reset This week to zero.
Here’s how that looks:
Get the codeExplanation:
- A time trigger node is set to fire at midnight each Saturday
- A function node is used to retrieve the This week input number value.
- The This week value replaces the Last week value
- This week resets 0
Part III - Update Dashboard
Step 7
The final step exposes the relevant entities in the UI. Here is the yaml that produces my daughter’s chore list shown in the image at the top of this post.
- type: entities
entities:
- entity: input_boolean.sydney_kitty_duties
icon: fas:cat
- entity: input_boolean.sydney_empty_dishwasher
- entity: input_boolean.sydney_5min_pickup
- type: divider
- entity: sensor.chore_total_last_week_sydney
type: custom:multiple-entity-row
name: Stinky Llamas Earned
icon: mdi:unicorn-variant
state_header: Last week
entities:
- entity: sensor.chore_total_sydney
name: This week
title: "Sydney's Chores"
show_header_toggle: false
Note: the above uses multiple-entity-row from HACS to show “This week” and “Last week” totals as columns.
Parting thoughts
Results so far have been postive. Of course, I expect this setup will change over time as our needs change. If you have read this far and the process I’ve outlined doesn’t quite fit your needs, I’ve included a few links below with different takes on chore tracking. The nice thing about Home Assistant is there is enough interest in the platform that regardless of the task you may have in mind, chances are pretty good there’s someone else looking to do something the same or similar.
Thanks for reading!
Alternatives:
- https://community.home-assistant.io/t/chore-tracking-in-home-assistant/231201
- https://leonardosmarthomemakers.com/how-to-track-chores-in-home-assistant-with-grocy-and-nfc-tags/
- https://community.home-assistant.io/t/chores-keep-track-using-ha/153796
- https://www.reddit.com/r/homeassistant/comments/lakixx/my_son_has_to_complete_chores_before_the_tv_smart/