Improved Shopping List

Hi all,

I recently published Shopping List Card — it hooks directly into the built-in todo integration, so there’s no external sensors (no 255-char limit) and no external templates required.

Here’s a drop-in example using auto-entities + my card (with images for categories and items):

type: custom:auto-entities
card_param: cards
filter:
  template: >
    {%- set ns = namespace(result = [], inner = [], categories = {
      "Dairy": ["Milk","Eggs","Yogurt","Butter","Cheese"],
      "Fruits": ["Apple","Bananas","Strawberries","Carrots","Grapes"]
    }) -%}
    {%- for cat, items in ns.categories.items() -%}
      {%- set ns.inner = [] -%}
      {%- for item in items -%}
        {%- set ns.inner = ns.inner + [{
          "type": "custom:shopping-list-card",
          "title": item,
          "layout": "vertical",
          "enable_quantity": true,
          "todo_list": "todo.shopping_list",
          "image": "/local/images/" ~ (item | lower | replace(' ', '_')) ~ ".png"
        }] -%}
      {%- endfor -%}
      {%- set ns.result = ns.result + [{
        "type": "custom:button-card",
        "name": cat,
        "show_entity_picture": true,
        "show_name": true,
        "entity_picture": "/local/images/" ~ (cat | lower | replace(' ', '_')) ~ ".png",
        "tap_action":
          action: call-service
          service: browser_mod.popup
          service_data:
            title: "{{ cat }}"
            card:
              type: custom:layout-card
              layout_type: grid
              layout:
                grid-template-columns: 25% 25% 25% 25%
              cards: ns.inner
            deviceID:
              - this
      }] -%}
    {%- endfor -%}
    {{ ns.result }}
card:
  type: custom:layout-card
  layout_type: grid
  layout:
    grid-template-columns: 33% 33% 33%

Enjoy! :rocket:

2 Likes