ScottG489 / ha-trello

Trello integration for Home Assistant
MIT License
7 stars 0 forks source link

Possibility to retrieve number of cards that belong to a list that are past their DUE date or that are for today. Plus...I can only see 5 lists #1

Open TeDeVPrime opened 8 months ago

TeDeVPrime commented 8 months ago

Checklist

Is your feature request related to a problem? Please describe.

well the only "problem" is that it shows only 5 columns

Describe the solution you'd like

Hi, first of all THANK YOU for trying to implement Trello to HASS.

i can see how many cards are in my lists (the issue is that i can only see 5 lists....).

what i really need is to have a sensor that checks how many cards in this list are not completed or DONE yet AND they are passed their DUE date and another sensor for how many of these cards for DUE today.

my lists are not like "Todo" - "Done" - "In Progress".

each list is about a different category of tasks that need to be done.

Describe alternatives you've considered

there are no alternatives to consider.

Additional context

nope.

ScottG489 commented 8 months ago

Hey @TeDeVPrime! Thanks for opening this issue!

I think I follow your workflow and it makes sense.

Trying to think of the best way about this... Creating a sensor based on some diverse criteria could be complicated and would require some thought. However, I think I could give you the tools needed to get what you're after much more quickly. Would also give you more flexibility and control going forward to get at the data you're interested in.

I've already started an implementation for adding service calls. One of the services makes use of the new service response feature and returns information for cards.

There are then a few routes you could take to get this into a sensor. The best would probably be making use of another new HA feature as well - trigger actions.

You'd call the service from the trigger action and parse the response for your sensor. Here's a starter example of what it might look like once I have the service call implemented:

(Non-working pseudo-example at time of writing)

template:
  - trigger:
      - platform: time_pattern
        minutes: "/5"
    action:
      - service: trello.get_cards
        target:
          entity_id: sensor.my_list
        response_variable: cards
    sensor:
      - name: My list done cards
        state: "{{ <template logic goes here> }}"

Let me know if this makes sense and your thoughts on how this implementation might work for you :)

ScottG489 commented 8 months ago

So just a quick update, I've prototyped this out and set up a working trello.get_cards service that will respond with all the cards for a given list with (from what I can tell) every field on a card, including the ones you'd be interested in: due and dueComplete.

Going to try to write up a template sensor like the example one I posted above to make sure this will support your use case end to end.

ScottG489 commented 8 months ago

Here's an actual working example that partially implements your use case. This sensor will display the count of cards in a list that are not marked as done:

template:
  - trigger:
      - platform: time_pattern
        minutes: "/5"
    action:
      - service: trello.get_cards
        data:
          account: abc123
          list_entity_id: sensor.my_list
        response_variable: list_cards
    sensor:
      - name: My list not done cards
        state: |
          {{
            list_cards.cards
            |selectattr("dueComplete", "==", false)
            |list|count
          }}

We'd need to expand the template a bit to also check to see if we are past the due date, but that should be fairly straightforward by parsing the due field.

Otherwise, I'm pretty confident as this point that this implementation would support your entire use case. Let me know what you think, excited to hear your thoughts!