Créer des conditions and sous esphome

Bonjour à toutes et tous,

Je souhaite créer une régulation de chauffage (celle d’origine fait des caprices) pour un plancher chauffant en hydro-accumulation (chauffe d’un gros ballon tampon par une chaudière bois).
Je travaille sur esphome de façon à ce que la régulation soit autonome.
Par contre je n’arrive pas à créer une condition and.
Je souhaite mettre le circulateur cir_plancher en fonctionnement uniquement lorsque temp_haut ballon > 30°C, t_ext < 21°C et t_amb < 21°C.

Merci pour votre aide.

substitutions:
  name: esphome-web-c45ed4
  friendly_name: ESP32_chaufferie

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  min_version: 2024.6.0
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: dev

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

# Allow Over-The-Air updates
ota:
- platform: esphome

# Allow provisioning Wi-Fi via serial
improv_serial:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.159
    gateway: 192.168.1.254
    subnet: 255.255.255.0
  reboot_timeout: 0s
  # Set up a wifi access point
  ap: {}

# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:

dashboard_import:
  package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
  import_full_config: true

# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
esp32_improv:
  authorizer: none

# To have a "next url" for improv serial
web_server:
  local: true
  port: 80
  auth:
    username: chauff
    password: chauff

one_wire:
  - platform: gpio
    pin: GPIO23

number:
  - platform: template
    name: "pente"
    optimistic: true
    min_value: 0
    max_value: 4
    step: 0.1
    id: pente
    initial_value: 0.6
  - platform: template
    name: "parallele"
    optimistic: true
    min_value: 0
    max_value: 30
    step: 0.5
    id: parallele
    initial_value: 20
  - platform: template
    name: "consigne"
    optimistic: true
    min_value: 10
    max_value: 30
    step: 0.5
    id: consigne
    initial_value: 20

script:
  - id: script_ouverture
    mode: restart
    then:
      - switch.turn_on: ouverture_v3v
      - delay: 1s
      - switch.turn_off: ouverture_v3v
      - delay: 10s
      - script.execute: script_ouverture
  - id: script_fermeture
    mode: restart
    then:
      - switch.turn_on: fermeture_v3v
      - delay: 1s
      - switch.turn_off: fermeture_v3v
      - delay: 10s
      - script.execute: script_fermeture

sensor:
  - platform: dallas_temp
    update_interval: 5s
    address: 0x723ce1d4431cf028
    name: "t_chaudiere"
    id: t_chaudiere
  #Mise en service de la pompe de charge de la chaudière.
    on_value_range:
          - above: 65
            then:
              - switch.turn_on: cir_chaudiere
          - below: 60
            then:
              - switch.turn_off: cir_chaudiere
  - platform: dallas_temp
    update_interval: 5s
    address: 0x293ce1d44398a828
    name: "t_haut_ballon"
    id: t_haut_ballon
  - platform: dallas_temp
    update_interval: 5s
    address: 0xb53ce1d443546828
    name: "t_bas_ballon"
    id: t_bas_ballon
  - platform: dallas_temp
    update_interval: 5s
    address: 0xc13ce1d443f0ee28
    name: "t_depart"
    id: t_depart
  - platform: dallas_temp
    update_interval: 5s
    address: 0x313ce1d4431d2d28
    name: "t_amb"
    id: t_amb
  - platform: dallas_temp
    update_interval: 5s
    address: 0xa83ce1d4438f4f28
    name: "t_ext"
    id: t_ext
  #Calcul de la loi d'eau.
  - platform: template
    name: "loi_d_eau"
    update_interval: 5s
    id: loi_d_eau
    unit_of_measurement: °C
    lambda: |-
      return (id(pente).state *(id(consigne).state - id(t_ext).state) + id(parallele).state);
  #Régulation de la température de départ plancher chauffant par vanne 3 voies.
  - platform: template
    name: "dif_depart-loideau"
    update_interval: 5s
    id: dif_depart_loideau
    unit_of_measurement: °C
    lambda: |-
      return (id(t_depart).state - id(loi_d_eau).state);
    on_value_range: 
          - above: 0.8
            then:
            - script.stop: script_ouverture
            - script.execute: script_fermeture
          - below: 0.79
            above: -0.79
            then: 
            - script.stop: script_ouverture
            - script.stop: script_fermeture 
          - below: -0.8
            then: 
            - script.stop: script_fermeture
            - script.execute: script_ouverture
              
switch:
  - platform: gpio
    name: "ouverture_v3v"
    pin: GPIO18
    id: ouverture_v3v
  - platform: gpio
    name: "fermeture_v3v"
    pin: GPIO19
    id: fermeture_v3v
  - platform: gpio
    name: "cir_chaudiere"
    pin: GPIO21
    id: cir_chaudiere
  - platform: gpio
    name: "cir_plancher"
    pin: GPIO5
    id: cir_plancher

Ma configuration

## System Information

version | core-2024.8.2
-- | --
installation_type | Home Assistant OS
dev | false
hassio | true
docker | true
user | root
virtualenv | false
python_version | 3.12.4
os_name | Linux
os_version | 6.6.33-haos
arch | aarch64
timezone | Europe/Paris
config_dir | /config

<details><summary>Home Assistant Community Store</summary>

GitHub API | ok
-- | --
GitHub Content | ok
GitHub Web | ok
GitHub API Calls Remaining | 5000
Installed Version | 1.34.0
Stage | running
Available Repositories | 1452
Downloaded Repositories | 5

</details>

<details><summary>Home Assistant Cloud</summary>

logged_in | false
-- | --
can_reach_cert_server | ok
can_reach_cloud_auth | ok
can_reach_cloud | ok

</details>

<details><summary>Home Assistant Supervisor</summary>

host_os | Home Assistant OS 12.4
-- | --
update_channel | stable
supervisor_version | supervisor-2024.08.0
agent_version | 1.6.0
docker_version | 26.1.4
disk_total | 98.7 GB
disk_used | 24.6 GB
healthy | true
supported | true
host_connectivity | true
supervisor_connectivity | true
ntp_synchronized | true
virtualization | kvm
board | generic-aarch64
supervisor_api | ok
version_api | ok
installed_addons | ESPHome (2024.7.3), File editor (5.8.0), Mosquitto broker (6.4.1), Let's Encrypt (5.1.1), WireGuard (0.10.2), Advanced SSH & Web Terminal (18.0.0), Zigbee2MQTT (1.39.1-1), Studio Code Server (5.15.0)

</details>

<details><summary>Dashboards</summary>

dashboards | 4
-- | --
resources | 2
views | 6
mode | storage

</details>

<details><summary>Recorder</summary>

oldest_recorder_run | 22 août 2024 à 19:06
-- | --
current_recorder_run | 22 août 2024 à 21:06
estimated_db_size | 854.91 MiB
database_engine | sqlite
database_version | 3.45.3

</details>

Bonjour,
Après plusieurs semaines de recherche, j’ai appris à utiliser la fonction && dans les templates.
Du coup voilà ce que ça donne :

 - platform: dallas_temp
    update_interval: 5s
    address: 0xa83ce1d4438f4f28
    name: "t_ext"
    id: t_ext
    on_value:
      then:
        - if:
            condition:
              lambda: return ((x < id(seuil_t_ext).state) && (id(t_amb2).state < id(seuil_t_amb).state) && (id(t_haut_ballon).state > id(seuil_t_haut_ballon).state));
            then:
              - switch.turn_on: cir_plancher
            else:
              - switch.turn_off: cir_plancher        

Les 9 dernières lignes étant à recopier sur les deux autres sensors en adaptant le lambda.

Si ça peut servir à d’autres utilisateurs.

Bonne soirée.