thomasloven / lovelace-template-entity-row

🔹 Display whatever you want in an entities card row.
MIT License
210 stars 16 forks source link

State not getting updated as expected #86

Closed kaizersoje closed 4 months ago

kaizersoje commented 1 year ago

I have created a row that displays how long a sensor value has changed. However, I have noticed that the value is not getting updated as expected.

type: entities
entities:
  - type: custom:template-entity-row
    icon: mdi:bed-king
    name: Bedroom
    state: |-
      {{   relative_time(states.sensor.temperature_lumi_158d000418a254.last_changed)  ~ " ago" }}
  - entity: sensor.temperature_lumi_158d000418a254
    secondary_info: last-changed

image

It shows 33 minutes in the more-info dialog for the entity.

The value in the template row gets updated only when I refresh the screen.

ildar170975 commented 1 year ago

This is about the whole expression with relative_time.

Try to reproduce my test:

  1. Add this card:
    type: entities
    entities:
    - type: custom:template-entity-row
    icon: mdi:bed-king
    name: Bedroom
    state: '{{relative_time(states.input_number.test_number.last_changed)}}'
    - entity: input_number.test_number
    secondary_info: last-changed
  2. Place the browser's window on the left part of your monitor.
  3. Open 2nd browser's window, place it on the right side of the monitor.
  4. Open Dev Tools -> Template., add this template: {{relative_time(states.input_number.test_number.last_changed)}}
  5. Change the helper's value and wait for 1 minute.

Check this clip (GIF), wait till the end (~72 sec) Untitled Project

And same is with this card:

type: vertical-stack
cards:
  - type: markdown
    content: '{{relative_time(states.input_number.test_number.last_changed)}}'
  - type: entities
    entities:
      - entity: input_number.test_number
        secondary_info: last-changed

image Probably a card is updated when the entity is changed. Since the entity is NOT changed, then the card is NOT updated.

Also, a conventional secondary_info value seems to be updated periodically.

ThePeePs commented 1 year ago

Has anyone found a work around for this? I see that the built-in entity row seems to work just fine with updating relative_time.

ildar170975 commented 4 months ago

can be closed