Python backend for https://github.com/Dielee/localToDo-card
303
Thanks to @grinstantin for the base js card.
Local ToDo card for Home Assistant Lovelace UI. This card displays items from local SQLite database.

localtodo-card.js file from the latest release.localtodo-card.js file into your config/www folder.localtodo-card.js in Lovelace. There's two way to do that:
/local/localtodo-card.js → Set Resource type as JavaScript Module.lovelace section.
resources:
- url: /local/localtodo-card.js
type: module
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
pip3 install flask, PyYAMLpython3 __init__.pyThis 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
Save.Content type
Image
Digest
Size
342.3 MB
Last updated
over 5 years ago
docker pull dielee/local-todo-card