button-card
button-card copied to clipboard
last_updated timestamp isn't refreshing card
Checklist
- [x ] I updated the card to the latest version available
- [x ] I cleared the cache of my browser
Describe the bug Accessing and using last_updated isn't refreshing the visual. I'm polling an API every 60/120 seconds, the API should respond with an update and i want to conditionally display red text on the last_updated field if this has failed
Version of the card v3.4.2
To Reproduce This is the configuration I used:
type: custom:button-card
entity: sensor.tesla_state
show_state: true
show_last_changed: true
triggers_update:
- sensor.tesla_online
custom_fields:
progress: >
[[[ return '<span style="position:absolute; left:195px; font-size:10px;">'
+ new Date(states['sensor.tesla_state'].last_updated).toLocaleString() +
'</span>']]]
time_diff: |
[[[ return `<span style="position:absolute; left:0px; font-size:10px;">
${new Date().getTime() - new Date(states['sensor.tesla_state'].last_updated).getTime()}
</span>`]]]
Screenshots
Image of the display:
Data from node-red showing update time:
Expected behavior On last_updated changing, even if the string value is unchanged, it should reflect the actual sensor data for when the sensor was pinged (is this a nodered issue?). I've removed the conditional aspect because to start with the card isn't updating.
Desktop (please complete the following information):
- Browser chrome and home assistant web app across multiple devices
- Version 106.0.5249.119 (Official Build) (64-bit)
Smartphone (please complete the following information):
- n/a
Additional context I've also tried adding forced updates to trigger_updates on all, it didn't make any difference
Looks like you are only asking it to look at changes to "sensor.tesla_online", try adding "sensor.tesla_state" to the list. E.G.:
triggers_update:
- sensor.tesla_online
- sensor.tesla_state
Or just use: "triggers_update: all"