PowerTodoist-card: Lists, Kanbans, and much more [beta release]

That’s exactly the problem, how do I get it to see both sensors?

I did a copy/paste of the first sensor once I got it working so that I knew for sure I was using working code.

The only things I changed in the second bit of code are the sensor name project ID.

The only one I can get to show up is the second instance of code. Doesn’t matter which project that is, I’ve had both in that position.

Here’s the code I’m working with. It only shows the todo_chores project

sensor:
  - name: todo_bills
    platform: rest
    method: GET
    resource: 'https://api.todoist.com/sync/v9/projects/get_data'
    params:
      project_id: ID1 but the correct one

    headers:
      Authorization: !secret todoist_api_token
    value_template: '{{ value_json[''project''][''id''] }}'
    json_attributes:
      - project
      - items
      - sections
      - project_notes
    scan_interval: 30
command_line:
  - sensor:
      name: label_colors
      command: !secret todoist_cmd_with_api_token
      value_template: >
        {{ value_json.label_colors | length }}

      json_attributes:
        - label_colors
      scan_interval: 200
rest_command:
  todoist:
    method: post
    url: 'https://api.todoist.com/sync/v9/{{ url }}'
    payload: '{{ payload }}'
    headers:
      Authorization: !secret todoist_api_token
    content_type: 'application/x-www-form-urlencoded'

sensor:
  - name: todo_chores
    params:
     project_id: ID 2 but the correct one
    platform: rest
    method: GET
    resource: 'https://api.todoist.com/sync/v9/projects/get_data'

    headers:
      Authorization: !secret todoist_api_token
    value_template: '{{ value_json[''project''][''id''] }}'
    json_attributes:
      - project
      - items
      - sections
      - project_notes
    scan_interval: 30
command_line:
  - sensor:
      name: label_colors
      command: !secret todoist_cmd_with_api_token
      value_template: >
        {{ value_json.label_colors | length }}

      json_attributes:
        - label_colors
      scan_interval: 200
rest_command:
  todoist:
    method: post
    url: 'https://api.todoist.com/sync/v9/{{ url }}'
    payload: '{{ payload }}'
    headers:
      Authorization: !secret todoist_api_token
    content_type: 'application/x-www-form-urlencoded'

I’m not sure, but I think you need to group together the main sections, otherwise the second one overwrites the first (instead of adding items as you intend).

So, one rest_command section with two items, then one sensor section with two items, then one command_line section with two items


Hey, can you help me figure out why I have a calendar icon instead of showing the hours? Even GPT is broken…

:thinking:

Hhhmmm could that be white text on top of white background? Try selecting text with your mouse, to the right of the calendar icon.

This is just to diagnose, then I’ll have to think of ways to fix…

I am trying to set this up for my Kids to use. So I have 3 sections, Morning, After School, and Evening. I’ve created a label to filter by for each time of day. I also want a 4th one as a catch-all for tasks missing either a due date or a label. I can’t get it to filter properly. Here is my code

type: custom:powertodoist-card
entity: sensor.kids_chore_list
filter_section: Kid1
filter_labels:
  - "!*"
filter_show_dates_empty: true
sort_by_due_date: ascending
show_header: true
show_card_labels: true
show_dates: true
use_quick_add: false
show_completed: 0
show_item_add: false
show_item_delete: false
friendly_name: Parked - Needs a Date or Label

The idea is, this would act like the Inbox in Todoist, so items without a date or not labeled would be added to this parked section. I can’t get the unlabeled/dated to populate at all.

@socafroal that’s a bug… in the Documentation.

I never implemented that as a filter, only as an action (to clear all labels). But when I edited the README I mistakenly wrote it in the filters section… sorry.

You can probably work around it with some other label scheme. How are you creating the items, is it from this card, or from Todoist app, or …?

I use Todoist directly. This will eventually make it’s way to a Nest hub for the kids to check off their daily list. I’ve been fighting with Labels and dates for the last couple of days. Right now, I have 2 tasks that have a due date of today, but no labels. I want these to show up in a new section but it’s not displaying. I see them in the entity

type: custom:powertodoist-card
entity: sensor.kids_chore_list
filter_section: Kid1
filter_labels:
  - "!*"
filter_show_dates_starting: "1"
filter_show_dates_ending: "1"
sort_by_due_date: ascending
show_header: true
show_card_labels: true
show_dates: true
show_completed: 5
show_item_add: false
show_item_delete: false
friendly_name: Due Some Time Today

So is the !* filter not supposed to filter for items without labels? I’m not sure I understand what you’re saying. Basically, I can’t get any exclusion filters for Labels to work.

If you’re feeling adventurous, go in the folder config/www/community/powertodoist-card

and open powertodoist-card.js

Find this block of code:

        // filter by label:
        var includes, excludes;
        var cardLabels=[];
        var hiddenLabels=[];
        var itemLabels=[];
        if (this.myConfig.filter_labels) {
            items = items.filter(item => {
                includes = excludes = 0;
                //this.config.labels.forEach(label => {
                this.myConfig.filter_labels.forEach(label => {
                    let l = label; //replaceMultiple(label, { "%user%" : this.hass.user.name });
                    if (l.startsWith("!")) {
                        excludes += item.labels.includes(l.slice(1));
                    } else {
                        includes += item.labels.includes(l) || (l === "*");
                        if (!cardLabels.includes(l)) cardLabels.push(l);
                    }
                });
                return (excludes == 0) && (includes > 0);
            });
        }

Replace it with this:

        // filter by label:
        var includes, excludes;
        var cardLabels=[];
        if (this.myConfig.filter_labels) {
            items = items.filter(item => {
                includes = excludes = 0;
                this.myConfig.filter_labels.forEach(label => {
                    let l = label; 
                    if (l.startsWith("!")) {
                        excludes += item.labels.includes(l.slice(1));
                    } else {
                        includes += item.labels.includes(l) || (l === "*");
                        includes += (l === "!*") && (item.labels.length === 0);
                        if (!cardLabels.includes(l)) cardLabels.push(l);
                    }
                });
                return (excludes == 0) && (includes > 0);
            });
        }
  • save that file
  • delete powertodoist-card.js.gz
  • hard-refresh your browser to reload the new js. This is sometimes difficult to achieve and makes testing harder…
  • test!

Thanks for your help, I currently can’t test myself

Hi - I just started using this a few days ago. We are using this to track daily chores for my kids on a tablet mounted on the wall. It basically works for our purposes, but my kids complain that when they tick an item it sits there for a bit before it disappears, and I have witnessed them trying to quickly tick multiple items, which leads to unpredictable results when suddenly one of the ticked items disappears after a couple seconds (meaning they have now just ticked the wrong thing since the entire list moved up by one or two items).

Is this lag between ticking an item and clearing the item from the dashboard a known issue? Any tips for increasing performance?

Thanks!

Hi. Yes I am well aware of the lag. It’s the downside of working with remote data (Todoist).

To improve that you basically need good internet performance all the way to Todoist’s server. Some of these elements might be under your control - check your tablet has proper wi-fi coverage, your house Internet is not laggy, etc.

But if nothing helps, I can tell you that I am about to release (in 2 or 3 weeks) a newer version to move to a new Todoist API, so it is a breaking change, involves some tweaks to the config files.

This new version should have a better experience regarding those lags, although still not perfect. But with good internet you should be able to see everything updated in 1 or 2 seconds.

1 Like

hey - thanks for the reply. just a thought, and I don’t know how much of a pain this would be to implement in HASS, but making all the operations local and then backgrounding the API call may be better solution here rather than waiting to receive the response back from todoist before updating the list. this would allow you to immediately update the status / hide the task that was just ticked without waiting to get a response back from todoist.

queueing of all api calls until x seconds after the last interaction with the list would also help ensure that the list doesn’t jump around due to an update coming back from todoist while someone was in the middle of ticking other things off.

again, I have never done any coding for HASS, so maybe this is not possible for reasons that I am not aware of, but generally speaking, working locally and backgrounding async tasks and api calls would make things feel snappy and hide latency from users.

The API call is backgrounded, it doesn’t freeze the UI. The problem is that the card reflects a HASS sensor, which in turn is fed by the API. So when you change something, the change goes off to Todoist, then the sensor period passes (typically 20 seconds although you can set it tighter), it calls to get the new API data, then refreshes the UI.

The card has several tricks to obviate this, such as (in some cases) making the specific change to the UI directly while waiting for the whole thing to refresh.

But it’s just not a good architecture. I was learning Javascript as I went along, and I am definitely guilty of feature creep. The code is convoluted and, as a developer, I assure you I would never pass what I wrote if I was doing a code review of it :slight_smile:

But hey, it mostly works and does a lot of cool things, so…

The updated version (for the newer Todoist API) I spoke about is the one where I changed things around more deeply. It also brings quite a few new nice features. It definitely feels faster and then we can improve on it.

thanks for the explanation! i’ll keep an eye out for the new release!

I have installed this card today, but cannot get the Rest sensor to work. It is created, but not available. Is this something to to do with the above mentioned changes to the version? The following data has been added to the configuration file:

sensor:
  - name: Electrical Tasks
    platform: rest
    method: GET
    resource: "https://api.todoist.com/sync/v9/projects/get_data"
    params:
      project_id: electrical-blah-blah
    headers:
      Authorization: !secret todoist_api_token
    value_template: "{{ value_json['project']['id'] }}"
    json_attributes:
      - project
      - items
      - sections
      - project_notes
    scan_interval: 30

command_line:
  - sensor:
      name: label_colors
      command: !secret todoist_cmd_with_api_token
      value_template: >
        {{ value_json.label_colors | length }}
      json_attributes:
        - label_colors
      scan_interval: 200

rest_command:
  todoist:
    method: post
    url: "https://api.todoist.com/sync/v9/{{ url }}"
    payload: "{{ payload }}"
    headers:
      Authorization: !secret todoist_api_token
    content_type: "application/x-www-form-urlencoded"

image

Did you fill in your todoist secret in the secrets file?

Is it possible to sort by Priority? If so, how?

I have it working now - I was including the project name in the project id.

1 Like

The problem here is white text on a white background, as you suggested. If I change the theme of the page, I can see the dates - not just the calendar icon.
Is there a way of changing the font color?