Skip to content

Local Todo card for Home Assistant Lovelace UI.

Notifications You must be signed in to change notification settings

Dielee/localToDo-card

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Local ToDo Card

Thanks to @grinstantin for the base js card.

Local ToDo card for Home Assistant Lovelace UI. This card displays items from local SQLite database.

Preview of todoist-card

Installing

JS Card

  1. Download localtodo-card.js file from the latest release.
  2. Put localtodo-card.js file into your config/www folder.
  3. Add a reference to localtodo-card.js in Lovelace. There are two ways to do that:
    1. Using UI: ConfigurationLovelace DashboardsResources → Click Plus button → Set Url as /local/localtodo-card.js → Set Resource type as JavaScript Module.
    2. Using YAML: Add the following code to lovelace section.
      resources:
        - url: /local/localtodo-card.js
          type: module
  4. Add custom:localtodo-card to Lovelace UI as any other card (using either editor or YAML configuration).

Setup DB Server

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

  1. Change settings in config.yaml to your needs
  2. Install flask pip3 install flask, PyYAML
  3. Run main.py from /src python3 __init__.py

Using the card

This card can be configured using Lovelace UI editor.

  1. 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'
  2. Reload configs or restart Home Assistant.

  3. In Lovelace UI, click 3 dots in top left corner.

  4. Click Edit Dashboard.

  5. Click Add Card button in the bottom right corner to add a new card.

  6. Find Custom: Todoist Card in the list.

  7. Choose entity.

  8. 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.

Adding tasks via HomeAssistant Automation/Script

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

Notify people about new tasks

 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

Actions

  • 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.

About

Local Todo card for Home Assistant Lovelace UI.

Resources

Stars

Watchers

Forks

Languages

  • JavaScript 78.8%
  • Python 19.9%
  • Dockerfile 1.3%