Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 107680

To Do List help when no due date

$
0
0

I’ve got a to do list, that I use to notify me of upcoming chores. I’ve used a few examples from elsewhere on this forum to make it work, but there’s something I can’t work out - when a task doesn’t have a due date, none of the sensors work.

Here is my config:

template:
  - trigger:
      - trigger: time_pattern
        minutes: /1
      - platform: state
        entity_id: todo.chores
    action:
      - service: todo.get_items
        data:
          status: needs_action
        target:
          entity_id: todo.chores
        response_variable: todo_list
    sensor:
      - name: "To Do List - Today"
        unique_id: todo_list_today
        state: >
            {%- set today = now().strftime('%Y-%m-%d')-%}
            {%- set ns =  namespace(result = []) -%}
            
            {% set tasks_list = todo_list['todo.chores']['items'] %}
            {%- for task in tasks_list -%}
            {%- if task['due'].split('T')[0] == today -%}
            {%- set ns.result = ns.result + [task['summary']] -%}
            {%- endif -%}
            {%- endfor -%}            
            {{ ns.result | count }}  
        attributes:
          items: >
            {%- set today = now().strftime('%Y-%m-%d')-%}
            {%- set ns =  namespace(result = []) -%}
            
            {% set tasks_list = todo_list['todo.chores']['items'] %}
            {%- for task in tasks_list -%}
            {%- if task['due'].split('T')[0] == today -%}
            {%- set ns.result = ns.result + [task['summary']] -%}
            {%- endif -%}
            {%- endfor -%}            
            
            {%- if ns.result is iterable -%}
            {%- for item in ns.result %}  
            - {{ item }}
            
            {%- endfor -%}
            {%- endif -%}

This works fine as long as all tasks have a due date. When one doesn’t, it comes back as unavailable.

My questions are:

  • How can I make the above work when there is not due date?
  • Can I create a new sensor that only brings back the items where there is no due date?

Thanks in advance!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 107680

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>