lovelace-card-templater icon indicating copy to clipboard operation
lovelace-card-templater copied to clipboard

Issue - only red box - picture-entity

Open Diamant80 opened this issue 4 years ago • 15 comments

Hi,

I've a picture-entity card and want to change the picture based on its state. This seems to work but if I reload the page, the card only shows a red box. If I change into Lovelace Editview the box becomes visible again (until next refresh) I tested a little bit and I noticed, if I add an additional "normal" picture entity cardto the site, the "custom-picture entity" card becomes visible (also after refresh).

Screenshot after reload: image

Screenshot edit mode image

Here is my code:

type: 'custom:card-templater'
card:
  type: picture-entity
  entity: sensor.tonnen
  name_template: '{{ states.sensor.tonnen.attributes.days }} days'
  show_name: true
  show_state: false
  state_image:
    '0': /hacsfiles/picture/tonnen.png
    '1': /hacsfiles/picture/tonnen.png
    '2': /hacsfiles/picture/tonnen_grau.png
entities:
  - sensor.tonnen

Diamant80 avatar Mar 23 '20 09:03 Diamant80

What is the state of the sensor.tonnen sensor normally (i.e. what does it display like in an entities card)?

gadgetchnnel avatar Mar 23 '20 09:03 gadgetchnnel

In my example the state is 0. State for sensor.tonnen could be 0 / 1 / 2 (will changed automatically based on date calculation)

Diamant80 avatar Mar 23 '20 09:03 Diamant80

Are there any errors in either home-assistant.log or the browser console when this happens?

gadgetchnnel avatar Mar 23 '20 09:03 gadgetchnnel

Consolse shows only: CARD-TEMPLATER Version 0.0.8

Unfortunately nothing in the log

Screenshot if default picture entity card is added to the view, everything works image

Diamant80 avatar Mar 23 '20 09:03 Diamant80

I don't see a reference to 'custom:card-templater' in your config, the config should be something like:

type: 'custom:card-templater'
card:
  type: picture-entity
  entity: sensor.tonnen
  name_template: '{{ states.sensor.tonnen.attributes.days }} days'
  show_name: true
  show_state: false
  state_image:
    '0': /hacsfiles/picture/tonnen.png
    '1': /hacsfiles/picture/tonnen.png
    '2': /hacsfiles/picture/tonnen_grau.png
entities:
  - sensor.tonnen

Is that what your config looks like?

gadgetchnnel avatar Mar 24 '20 08:03 gadgetchnnel

Yes the config looks exactly same. I also edited my first post, there was a issue with the "insert code" function and the first line "type: 'custom:card-templater'" was not displayed

Diamant80 avatar Mar 24 '20 09:03 Diamant80

I tested a little bit:

Custom card on View 1 --> Custom card don't work Add a defafult picture-entity card to view 1 --> Custom card works

Custom Card on View 1 & Default Card on View 2 --> Custom card don't work Change to View2 & Change to View 1 again --> Custom card works

I'm not a developer but it seems a dependency is missing. Hope this helps

Diamant80 avatar Mar 24 '20 09:03 Diamant80

Hi I have same issue, red boxes, but give it some time and a refresh, then it works. Btw great work on templater...

Screenshot_20200506-104849_Home Assistant Screenshot_20200506-104830_Home Assistant

klint76 avatar May 06 '20 02:05 klint76

Same issue here with my Garbage card;

https://tweakers.net/i/3KcXMzIYSDEaoDUO_vDkeDlFMBg=/full-fit-in/4920x3264/filters:max_bytes(3145728):no_upscale():strip_icc():fill(white):strip_exif()/f/image/OTbE7uSFwpVDGG03DXCuzD3c.jpg?f=user_large

After a refresh it often works; https://tweakers.net/i/PVf80Q1uOCOTNjsQquFNbiBs08w=/full-fit-in/4920x3264/filters:max_bytes(3145728):no_upscale():strip_icc():fill(white):strip_exif()/f/image/rLchPd6jgyQj13haP2imWRkD.jpg?f=user_large

Card code:

card:
  cards:
    - card:
        entity: sensor.papier_2
        name_template: |-
          {%- if is_state("sensor.papier_2", "0")%}
            Vandaag
          {% elif is_state("sensor.papier_2", "1")%}
            Morgen
          {% else %} 
          {{states.sensor.papier_2.attributes.days }}
            dagen
          {%- endif %}
        show_name: true
        show_state: false
        state_image:
          '0': /local/images/trash_card/papier.png
          '1': /local/images/trash_card/papier.png
          '2': /local/images/trash_card/papier_bw.png
        type: picture-entity
      entities:
        - sensor.papier_2
      type: 'custom:card-templater'
    - card:
        entity: sensor.gft_rest
        name_template: |-
          {%- if is_state("sensor.gft_rest", "0")%}
            Vandaag
          {% elif is_state("sensor.gft_rest", "1")%}
            Morgen
          {% else %}
          {{states.sensor.gft_rest.attributes.days }}
            dagen 
          {%- endif %}
        show_name: true
        show_state: false
        state_image:
          '0': /local/images/trash_card/gft_rest.png
          '1': /local/images/trash_card/gft_rest.png
          '2': /local/images/trash_card/gft_rest_bw.png
        type: picture-entity
      entities:
        - sensor.gft_rest
      type: 'custom:card-templater'
    - card:
        entity: sensor.pmd
        name_template: |-
          {%- if is_state("sensor.pmd", "0")%}
            Vandaag
          {% elif is_state("sensor.pmd", "1")%}
            Morgen
          {% else %}
          {{states.sensor.pmd.attributes.days }}
            dagen 
          {%- endif %}
        show_name: true
        show_state: false
        state_image:
          '0': /local/images/trash_card/pmd.png
          '1': /local/images/trash_card/pmd.png
          '2': /local/images/trash_card/pmd_bw.png
        type: picture-entity
      entities:
        - sensor.pmd
      type: 'custom:card-templater'
  type: horizontal-stack
type: 'custom:mod-card'

Meelobee avatar Jun 23 '20 09:06 Meelobee

I have the exact same issue with a gauge card.

JonasPed1 avatar Jul 20 '20 08:07 JonasPed1

@Diamant80 @klint76 @Meelobee @JonasPed Can you please make sure you are updated to the latest version of the card, 0.0.12, and see if it works now? I discovered that I was using an older version of a library, which would cause issues, and 0.0.12 uses the latest version of the library which should fix it.

gadgetchnnel avatar Jul 21 '20 06:07 gadgetchnnel

It seems to have fixed the issue, but now the days aren't updating for my garbage days.

On Tue, 21 Jul 2020, 2:44 pm Steven Rollason, [email protected] wrote:

@Diamant80 https://github.com/Diamant80 @klint76 https://github.com/klint76 @Meelobee https://github.com/Meelobee @JonasPed https://github.com/JonasPed Can you please make sure you are updated to the latest version of the card, 0.0.12, and see if it works now? I discovered that I was using an older version of a library, which would cause issues, and 0.0.12 uses the latest version of the library which should fix it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gadgetchnnel/lovelace-card-templater/issues/16#issuecomment-661667867, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKT75N47FZLUIYDLCMYHPSLR4U2NRANCNFSM4LRW2TBA .

klint76 avatar Jul 21 '20 13:07 klint76

Sorry, just took time to update. All good so far. Will keep you updated. Great work thanks

Klint

On Tue, 21 Jul 2020, 2:44 pm Steven Rollason, [email protected] wrote:

@Diamant80 https://github.com/Diamant80 @klint76 https://github.com/klint76 @Meelobee https://github.com/Meelobee @JonasPed https://github.com/JonasPed Can you please make sure you are updated to the latest version of the card, 0.0.12, and see if it works now? I discovered that I was using an older version of a library, which would cause issues, and 0.0.12 uses the latest version of the library which should fix it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gadgetchnnel/lovelace-card-templater/issues/16#issuecomment-661667867, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKT75N47FZLUIYDLCMYHPSLR4U2NRANCNFSM4LRW2TBA .

klint76 avatar Jul 21 '20 13:07 klint76

It seems to have fixed the issue, but now the days aren't updating for my garbage days. On Tue, 21 Jul 2020, 2:44 pm Steven Rollason, @.***> wrote: @Diamant80 https://github.com/Diamant80 @klint76 https://github.com/klint76 @Meelobee https://github.com/Meelobee @JonasPed https://github.com/JonasPed Can you please make sure you are updated to the latest version of the card, 0.0.12, and see if it works now? I discovered that I was using an older version of a library, which would cause issues, and 0.0.12 uses the latest version of the library which should fix it. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#16 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKT75N47FZLUIYDLCMYHPSLR4U2NRANCNFSM4LRW2TBA .

having the same issue described. v0.0.13 used

ionuttimofte53 avatar Jan 19 '21 10:01 ionuttimofte53

In my environment everything is working totally fine 👍

Diamant80 avatar Jan 19 '21 16:01 Diamant80