Custom Button Card do not refresh data while using variables for entities

Hello, I have problem with Custom Button Card configuration.

To make code nice and clean I put all entities for Tile in one section

# Kafelek *** POMPA CWU ***
type: custom:button-card
show_name: false
entity: "switch.smartdgm_pompa_cwu"

# ZMIENNE ( W tej sekcji należy wskazać encje )
variables:
  zmienna_nazwa: "switch.smartdgm_pompa_cwu"
  zmienna_ikona: "mdi:turbine"
  zmienna_pobor: "sensor.smartdgm_pompa_cwu_energy_power"
  zmienna_pobor_dzis: "sensor.smartdgm_pompa_cwu_energy_today"
  zmienna_pobor_ogolem: "sensor.smartdgm_pompa_cwu_energy_total"
  zmienna_rssi: "sensor.smartdgm_pompa_cwu_rssi"
  zmienna_ip: "sensor.smartdgm_pompa_cwu_ip"
# FUNKCJE ( W tej sekcji wywoływane są zmienne zawierające nazwy encji )
custom_fields:
  # Nazwa
  pole_A2: >
    [[[
      return states[[[variables.zmienna_nazwa]]].attributes.friendly_name
    ]]]

  # Pobór prądu BIEŻĄCY
  pole_C2: >
    [[[
      if (entity.state !='unavailable' & states['input_boolean.kafelek_status_gniazda'].state == 'on' & entity.state == 'on')
      return `${states[[[variables.zmienna_pobor]]].state}`
    ]]]

Data show up, it’s working, but since I use the variables as entity for example power sensor does not refreshing data online.

If i use code

return (states['sensor.smartdgm_pompa_cwu_energy_power'].state)

data is changing online, but my idea was to put entities data in one place, then its easy and fast to copy tile
and You have to modify entities in few line instead looking for this in code.

Custom Button Card

I am using the custom:button-card in a very similar way to have all my heating info in a single place. For me, the updates in the button are instantaneous, so it should work for you as well.

Is the problem with a specific custom_field or everything you display? Can you post the whole yaml for one of the buttons?

[edited for typos]

It all looks OK to me. The only difference is I am not using a template.

Can you try a simpler version without the template just to rule this difference out?

I think It depends on javascript template, found in documentation

triggers_update

triggers_update: all

Putting above code in my card solved the problem, because by default main entity trtigger update, but i have
few entities and system will not update for ex. rssi signal because entity state didn’t change.
Dont know will it not overload the page, server etc…

1 Like

Got a similar issue, with a button card containing 7 sensors shown with titles build by js.
Perhaps @RomRider could help. I sent him a way too long YAML example to be posted in here. Especially for a sensor curve it’s essential it doesn’t get stuck awaiting a state change since time passes on mostly by 60 seconds within a minute, no matter if the actual state of the sensor entlty remains static.

1 Like

Hi!
Jist face this issue: button-card reacts and update view (styling-visibility) on triggering entities (as expected) but NOT re-calculate templated strings.
But now I have more information: this happens in browser_mod popup windows only. It looks like templated expressions calculated only after I re-open popup window.

If I move button-card description block to base dashboard it works Ok both with styles/states configuration and templated expressions