MQTT + yaml display problem


I display in a card, informations transmitted by MQTT.

The MQTT message has several elements. They are not necessarily all present at the same time. In fact I do not send information whose value has not changed during a cycle (push information every minute).

Here is an example of a message:

Listen  /chaudiere_viessmann/etat
Message 0 received /chaudiere_viessmann/etat à 10:42 :
    "infos_chaudiere_consigne_temperature_reduit": "18",
    "infos_chaudiere_consigne_temperature_party": "20",
    "infos_chaudiere_regime_eco": "False",
    "infos_chaudiere_mode": "2",
    "infos_chaudiere_temp_ambiante": "19.2",
    "infos_chaudiere_regime_party": "False",
    "infos_chaudiere_consigne_temperature_normale": "19",
    "infos_chaudiere_temp_sonde": "13.7",
    "infos_chaudiere_consommation_jour_chauffage": "10",
    "infos_chaudiere_temps_fonctionnement": "0",
    "infos_chaudiere_temp_fumees": "26",
    "infos_chaudiere_temp_ecs": "45",
    "infos_chaudiere_consigne_temperature_eau_chaude": "50",
    "infos_chaudiere_temp_corps": "25",
    "infos_chaudiere_consommation_jour_eau_chaude": "2",
    "infos_chaudiere_date": "Lun 25/04/2022 10:41:46",
    "infos_chaudiere_puissance": "0.0"

Here is a message received, it only includes the information that has changed since the previous call
Message 1 received on  /chaudiere_viessmann/etat à 10:43 :
    "infos_chaudiere_temp_sonde": "13.8",
    "infos_chaudiere_date": "Lun 25/04/2022 10:42:44"

Here is the yaml description of the MQTT data

  - platform: mqtt
    name: infos_chaudiere_temp_ambiante
    state_topic: "/chaudiere_viessmann/etat"
    value_template: |-
      {% if value_json.infos_chaudiere_temp_ambiante is defined %}
      {% else %}
        {{ states(entity_id)}}
      {% endif %}
    json_attributes_topic: "/chaudiere_viessmann/etat"
    device_class: temperature
    state_class: measurement
    unit_of_measurement: °C
    icon: mdi:thermometer

  - platform: mqtt
    name: infos_chaudiere_date
    state_topic: "/chaudiere_viessmann/etat"
    value_template: '{{value_json.infos_chaudiere_date}}'
    json_attributes_topic: "/chaudiere_viessmann/etat"
    icon: mdi:calendar

I set (a little snatch) code to display the value of the entity if it is not present in the received message.

The problem observed, when displaying the second message, the data present on the screen is empty.

Here are three screenshots to show what’s happening on display.

If someone can direct me to the right track? I am just starting to use HA.

My configuration

System Health

version: core-2022.4.7
installation_type: Home Assistant OS
dev: false
hassio: true
docker: true
user: root
virtualenv: false
python_version: 3.9.9
os_name: Linux
os_version: 5.10.103-v8
arch: aarch64
timezone: Europe/Paris

GitHub API: ok
GitHub Content: ok
GitHub Web: ok
GitHub API Calls Remaining: 5000
Installed Version: 1.24.0
Stage: running
Available Repositories: 1023
Downloaded Repositories: 13

logged_in: false
can_reach_cert_server: ok
can_reach_cloud_auth: ok
can_reach_cloud: ok

host_os: Home Assistant OS 7.6
update_channel: stable
supervisor_version: supervisor-2022.04.0
docker_version: 20.10.9
disk_total: 237.7 GB
disk_used: 11.4 GB
healthy: true
supported: true
board: rpi4-64
supervisor_api: ok
version_api: ok
installed_addons: Samba share (9.5.1), File editor (5.3.3), Duck DNS (1.14.0), SSH & Web Terminal (10.1.1), Mosquitto broker (6.0.1), Node-RED (11.1.1), Z-Wave JS (0.1.57), SQLite Web (3.3.0), InfluxDB (4.4.1), Grafana (7.5.2)

dashboards: 14
resources: 10
views: 37
mode: storage