Thanks to @grinstantin for the base js card.
Local ToDo card for Home Assistant Lovelace UI. This card displays items from local SQLite database.
- Download
localtodo-card.js
file from the latest release. - Put
localtodo-card.js
file into yourconfig/www
folder. - Add a reference to
localtodo-card.js
in Lovelace. There are two ways to do that:- Using UI: Configuration → Lovelace Dashboards → Resources → Click Plus button → Set Url as
/local/localtodo-card.js
→ Set Resource type asJavaScript Module
. - Using YAML: Add the following code to
lovelace
section.resources: - url: /local/localtodo-card.js type: module
- Using UI: Configuration → Lovelace Dashboards → Resources → Click Plus button → Set Url as
- Add
custom:localtodo-card
to Lovelace UI as any other card (using either editor or YAML configuration).
i. Docker
docker pull dielee/local-todo-card:latest
docker run -d -p ExternalPort:5556 --name "localToDo" -e toDoLanguage="yourLanguage" -e toDoPersons="Person1,Person2,Person3" dielee/local-todo-card:latest
ii. Manual
- Change settings in config.yaml to your needs
- Install flask
pip3 install flask, PyYAML
- Run main.py from /src
python3 __init__.py
This card can be configured using Lovelace UI editor.
-
Add the following code to
configuration.yaml
:sensor: - platform: rest name: To-do List method: GET resource: 'http://ipServerRuns:port/getToDoListItems' value_template: '{{value_json[''project''][''id'']}}' json_attributes: - items - settings scan_interval: 30 rest_command: todoist: method: post url: 'http://ipServerRuns:port/setToDoListItems' payload: commands={{commands}} content_type: 'application/x-www-form-urlencoded'
-
Reload configs or restart Home Assistant.
-
In Lovelace UI, click 3 dots in top left corner.
-
Click Edit Dashboard.
-
Click Add Card button in the bottom right corner to add a new card.
-
Find Custom: Todoist Card in the list.
-
Choose
entity
. -
Now you should see the preview of the card!
Typical example of using this card in YAML config would look like this:
type: 'custom:localtodo-card'
entity: sensor.to_do_list
name: 'Aufgaben'
done_tasks: 2
show_header: true
show_item_add: true
show_item_close: true
show_item_delete: true
show_item_edit: true
Here is what every option means:
Name | Type | Default | Description |
---|---|---|---|
type |
string |
required | custom:todoist-card |
entity |
string |
required | An entity_id within the sensor domain. |
name |
string |
Top card Name. | |
done_tasks |
int |
Show done tasks in days | |
show_header |
boolean |
true |
Show friendly name of the selected sensor in the card header. |
show_item_add |
boolean |
true |
Show text input element for adding new items to the list. |
show_item_close |
boolean |
true |
Show close/complete buttons. |
show_item_delete |
boolean |
true |
Show delete buttons. |
show_item_edit |
boolean |
true |
Show edit buttons. |
show_item_edit |
boolean |
true |
Show pin buttons. |
rest_command:
todoistmanualadd:
method: post
url: 'http://192.168.50.2:5556/setToDoListItems'
payload: 'commands=[{"type":"item_add","temp_id":"{{ now() | as_timestamp()}}","args":{"content":"{{content}}", "responsePerson":"{{responsePerson}}"}}]'
content_type: 'application/x-www-form-urlencoded'
Automation/script action:
- service: rest_command.todoistmanualadd
data:
content: "Task name here"
responsePerson: "Person name here" #optional
sensors:
- platform: template
sensors:
OneNameFromConfigYaml_tasks:
value_template: >-
{% set value_json = state_attr('sensor.to_do_list','items') %}
{% set tasks = value_json | selectattr ('responsePerson', 'eq', '<OneNameFromConfigYaml>') | selectattr ('checked', 'eq', 0) | map(attribute='content') | list %}
{% set values = namespace(content=[]) %}
{% for task in tasks %}
{% set values.content = values.content + [task] %}
{% endfor %}
{% set cnt = {'tasks':values.content | count } %}
{{ cnt.tasks }}
attribute_templates:
tasks: >-
{% set value_json = state_attr('sensor.to_do_list','items') %}
{% set tasks = value_json | selectattr ('responsePerson', 'eq', '<OneNameFromConfigYaml>') | selectattr ('checked', 'eq', 0) | map(attribute='content') | list %}
{% set values = namespace(content=[]) %}
{% for task in tasks %}
{% set values.content = values.content + [task] %}
{% endfor %}
{{ {'tasks':values.content} }}
automation:
alias: Notify_linus_newTask
description: ''
trigger:
- platform: state
entity_id: sensor.<OneNameFromConfigYaml_tasks>
condition:
- condition: template
value_template: '{{ trigger.from_state.state | int < trigger.to_state.state | int }}'
action:
- service: notify.mobile_app_ac2003
data:
title: Dir wurde eine neue Aufgabe zugewiesen!
message: >-
{% set aufgaben = state_attr('sensor.<OneNameFromConfigYaml_tasks>', 'tasks')['tasks'] %}
Folgende Aufgaben sind dir aktuell zugewiesen:
{{ aufgaben | replace('[','') | replace (']','') | replace ("'","") }}
data:
actions:
- action: URI
title: Aufgaben ansehen
uri: /lovelace-temp/6
mode: single
- Circle marks selected task as completed.
- Click on Text marks selected task as completed..
- Trash bin deletes selected task.
- Pencil Edit selected task
- Pin Pins the item on top of the card.
- Input adds new item to the list after pressing button
Save
.