Card no longer automatically updates when timer changes state since 2024.3, requires manual page refresh
jarrodstrachan96 opened this issue · 4 comments
Describe the bug
When the timer emtity changes state, ie from timer isn't running to timer is running, or the time remaining changes value, the card no longer shows the real current live value, without manually refreshing the page. This behavior only began since I updated to 2024.3. Please note, I am using Card Templater in conunction with tiemr card, but the bug remains even without card templater.
Please see video attached to see the issue : https://streamable.com/0gazof
Your card configuration
type: custom:card-templater
card:
type: custom:timer-bar-card
entity: timer.climate_manual_mode_timer
name_template: |
{% set booststatus = states('input_boolean.climate_boost') %}
{% if booststatus == 'on' %}
Boost Timer
{% else %}
Manual Timer
{% endif %}
invert: true
bar_direction: ltr
bar_width: 100%
height: 100px
mushroom:
layout: vertical
color: white
hold_action:
action: none
style: |
ha-card {
--st-font-size-title: 25px;
{% set climatemode = states('input_select.climate_mode_selection') %}
{% if climatemode == 'Manual' %}
border: 2px solid white;
--ha-card-background: grey;
{% endif %}
}
entities:
- input_boolean.climate_boost
Debug information
Please add debug: true
to your configuration and either take a screenshot or paste the output here!
I'll take a look when I have some time. It's odd that no one else has commented yet; I'd expect there to be more activity on this issue for such a noticeable regression.
Hi rianadon,
indeed I do have the same issue. Here is what I have:
I am on version: 2024.5.5
- I use the duration from within a script
- I can start with the script via call or from the timer card (love that)
the card doesn't update apart from the fact that it says on - in my case it is correct as I use a switch.
The moment I click on "dashboard settings" icon
It shows the correct value and from then on
It keeps updating, even when I go back to view.
Strange, isn't it.
Cheers
Dietger
Below is the code:
type: custom:timer-bar-card
bar_direction:
invert: true
entity: switch.fibaro_gartenbewaesserung_1
name: Restlaufzeit
duration:
script: script.turn_on_bewaesserung_1
tap_action:
action: call-service
service: script.turn_on_bewaesserung_1
hold_action:
action: more-info
mushroom:
layout: horizontal
color: green
I also seem to have this problem, although I'm a new user so I've never seen it work correctly. I'm on version 1.30.2, HA 2024.6.4. I'm using this configuration:
type: custom:timer-bar-card
entity: binary_sensor.linktap_taplinker_is_watering
duration:
entity: sensor.linktap_taplinker_total_duration
units: seconds
remain_time:
entity: sensor.linktap_taplinker_remain_duration
units: seconds
bar_width: 80%
mushroom:
layout: vertical
color: blue
debug: true
The card only updates when the state changes at the beginning and end. When the time changes (which should be detected by the remain_time
entity updating), nothing happens. The only way to get it to update is to force the whole card to rerender, e.g. by switching views or refreshing the page.
Debug info from the card:
State: on (state mode = active)
Mode: active (explicit; guess mode produces N/A)
Duration: 300 second
Time remaining: 165
Counter: 165
Attr: {"icon":"mdi:water","friendly_name":"Linktap TapLinker Is Watering"}
I poked around a bit and at least in my case, and I suspect @dimafemabo's based on their config, the problem is here in shouldUpdate()
:
if (this.config.entity) {
return hasConfigOrEntityChanged(this, changedProps, false);
}
Defining an entity
in the config short-circuits all the checking of the other entities generated by gatherEntitiesFromConfig()
-- instead the card only updates if the main entity has changed. I'm not sure if there's a good reason for this, but it seems like it could just be removed; config.entity
is already included in the list generated by gatherEntitiesFromConfig()
.
Now that I look at the examples more closely, they all seem to use entities
instead of entity
, even if there's only one. That would work around this.
Edit:
Also needed to update the later loop to deal with a possibly null config.entities
, but other than that it appears to work for me. I don't know if there's some other configuration that might have problems though.