Card_mod + template_card + thermostat card - 1 card out of 4 is not refreshing after actions

I’m using some Shelly window sensors and would like to have a visual cue directly at the HVAC cards that the window for a given room is open. All of the cards are working properly, but the Master Bedroom one is not refreshing when I click a operation mode, for example (all others do…).

Any hints on where I messed up?

cards:
  - cards:
      - type: custom:config-template-card
        variables:
          LIVING_ROOM_WINDOWS_STATE: states['binary_sensor.living_room_windows'].state
        entities:
          - climate.living_room_ac
        card:
          type: thermostat
          entity: climate.living_room_ac
          features:
            - type: climate-fan-modes
              style: dropdown
              fan_modes:
                - low
                - mid
                - high
            - type: climate-hvac-modes
              hvac_modes:
                - 'off'
                - heat
                - cool
                - fan_only
                - dry
          name: >-
            "${LIVING_ROOM_WINDOWS_STATE === 'on' ? '⚠️ Living Room Window Open!
            ⚠️' : 'Living Room'}"
          card_mod:
            style: |
              ha-card {
                 {% if is_state('binary_sensor.living_room_windows', 'on') %}
                    background: rgb(76,0,153);
                 {% endif %}
              }
      - type: custom:config-template-card
        variables:
          LAURA_ROOM_WINDOWS_STATE: states['binary_sensor.shellydw2_6f2a4e_door'].state
        entities:
          - climate.laura_bedroom_ac
        card:
          type: thermostat
          entity: climate.laura_bedroom_ac
          features:
            - type: climate-fan-modes
              style: dropdown
              fan_modes:
                - low
                - mid
                - high
            - type: climate-hvac-modes
              hvac_modes:
                - 'off'
                - heat
                - cool
                - fan_only
                - dry
          name: >-
            "${LAURA_ROOM_WINDOWS_STATE === 'on' ? "⚠️ Laura's Bedroom Window
            Open! ⚠️" : "Laura's Bedroom"}"
          card_mod:
            style: |
              ha-card {
                 {% if is_state('binary_sensor.shellydw2_6f2a4e_door', 'on') %}
                    background: rgb(76,0,153);
                 {% endif %}
              }
    type: horizontal-stack
  - cards:
      - type: custom:config-template-card
        variables:
          MASTER_ROOM_WINDOWS_STATE: states['binary_sensor.shellydw2_483fda825456_door'].state
        entities:
          - thermostat
        card:
          type: thermostat
          entity: climate.master_bedroom_ac
          features:
            - type: climate-fan-modes
              style: dropdown
              fan_modes:
                - low
                - mid
                - high
            - type: climate-hvac-modes
              hvac_modes:
                - 'off'
                - heat
                - cool
                - fan_only
                - dry
          name: >-
            "${MASTER_ROOM_WINDOWS_STATE === 'on' ? '⚠️ Master Bedroom Window
            Open! ⚠️' : 'Master Bedroom'}"
          card_mod:
            style: |
              ha-card {
                 {% if is_state('binary_sensor.shellydw2_483fda825456_door', 'on') %}
                    background: rgb(76,0,153);
                 {% endif %}
              }
      - type: custom:config-template-card
        variables:
          JULIA_ROOM_WINDOWS_STATE: states['binary_sensor.shellydw2_6f2069_door'].state
        entities:
          - climate.julia_bedroom_ac
        card:
          type: thermostat
          entity: climate.julia_bedroom_ac
          features:
            - type: climate-fan-modes
              style: dropdown
              fan_modes:
                - low
                - mid
                - high
            - type: climate-hvac-modes
              hvac_modes:
                - 'off'
                - heat
                - cool
                - fan_only
                - dry
          name: >-
            "${JULIA_ROOM_WINDOWS_STATE === 'on' ? "⚠️ Julia's Bedroom Window
            Open! ⚠️" : "Julia's Bedroom"}"
          card_mod:
            style: |
              ha-card {
                 {% if is_state('binary_sensor.shellydw2_6f2069_door', 'on') %}
                    background: rgb(76,0,153);
                 {% endif %}
              }
    type: horizontal-stack
  - cards:
      - type: custom:mushroom-entity-card
        name: Storage Fan
        fill_container: true
        entity: switch.shelly_plug_storage_fan_switch_0
        tap_action:
          action: toggle
        hold_action:
          action: more-info
        double_tap_action:
          action: none
        layout: vertical
      - type: custom:mushroom-entity-card
        name: Storage Air Purifier
        icon: mdi:air-purifier
        fill_container: true
        entity: fan.zhimi_cpa4_e80d_air_purifier
        tap_action:
          action: toggle
        hold_action:
          action: more-info
        double_tap_action:
          action: none
        icon_type: icon
        icon_color: green
        layout: vertical
      - type: custom:mushroom-number-card
        entity: number.zhimi_cpa4_e80d_favorite_level
        display_mode: slider
        name: Storage Air Purifier
        icon: mdi:air-purifier
        fill_container: true
        tap_action:
          action: none
        hold_action:
          action: more-info
        double_tap_action:
          action: none
        card_mod:
          style: |
            mushroom-card {
              {% if is_state('fan.zhimi_cpa4_e80d_air_purifier', 'on') %}
              {% else %}
                 filter: grayscale(100%);
              {% endif %} 
        layout: vertical
    type: horizontal-stack
type: vertical-stack

1.The code contains plenty of unrelated stuff like card-mod & mushrooms which distracts YOU (not to mention other people) from the main issue.
To solve issues - you need to simplify the code to leave only the minimal config where you still see the problem.
If the code was made by you - you know how to simplify. If the code was taken from somewhere - you still need to understand which parts are responsible for.

2.An inner card inside config-template-card (CTC) is only updated (redraws itself) when:
– a “monitored” entity is changed;
– after a browser’s page refresh (F5).
All entities used in the inner card are supposed to be declared as “monitored” in the “entities” option - otherwise the inner card may miss a change of some entity.
And now compare these 2 inner cards:

      - type: custom:config-template-card
        variables:
          LIVING_ROOM_WINDOWS_STATE: ...
        entities:
          - climate.living_room_ac
...
      - type: custom:config-template-card
        variables:
          MASTER_ROOM_WINDOWS_STATE: ...
        entities:
          - thermostat

P.S. CTC-related questions are discussed in a huge CTC thread. No need to create separate ones.

2 Likes

Thank you for your reply and insights. I see were I messed up, and the error was so simple it hurts. Spent too much time looking at it to see how in front of me it was :confused:
BTW, I did not want to spin any unnecessary wheels and make this a CTC (first time I heard about it) thread.

Once more, a big thank you for taking the time to look at it and help me fix this.

#bowinrespect

1 Like