iantrich / config-template-card

📝 Templatable Lovelace Configurations
MIT License
425 stars 55 forks source link

Needle in gauge card resets when entity is changed #131

Closed swissdiver closed 6 months ago

swissdiver commented 10 months ago

Release with the issue: Home Assistant 2023.8.4 Supervisor 2023.08.1 Operating System 10.5 Frontend 20230802.1 - latest

Last working release (if known):

Browser and Operating System: Win 11, Firefox & Chrome

Description of problem: I have created a customised gauge card in which I first define a variable max value and in a second step also want to make the deviations variable. But now I've noticed that when I change the entity, the needle jumps to "0" for a short time and the pointer wobbles. With the standard gauge card, the status changes smoothly.

https://github.com/iantrich/config-template-card/assets/95888298/db9c3818-52cb-470f-8e70-82155da9d56b


type: vertical-stack
cards:
  - type: custom:config-template-card
    variables:
      maxBar: Number(states['input_select.sensor_1_type'].state)
    entities:
      - sensor.bar_var_sensor1
    card:
      type: gauge
      entity: sensor.bar_var_sensor1
      name: Stufe 1
      needle: true
      min: 0
      max: ${maxBar}
      segments:
        - from: 0
          color: '#db4437'
        - from: 5
          color: '#ffa600'
        - from: 6
          color: '#43a047'
        - from: 8
          color: '#ffa600'
        - from: 9
          color: '#db4437'
  - type: gauge
    entity: sensor.bar_var_sensor1
    name: Stufe 1
    needle: true
    min: 0
    max: 10
    segments:
      - from: 0
        color: '#db4437'
      - from: 5
        color: '#ffa600'
      - from: 6
        color: '#43a047'
      - from: 8
        color: '#ffa600'
      - from: 9
        color: '#db4437'
  - type: entities
    entities:
      - entity: input_number.demo_smart_1_1
ildar170975 commented 10 months ago

It happens because the nested card is REDRAWN when a monitored entity changed. Consider this not as a bug but as an outcome of the card's design...

mcmanigle commented 6 months ago

Question: in this example, does sensor.bar_var_sensor1 need to be a monitored entity? Since the templated values (just max) depend only on input_select.sensor_1_type, couldn't that alone be listed in entities?

ildar170975 commented 6 months ago

does sensor.bar_var_sensor1 need to be a monitored entity? Since the templated values (just max) depend only on input_select.sensor_1_type, couldn't that alone be listed in entities?

Both of them should be declared in "entities".

Explanations were provided. No feedback from OP. Closed.