Need Help getting a HA-Automation into ESPhome

I have 4 DS18B20 measuring Temperatures of my Heatingsystem and Solarthermie,
the Automation i use in HA works, but i want to move this direktly into ESPHome because it must run
by itself, even if HA doesn’t work.
So i need help writing an Automation in ESPHome, can someone help me?

here the HA Automation:
TurnOn:

alias: Heizung Sonnenkollektor warm
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.sonnenkollektor_temp
    value_template: >-
      {{ states('sensor.sonnenkollektor_temp')|float(0) -
      states('sensor.ruecklauf_heizkoerper_temp')|float(0) }}
    above: 27
action:
  - type: turn_on
    device_id: 522e4952768a46569d6810551128cfd2
    entity_id: switch.switch_4_2
    domain: switch
  - type: turn_on
    device_id: 522e4952768a46569d6810551128cfd2
    entity_id: switch.switch_5_2
    domain: switch
  - type: turn_off
    device_id: 522e4952768a46569d6810551128cfd2
    entity_id: switch.switch_6_2
    domain: switch
  - type: turn_on
    device_id: 522e4952768a46569d6810551128cfd2
    entity_id: switch.switch_7_2
    domain: switch
mode: parallel
max: 500

TurnOff:

alias: Heizung Sonnenkollektor kalt
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.sonnenkollektor_temp
    below: sensor.ruecklauf_heizkoerper_temp
action:
  - type: turn_off
    device_id: 522e4952768a46569d6810551128cfd2
    entity_id: switch.switch_4_2
    domain: switch
  - type: turn_off
    device_id: 522e4952768a46569d6810551128cfd2
    entity_id: switch.switch_5_2
    domain: switch
  - type: turn_on
    device_id: 522e4952768a46569d6810551128cfd2
    entity_id: switch.switch_6_2
    domain: switch
  - type: turn_off
    device_id: 522e4952768a46569d6810551128cfd2
    entity_id: switch.switch_7_2
    domain: switch
mode: parallel
max: 500

At the moment this is my ESPHome Config:

esphome:
  name: sonnenkollektor_temp
  platform: ESP8266
  board: d1_mini

logger:

api:
  password: "xxxx"

ota:
  password: "xxxx"

wifi:
  networks:
  - ssid: "xxxx"
    password: "xxxx"
  - ssid: "xxxx"
    password: "xxxx"
  - ssid: "xxxx"
    password: "xxxx"
  manual_ip:
    static_ip: 192.168.3.18
    gateway: 192.168.2.1
    subnet: 255.255.252.0

web_server:
  port: 80

dallas:
  - pin: GPIO05
    update_interval: 10s
  
sensor:
  - platform: dallas
    # Kollektor Sensor 1
    address: 0xc8672ae90264ff28
    name: "Sonnenkollektor Temp"
    id: "DS18B20_KOLLEKTOR"
    filters:
      - filter_out: nan

  - platform: dallas
    # Rücklauf Kessel Sensor 2
    address: 0x295b94bf0164ff28
    name: "Ruecklauf Kessel Temp"
    id: "DS18B20_RUECKLAUF_KESSEL"
    filters:
      - filter_out: nan

  - platform: dallas
    # Rücklauf Heizkörper Sensor 3
    address: 0x4e8965b90164ff28
    name: "Ruecklauf Heizkoerper Temp"
    id: "DS18B20_RUECKLAUF_HEIZKOERPER"
    filters:
      - filter_out: nan

  - platform: dallas
    # Vorlauf Kessel Sensor 4
    address: 0x206b61b90164ff28
    name: "Vorlauf Kessel Temp"
    id: "DS18B20_VORLAUF_KESSEL"
    filters:
      - filter_out: nan

spi:
  clk_pin: 14
  mosi_pin: 13

display:
  - platform: max7219
    cs_pin: 04
    num_chips: 1
    intensity: 2
    lambda: |-
      it.printf(0, " ");
      it.printf(1, "%.1f", id(DS18B20_KOLLEKTOR).state);
      it.printf(4, " ");
      it.printf(5, "%.1f", id(DS18B20_RUECKLAUF_HEIZKOERPER).state);