custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.83k stars 227 forks source link

helpers.relativeTime(date) doesn't work #852

Closed MelleD closed 3 weeks ago

MelleD commented 1 month ago

Checklist

Describe the bug Error on function helpers.relativeTime(date)

Version of the card Version: 4.1.2

To Reproduce This is the configuration I used:

     - type: custom:button-card
        template: card_title
        label: "test relative time"
        name: >
          [[[
            return helpers.relativeTime(states['sensor.sun_next_dawn'].state)
          ]]]

Screenshots

Bildschirmfoto 2024-05-29 um 15 38 01

Expected behavior No error ;)

Desktop (please complete the following information):

Mariusthvdb commented 3 weeks ago
    - type: custom:button-card
      entity: sun.sun
      show_state: true
      show_name: true
      state_display: |
        [[[ return helpers.relativeTime(states['sensor.sun_next_dawn'].state); ]]]

seems to be fine?

Scherm­afbeelding 2024-06-07 om 15 56 20

works for name too:

    - type: custom:button-card
      entity: sun.sun
      show_state: true
      show_name: true
      name: |
        [[[ return helpers.relativeTime(states['sensor.sun_next_dawn'].state); ]]]

      state_display: |
        [[[ return helpers.relativeTime(states['sensor.sun_next_dawn'].state); ]]]
Scherm­afbeelding 2024-06-07 om 17 01 02

maybe your template is creating an issue, just leave it out for testing purposes

MelleD commented 3 weeks ago

Ok works now no idea why. Thanks for help