UI-Lovelace-Minimalist / UI

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

card_binary_sensor_alert does not show state #413

Open filikun opened 2 years ago

filikun commented 2 years ago

Describe the bug The main issue is that if you set show_last_changed: false the card does not show any state in the label field. Also The documentation is wrong as if you are on the card_binary_sensor_alert page page it shows you the config for card_binary_sensor and vice versa.

EDIT: It seems card_binary_sensor has the same problem.

Tested config

    - type: 'custom:button-card'
      template: card_binary_sensor_alert
      name: Yterdörr
      variables:
        - ulm_card_binary_sensor_alert: true
      entity: binary_sensor.door_outdoor_magnet_contact
      show_last_changed: false

How it looks image

Expected look image

ScottEgan commented 2 years ago

I also ran into this issue and had a quick look today.

I think I have found the problem, both the card_binary_sensor and card_binary_sensor_alert are missing their label: definitions.

I modified the card_binary_sensor template located here: /config/custom_components/ui_lovelace_minimalist/__ui_minimalist__/ulm_templates/card_templates/cards/card_binary_sensor.yaml

To the following:

---
### Card Binary Sensor ###
card_binary_sensor:
  template:
    - "icon_info_bg"
    - "ulm_language_variables"
    - "blue"
  name: "[[[ return entity.attributes.friendly_name != '' ? entity.attributes.friendly_name : entity.entity_id ]]]"
  show_last_changed: true
  label: >
    [[[
      var unit = entity.attributes.unit_of_measurement != null ? " " + entity.attributes.unit_of_measurement : ""
      if (entity.state == "on") {
        return variables.ulm_on;
      } else if (entity.state == "off") {
        return variables.ulm_off;
      } else if (entity.state == "unavailable") {
        return variables.ulm_unavailable;
      } else if (entity.state == "idle") {
        return variables.ulm_idle;
      } else if (entity.state == "open") {
        return variables.ulm_open;
      } else if (entity.state == "closed") {
        return variables.ulm_closed;
      } else {
        return entity.state + unit;
      }
    ]]]

With those changes the state now shows up correctly: image