Closed seb5594 closed 1 year ago
Thanks for your feature request and your interest in the integration. I will have a look into it.
I would second his request. If there is a way to create a lovelace template, so we don't have to do it on our own every single time, that would be great!
This is how my markdown card looks like:
# **Süßes und Salziges**
| | | |
| :------------: |:------------- | -----:|
{%- set product_list_loop = state_attr('sensor.rewe_440421', 'discounts') -%}
{%- for product in product_list_loop -%} {% if 'Süßes & Salziges' in product.category and product.product != '' %}
| <img src="{{product.picture_link[0] }}" width="50" height="50"/> | {{product.product }}
| ![badge](https://badgen.net/badge/{{ product.price.price }}€/{{ product.price.regularPrice }}/red)
| {%- endif -%}
{%- endfor -%}
Downside:
Done with #5
Hi there, since my market has 389 offers, I had to reduce that number to something I could handle. Therefore, I came up with this mushroom template card. Since it's text-only, it loads pretty fast. Hope it helps:
type: custom:mushroom-template-card
primary: Aktuelle Angebote im Rewe Prospekt
icon: ''
multiline_secondary: true
secondary: |+
{# This selects the sensor containing the Rewe market ID.
Note: Check the very last line of this card configuration.
The link shown there should refer to your respective market in order to make sense.
In case you're wondering: on double tap because it's more user-friendly. #}
{%- set product_list_loop = state_attr('sensor.rewe_4040274', 'discounts') -%}
{# This defines a list of things we don't want to see in our result list. #}
{%- set unwanted_products = (
'Homann',
'Kühlmann',
'Nadler',
) -%}
{# This defines the list of offers we want to see. #}
{%- set wanted_products = (
'Sekt','Crémant','Brut','Champagner'
'Äpfel','äpfel'
'Bacon',
'Beere','beere',
'Bio',
'Birne','birne',
'Butter',
'Emmis',
'Forelle',
'Gurke',
'Hummus','hummus',
'Joghurt',
'Lachs',
'Kartoffeln','kartoffeln',
'Lamm',
'Öl','öl',
'Parma',
'Rind',
'Salat','salat',
'Schnitzel'
'Skyr',
'Spargel',
'Traube','traube',
) -%}
{# Here, we define all variables we are going to use later on. #}
{%- set ns = namespace() -%}
{%- set ns.found_wanted=false -%}
{%- set ns.product_list={0:0} -%}
{%- set ns.product_list_current={0:0} -%}
{# Now, let the magic happen. For each of the products available as discount items do: #}
{%- for product in product_list_loop -%}
{%- if product.price %} {# This filters out entries without pricing details. #}
{%- set ns.found_wanted=false -%}
{# If the product is on our positive list, we set a marker to have it added. #}
{%- for wanted_product in wanted_products %}
{%- if product.product|contains(wanted_product) -%}
{%- set ns.found_wanted=true %}
{%- endif -%}
{%- endfor -%}
{# Except when it also contains a string from things we don't want to see.
Then we have to remove that marker.
(e.g.: we want to see Salat but not Homanns Fleischsalat as it is gross.) #}
{%- for unwanted_product in unwanted_products %}
{%- if product.product|contains(unwanted_product) -%}
{%- set ns.found_wanted=false %}
{%- endif -%}
{%- endfor -%}
{# This is when we finally figured out whether we want to have
the current product on our result list or not. #}
{%- if ns.found_wanted == true %}
{# This is to add the first item to the empty list. #}
{%- if ns.product_list_current == ns.product_list-%}
{%- set ns.product_list = {product.product: product.price.price} -%}
{%- else -%}
{# This is for everything else. Looks a bit weird as
Home Assistant does not seem to suppport the comfy way. #}
{%- set ns.product_list_current = {product.product: product.price.price} -%}
{%- set ns.product_list = dict(ns.product_list.items(), **ns.product_list_current) -%}
{%- endif -%}
{%- set ns.found_wanted=false -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{# Finally, we print out the whole thing in alphabetic order. #}
{% for key,value in ns.product_list|dictsort %}
{{ key }}: {{ value }} €
{%- endfor -%}
fill_container: true
tap_action:
action: none
hold_action:
action: more-info
double_tap_action:
action: url
url_path: >-
https://www.rewe.de/angebote/berlin-neukoelln/4040274/rewe-markt-rollbergstr-59/?market-flyer=active
For completion, here's a screenshot:
the cool card from @KrizzeOne doens't work anymore. We only get the current "price", not the old "regularPrice" . here is an updated card:
# **Obst und Gemüse**
| | | |
| :------------: |:------------- | -----:|
{%- set product_list_loop = state_attr('sensor.rewe_4040708', 'discounts') -%}
{%- for product in product_list_loop -%} {% if 'obst-und-gemuese' in product.category and product.product != '' %}
| <img src="{{product.picture_link[0] }}" width="50" height="50"/> | {{product.product }}
| ![badge](https://badgen.net/badge/{{ product.price | urlencode }}/€)
| {%- endif -%}
{%- endfor -%}
For updating the readme file, I opend a pull request: https://github.com/FaserF/ha-rewe/pull/25
The request
Nice HA integration here! Could you give out more examples like a markdown card where all "Knaller" sales will be listed or something similar? Would be a good addition
Is your feature request related to a problem?
No response
Additional information
No response