Recipes
Home Assistant
Show the chores of your tribe in Home Assistant and log tasks from automations with the Nipto API.
Two building blocks cover most setups: a RESTful sensor to read Nipto, and a RESTful Command to log a task. Both go in configuration.yaml.
Store the token
Put your token in secrets.yaml so it never shows in your configuration:
nipto_token: YOUR_TOKENFind the ids
Members and tasks are named by their uid. Run this query once, with curl or the explorer at nipto.app/graphql, and note the ones you need:
{ users { uid name } tasks { uid name value } }Read the week
One REST call feeds several sensors. This one counts the activities of the week, the eggs of one member and the last thing done:
rest:
- resource: https://nipto.app/graphql
method: POST
scan_interval: 300
headers:
Authorization: !secret nipto_token
Content-Type: application/json
payload: >-
{"query":"{ activities { user { uid name } task { name value } date }
weeks(limit: 1, sort: DESC) { scores { user { name } score level } } }"}
sensor:
- name: Nipto activities this week
unique_id: nipto_activities_week
value_template: "{{ value_json.data.activities | count }}"
- name: Nipto eggs Camille
unique_id: nipto_eggs_camille
unit_of_measurement: eggs
value_template: >-
{{ value_json.data.activities
| selectattr('user.uid', 'eq', 'CAMILLE_UID')
| map(attribute='task.value') | sum }}
- name: Nipto last activity
unique_id: nipto_last_activity
value_template: >-
{% set last = value_json.data.activities | sort(attribute='date') | last %}
{{ last.user.name ~ ' · ' ~ last.task.name if last else 'none' }}Log a task from an automation
A REST command logs the task for one or more members. Here, when the dishwasher is done, it is logged for Camille:
rest_command:
nipto_log_dishwasher:
url: https://nipto.app/graphql
method: POST
headers:
Authorization: !secret nipto_token
content_type: application/json
payload: >-
{"query":"mutation($doers: [String!], $done: String!) { createActivity(doers: $doers, done: $done) { uid } }",
"variables":{"doers":["CAMILLE_UID"],"done":"DISHWASHER_TASK_UID"}}automation:
- alias: Log the dishwasher in Nipto
triggers:
- trigger: state
entity_id: sensor.dishwasher_status
to: "finished"
actions:
- action: rest_command.nipto_log_dishwasherSeveral members in doers share the eggs, as when they log a task together in the app. Paused members cannot get activities, and if your account is under parental control the activity waits for an admin to approve it.
When it fails
- The sensor turns unavailable when the token is wrong (
401), Premium is over (403) or the day is over its calls (429). The log of Home Assistant shows the status, and Errors explains each one. - A
200with anerrorslist means the query worked but something was refused, for example a task id that does not exist anymore.