UI-Lovelace-Minimalist / UI

UI-Lovelace-Minimalist is a "theme" for HomeAssistant
https://ui-lovelace-minimalist.github.io/UI/
Other
1.62k stars 431 forks source link

card_binary_sensor and card_binary_sensor_alert not displayed after HA Core 2023-11 #1398

Closed wokkeltje13 closed 10 months ago

wokkeltje13 commented 10 months ago

After 1.3.7 most of the issues are resolved since the HA 2023-1 upgrade but I still have issues with the binary sensor cards

image

This is my yaml code

- type: grid
  columns: 2
  square: false
  cards:
    - type: 'custom:button-card'
      template: card_binary_sensor_alert
      variables:
        ulm_card_binary_sensor_alert: true
        ulm_show_last_changed: true
        ulm_card_binary_sensor_alert_name: Bureau Buiten 1
      entity: binary_sensor.bureau_buiten_motion_sensor
    - type: 'custom:button-card'
      template: card_binary_sensor_alert
      variables:
        ulm_card_binary_sensor_alert: true
        ulm_show_last_changed: true
        ulm_card_binary_sensor_alert_name: Bureau Buiten 2
      entity: binary_sensor.bureau_buiten_2_motion_sensor_bureau
wokkeltje13 commented 10 months ago

setting ulm_show_last_changed to false solved the issue

pbartek20 commented 10 months ago

For me as well both mentioned cards are not working afer the update from 1.3.6 to 1.3.7 of Minimalist. I'm still on core 10.5 so sorry that it not fits the full topic of this report.

But for me no error is visible only blank card. I tried as @wokkeltje13 suggested and changed ulm_show_last_changed to false but but still same. Looks like a problem on this cards in the new relase

code for one of my cards:

- type: horizontal-stack
    cards:
      - type: 'custom:button-card'
        template:
        - card_binary_sensor_alert
        variables:
          ulm_card_binary_sensor_alert_name: "Presence"
          ulm_card_binary_sensor_alert_icon: mdi:motion-sensor
          ulm_card_binary_sensor_alert: true
          ulm_show_last_changed: false
        entity: binary_sensor.presence_sensor_fp2_b4d2_presence_sensor_6
      - type: 'custom:button-card'
        template:
        - card_binary_sensor_alert
        variables:
          ulm_card_binary_sensor_alert_name: "Sofa"
          ulm_card_binary_sensor_alert_icon: mdi:sofa
          ulm_card_binary_sensor_alert: true
          ulm_show_last_changed: false
        entity: binary_sensor.presence_sensor_fp2_b4d2_presence_sensor_5

below screenshot how it look like:

issue_cards

giannoug commented 10 months ago

Same here after the core update: image

Getting a lot of these in browser console:

button-card.js:425 ButtonCardJSTemplateError: TypeError: Cannot read properties of undefined (reading 'ulm_show_last_changed') in 'if (typeof(entity) !== 'undefined' && entity !== undefined){
    let device_class = entity.attribu...'
    at ti.eval (eval at _evalTemplate (button-card.js:425:9303), <anonymous>:10:18)
    at ti._evalTemplate (button-card.js:425:9389)
    at ti._getTemplateOrValue (button-card.js:425:9976)
    at button-card.js:425:9869
    at Array.forEach (<anonymous>)
    at ti._getTemplateOrValue (button-card.js:425:9846)
    at ti._objectEvalTemplate (button-card.js:425:9685)
    at ti.render (button-card.js:425:6853)
    at ti.update (button-card.js:1:19873)
    at ti.performUpdate (button-card.js:1:16761)

and

Uncaught (in promise) TypeError: e.setConfig is not a function
    at ti.render (button-card.js:425:7051)
    at ti.update (button-card.js:1:19873)
    at ti.performUpdate (button-card.js:1:16761)
    at ti._enqueueUpdate (button-card.js:1:16413)
michaelsleen commented 10 months ago

Same issue as @wokkeltje13 after updating UI Lovelace Minimalist to Version 1.3.7.

tieskuh commented 10 months ago

I have the same issue after updating minimalist to 1.3.7.

image

image

  - type: 'custom:button-card'
            template: card_binary_sensor
            variables:
              ulm_show_last_changed: true
              ulm_card_binary_sensor_name: Bewegingsmelder
            entity: binary_sensor.bewegingsmelder_garage_input_0_input

Downgrading to 1.3.6 solves the issue.

billyjoebob999 commented 10 months ago

I was also having the same issue as @wokkeltje13. I did set ulm_show_last_changed to false and it did get the card working again but I noticed ulm_card_binary_sensor_name was no longer working. What ended up fixing both my issues was the following:

Change: ulm_show_last_changed to ulm_show_last_alert_changed ulm_card_binary_sensor_name to ulm_card_binary_sensor_alert_name

Looks like the documentation for the binary sensor card needs to be updated

https://ui-lovelace-minimalist.github.io/UI/usage/cards/card_binary_sensor/#description

pbartek20 commented 10 months ago

@billyjoebob999

ulm_card_binary_sensor_alert_name - this I had alredy in my config since few months. I triedulm_show_last_changed to ulm_show_last_alert_changed either with true or false but still no luck.

I'm still on 10.5 core not sure if this is relevant for me why it is not working. It stopped working for me after 1.3.7 update

wokkeltje13 commented 10 months ago

I was also having the same issue as @wokkeltje13. I did set ulm_show_last_changed to false and it did get the card working again but I noticed ulm_card_binary_sensor_name was no longer working. What ended up fixing both my issues was the following:

Change: ulm_show_last_changed to ulm_show_last_alert_changed ulm_card_binary_sensor_name to ulm_card_binary_sensor_alert_name

Looks like the documentation for the binary sensor card needs to be updated

https://ui-lovelace-minimalist.github.io/UI/usage/cards/card_binary_sensor/#description

Can't find any traces of ulm_show_last_alert_changed in the card. Have same result even if I change the variable to something random. My issue only appears with ulm_show_last_changed: true, ulm_card_binary_sensor_alert_name is an old change that was already fixed before my issues appear (2023-11 and 1.3.7)

billyjoebob999 commented 10 months ago

Sorry for not being clear. Didn't mean to imply that ulm_card_binary_sensor_alert_name was part of the fix. Not sure why the custom name stopped working after I commented out ulm_show_last_changed: true and not before since it sounds like this changed a while back.

Updating the card with ulm_show_last_alert_changed: true is what got everything working for me.

Here is the code i'm using incase it helps.

  - type: 'custom:button-card'
    template: card_binary_sensor_alert
    variables:
      ulm_card_binary_sensor_alert_name: Front door
      ulm_card_binary_sensor_alert: true
      ulm_show_last_alert_changed: true
    entity: binary_sensor.front_door

image

While writing this I realized I'm using the binary_sensor_alert card and was referencing the binary_sensor card. Apologies there.

basbruss commented 10 months ago

But it's not working as it is supposed, to cause ulm_show_last_alert_changed does not exist in the source code. So it shows the normal state

basbruss commented 10 months ago

I found the source of the problem https://github.com/UI-Lovelace-Minimalist/UI/blob/3438d15b4d4cb6d6b5778a619a5015a8abed9638/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_binary_sensor_alert.yaml#L80-L94, but do not have a solution ready without adding breaking changes for now

pbartek20 commented 10 months ago

After I updated to core 11.0 it started working same as @wokkeltje13 mentioned when ulm_show_last_changed is set to false. When set to true card does not work. On 10.5 was not working for both true and false. Also reloading the UI Minimalist & all yaml config from HA not helped. Only after full HA system reboot and setting state to false card is working.

wokkeltje13 commented 10 months ago

I found the source of the problem

https://github.com/UI-Lovelace-Minimalist/UI/blob/3438d15b4d4cb6d6b5778a619a5015a8abed9638/custom_components/ui_lovelace_minimalist/lovelace/ulm_templates/card_templates/cards/card_binary_sensor_alert.yaml#L80-L94

, but do not have a solution ready without adding breaking changes for now

What will be the breaking change? Currently it is already broken.

brendanlees commented 10 months ago

Can also confirm same issues noted by @wokkeltje13 after updating to 1.3.7 & core 11.0 - cards on ulm_show_last_changed: true are now blank or intermittenly show the same errors shown by @tieskuh unless rolling back versions.

wokkeltje13 commented 10 months ago

Any idea how and when this issue can be solved without a rollback? Things we can do to test?

spammads commented 10 months ago

Same here. Would appreciate a fix.

johnmoxon commented 10 months ago

Same issue, have applied, workaround as below, but now missing any value for last_changed, so will look forward to the fix 👍

ulm_show_last_alert_changed: true
ulm_show_last_changed: false
ulm_card_binary_sensor_alert: true
basbruss commented 10 months ago

Should be fixed with release https://github.com/UI-Lovelace-Minimalist/UI/releases/tag/v1.3.8

Note the breaking change to the card configs to apply the fix 😉

spammads commented 10 months ago

Applied the fix. Lgtm. Thanks!

wokkeltje13 commented 10 months ago

Tnx, fixed the issue

AneeshBhatnagar commented 9 months ago

Thanks for this fix! I just hit this issue after the upgrade, but glad I could find the fix here

DoctorMod commented 9 months ago

This issue also seems to affect generic cards when you have an entity with a device class of timestamp as well, e.g. the in-built uptime sensor. I've done some debugging and it looks like it's an issue with the translation code with the helpers.relativeTime function.