config-template-card
config-template-card copied to clipboard
Auto refreshing of values raising exception
Checklist:
- [x] I updated to the latest version available
- [x] I cleared the cache of my browser
Release with the issue:
Last working release (if known):
Browser and Operating System: Windows 10 (Edge, Chrome, Firefox) + Android (Home Assistant APP)
Description of problem: Auto refresh of values doesn't work (initial loading or f5 works). The lovelace entities are auto generated by https://github.com/thomasloven/lovelace-auto-entities
Javascript errors shown in the web inspector (if applicable):
Uncaught (in promise) TypeError: this._config.entities.forEach is not a function
at HTMLElement.shouldUpdate (config-template-card.js:3290)
at HTMLElement.performUpdate (config-template-card.js:2414)
at HTMLElement._enqueueUpdate (config-template-card.js:2369)
Additional information:
Lovelace:
type: 'custom:auto-entities'
card:
type: grid
columns: 6
card_param: cards
filter:
include:
- entity_id: /sensor.server_/
options:
type: 'custom:config-template-card'
entities: this.entity_id
card:
type: gauge
entity: this.entity_id
max: 100
this._config.entities
:
My bad, entitites needed to be a list...
type: 'custom:auto-entities'
card:
type: grid
columns: 6
card_param: cards
filter:
include:
- entity_id: /sensor.server_/
options:
type: 'custom:config-template-card'
entities:
- this.entity_id
card:
type: gauge
entity: this.entity_id
max: 100
But it still doesn't work as expected, is this template card tested with card-type: gauge? When receiving a new value the animation repeats like I refresh my browser.
Have you tried this without auto-entities? No testing has been done with other custom cards.
I tired it without auto-entities, same result.
copy paste on my phone doesn't work but with the config below you get this result:
type: 'custom:config-template-card'
entities:
- sensor.xy
card:
type: gauge
entity: sensor.xy
min: 0
max: 1000
I am unable to replicate
Thats strange.
I reinstalled this card, cleared Cache and tried different browsers.
- title: Testttttt
path: testttttt
badges: []
cards:
- type: 'custom:config-template-card'
entities:
- sensor.fritz_box_7590_packets_sent
card:
type: gauge
entity: sensor.fritz_box_7590_packets_sent
min: 0
max: 100000000
Any idea what could lead to this behaviour? Im out of ideas
Have you found a solution? I think my problem #60 is the same as yours.
Nope, sorry. I have still no clue whats going on, this weird refreshes are really annyoing :/
Good news, I figured out how to replicate this. Will see what can be done. Bad news, my dev environment is all messed up.
Hi
I also had a look at this issue. Basically, when the state of a sensor changes, the Config-Template-Card will trigger a rerender, which will create a new gauge card. The standard behavior of the gauge card is to show this animation and that is why you are seeing this movement(basically the new gauge card is just going from 0 to this value)
I have a question though: Why do you need to use the template-card in the first place for this? The sample you provided can be done without the template as well:
type: custom:auto-entities
card:
type: grid
columns: 6
card_param: cards
filter:
include:
- entity_id: /sensor.server_/
options:
type: gauge
entity: this.entity_id
max: 100
Would be interesting to know where exactly you are using the template. I am using this card quite extensively and ran into the issue that recalculating the template is done quite often(basically with any state update), but once the basic templating is done, nothing is updating anymore. Basically I calculate the entity_id of some switches based on a sensor, replace somee strings to shorten them and that's it. There would not be the need to recalculate ANYTHING after that, and no change in the state of any sensor would change that. So I am thinking maybee you have the same usecase and it would be possible to just add a config to the card that would only ever update if the config changes?
Hello, have you solved this problem? I also met it. How can I solve it?
@kamtschatka Not OP but my use case is that I want the min
, max
, and name
values to be based on attributes. I could make a workaround with helpers where min and max are 0 and 100 but the value is a new template calculating the percentage using the real min and max. The name I am still unsure of, could maybe use vertical stack and card mod to combine it with a markdown or title card.
Edit: I guess I also need to use card mod to hide the gauge's value
Edit 2: Got it (mostly) working with button-card
and card-mod
type: custom:button-card
custom_fields:
xp_gauge:
card:
type: gauge
entity: sensor.xp
needle: false
max: '[[[ return states[''sensor.xp''].attributes.level_max ]]]'
name: XP Meter
min: '[[[ return states[''sensor.xp''].attributes.level_min ]]]'
card_mod:
style: |
ha-card {
border-width: 0;
}
styles:
grid:
- grid-template-areas: '"xp_gauge"'
I say mostly because the name
field has the same behavior but this is much closer and I can probably fix that with button card eventually by hiding the name completely via card mod and placing another text overlapping it.
FYI @deemonrider @fangguisheng
Closing the issue. A gauge behaviour is explained, there is nothing else here.