FaserF / ha-rewe

Rewe Discounts Homeassistant Integration
GNU General Public License v3.0
15 stars 4 forks source link

Sensor gives "dirty" URLs for images #3

Closed bluenazgul closed 1 year ago

bluenazgul commented 1 year ago

The problem

"product.picture_link" gives: ['https://img.rewe-static.de/REWE_TZ46_2022/7828148/35984627-3_digital-image.png']

But it should be something like: https://img.rewe-static.de/REWE46_2022/7828148/35088954-8_digital-image.png

I tried your example inside an Markdown Card. Sadly it Looks Like this: Screenshot_20221117-120849

But it should Look Like this: Screenshot_20221117-120924

To make this Work, you could have to remove the [' at the begin and the '] at the end of the Part inside "product.picture_link" of the Sensor that your Integration creates.

This is the Code i use inside an Markdown Card:

Neues Angebot im Rewe Prospekt für
    {%- set product_list_loop =  state_attr('sensor.rewe_561152', 'discounts') -%}
    {%- for product in product_list_loop -%}
    {% if 'Spezi' in product.product or 'Hell' in product.product or 'Tradizionale' in product.product %}

    - {{product.product }}
    Preis: {{product.price.price }} €
    Bild: 
  <div style="text-align:center">
      <img src="{{ product.picture_link }}" alt="Produkt Bild"/>
  </div>
    {%- endif -%}
    {%- endfor -%}

What version of Home Assistant Core has the issue?

2022.11.3

What version of Rewe Integration has the issue?

2022.09.2

What type of installation are you running?

Home Assistant OS

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

bluenazgul commented 1 year ago

I think Something Happens within the for Loop, as the Sensor itself Shows the correct value. But i dont know how to get it fixed.

bluenazgul commented 1 year ago

{{ product.picture_link[0] }}

Fixed the issue