How to read different values in a climate card

Hello everyone,

I use the Climate Card to control my heating. all data comes via MQTT (BSB-LAN).

The data for my Climate Card comes via a YAML file called climates.yaml.

This file looks like this:

- name: "Fußbodenheizung EG HK1"
  unique_id: sb_lan_climate_fbh
  availability_topic: "BSB/status"
  payload_on: 1
  payload_off: 0
  modes:
    - auto
    - heat
    - cool
    - "off"
  mode_state_topic: "BSB/1000!1"
  mode_state_template: >-
    {% set values = { '0 - Schutzbetrieb':'off', '1 - Automatik':'auto', '2 - Reduziert':'cool', '3 - Komfort':'heat'} %}
    {{ values[value] if value in values.keys() else 'off' }}
  mode_command_topic: "BSB"
  mode_command_template: >-
    {% set values = { 'off':'S1000=0!1', 'auto':'S1000=1!1', 'cool':'S1000=2!1', 'heat':'S1000=3!1'} %}
    {{ values[value] if value in values.keys() else '0' }}
  current_temperature_topic: "BSB/8740"
  current_temperature_template: >-
    {% if value == '---' %}
        {{ 'None' }}
    {% else %}
        {{ value }}
    {% endif %}
  min_temp: 5
  max_temp: 30
  temp_step: 0.1
  temperature_state_topic: "BSB/710!1"
  temperature_command_topic: "BSB"
  temperature_command_template: "{{'S1010!1='+ (value| string)}}"
  device:
    {
      identifiers: ["00000002"],
      name: "Heizung",
      model: "SOB22C",
      manufacturer: "Brötje",
    }

The whole thing actually works great, but I have a different mqtt message for each mode set (heat, cool, etc.).

It is currently reading the value for display in the climate card from temperature_state_topic: “BSB/710!1”. However, this is only true if the thermostat is set to heat. For the cool setting he would have to query the topic “BSB/712!1” and for off the topic “BSB/714!1”.

My idea was to set the point like this:

  temperature_state_topic: "BSB"
  temperature_state_template: >- 
    {% if state_attr('climate.brennwertheizung_fussbodenheizung_eg_hk1', 'hvacmode.heat') %}
        {{ '710!1' }}
    {% elif state_attr('climate.brennwertheizung_fussbodenheizung_eg_hk1', 'hvacmode.cool') %}
        {{ '712!1' }}
    {% elif state_attr('climate.brennwertheizung_fussbodenheizung_eg_hk1', 'hvacmode.off') %}
        {{ '714!1' }}
    {% endif %}

So that, depending on which Hvac mode is currently active, the appropriate temperature is displayed, completely like this:

- name: "Fußbodenheizung EG HK1"
  unique_id: bsb_lan_climate_fbh
  availability_topic: "BSB/status"
  payload_on: 1
  payload_off: 0
  modes:
    - auto
    - heat
    - cool
    - "off"
  mode_state_topic: "BSB/700!1"
  mode_state_template: >-
    {% set values = { '0 - Schutzbetrieb':'off', '1 - Automatik':'auto', '2 - Reduziert':'cool', '3 - Komfort':'heat'} %}
    {{ values[value] if value in values.keys() else 'off' }}
  mode_command_topic: "BSB"
  mode_command_template: >-
    {% set values = { 'off':'S700=0!1', 'auto':'S700=1!1', 'cool':'S700=2!1', 'heat':'S700=3!1'} %}
    {{ values[value] if value in values.keys() else '0' }}
  current_temperature_topic: "BSB/716!1"
  current_temperature_template: >-
    {% if value == '---' %}
        {{ 'None' }}
    {% else %}
        {{ value }}
    {% endif %}
  min_temp: 5
  max_temp: 30
  temp_step: 0.1
  temperature_state_topic: "BSB"
  temperature_state_template: >- 
    {% if state_attr('climate.brennwertheizung_fussbodenheizung_eg_hk1', 'hvacmode.heat') %}
        {{ '710!1' }}
    {% elif state_attr('climate.brennwertheizung_fussbodenheizung_eg_hk1', 'hvacmode.cool') %}
        {{ '712!1' }}
    {% elif state_attr('climate.brennwertheizung_fussbodenheizung_eg_hk1', 'hvacmode.off') %}
        {{ '714!1' }}
    {% endif %}

  temperature_command_topic: "BSB"
  temperature_command_template: "{{'S710!1='+ (value| string)}}"
  device:
    {
      identifiers: ["00000002"],
      name: "Heizung",
      model: "SOB22C",
      manufacturer: "Brötje",
    }

Unfortunately the whole thing doesn’t work that way, I’m also an absolute noob when it comes to creating individual yaml files, for me it’s more like copy & paste, I hope someone can still help me and point me in the right direction.

best regards
Pierre