Control of gas/electric water boiler/heater - thermostat and temperature control

It was idea to create some simple thermostat for my home heating system ( gas heater, water in radiators) to make it smart and integrate to Homeassistant. For “climate integration” it necessary two components:
1)switch (relay) to control heater and
2)any temperature sensor, both integrated in Homeassistant.

From what I started:

  1. Switch - Sonoff basic flashed with ESPHOME basic ( direct from example for Sonoff Basic),
  2. Temperature sensor - Zigbee Aqara Temperature sensor.
    Both above components were integrated in Homeassistant, and climate integration done, all is good. But then i realised, that I cant control operation of my gas boiler, I don’t know if its really run after switch was “ON”.

I decided to add DS18 temperature sensor to my Sonoff Basic RX gpio, and fast it to the hot water outlet pipe inside of the gas boiler. So, by temperatures readings I can control real operation of gas boiler. Also, I added climate integration for Sonoff Basic itself, and on temperature below 16 C of water, gas boiler will start heating. This is for safety, if your Homeassistant server fails, or you forgot to switch on Your thermostat integration, Your hose will be not frozen, Sonoff Basic will directly control water temperature inside of radiators, to prevent its from freezing. I did it just to utilize possibilities of Sonoff Basic. And after I added boost for my gas boiler, switch " boost" will heat water 20 minutes for 65 C, to make home warm for You. This is for project sharing.
My Sonoff Basic configuration:

esphome:
  name: boilertermo
  platform: ESP8266
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

wifi:
# Set below Your WiFi info
  ssid: "Greenhouse"
  password: "Greenhouse"
  
  manual_ip:
    # Set this to the IP of the ESP
   static_ip: 192.168.1.78
   gateway: 192.168.1.1
    # The subnet of the network. 255.255.255.0 works for most home networks.
   subnet: 255.255.255.0
   
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Boiler Fallback Hotspot"
    password: "12345678"

captive_portal:

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: true
    name: "Boiler Button"
    on_press:
      - switch.toggle: boiler

  - platform: template
    name: "boiler_relay"
    id: boiler_relay
    lambda: |-
      if (id(boiler).state) {
        return true;
      } else {
        return false;
      }

  - platform: template
    name: "Boiler_hot"
    id: boiler_hot
    device_class: heat
    lambda: |-
      if (id(boiler_temp_water).state > 30) {
        return true;
      } else {
        return false;
      }      

dallas:
  pin: GPIO3
  update_interval: 20s
  

sensor:
 - platform: dallas
   name: "boiler_temp_water"
   id: boiler_temp_water
   address: "0x3F3C01D075788A28"
   accuracy_decimals: 1
   force_update: true
      
switch:
  - platform: gpio
    pin: GPIO12
    id: boiler
    icon: "mdi:radiator"
    name: "boiler"
    restore_mode: ALWAYS_OFF
      
  - platform: template
    name: "Boiler boost"
    restore_state: no
    id: boiler_boost
    icon: "mdi:weather-sunny"
    optimistic: true
    turn_on_action:
      - delay: 20min
      - switch.turn_off: boiler_boost
    on_turn_on:
     then:
      - climate.control:
         id:  boiler_thermostat_controller
         preset: "away"
    on_turn_off:
     then:
      - climate.control:
         id: boiler_thermostat_controller
         preset: "home"
    
status_led:
  pin:
    number: GPIO13
    inverted: yes
    
climate:
  - platform: thermostat
    name: "Boiler Thermostat Controller"
    id: boiler_thermostat_controller
    sensor: boiler_temp_water
    default_target_temperature_low: 16 °C
    min_heating_off_time: 60s
    min_idle_time: 120s
    min_heating_run_time: 120s
    heat_action:
      - switch.turn_on: boiler
    idle_action:
      - switch.turn_off: boiler
    default_mode: "heat"
    visual:
      min_temperature: 10 °C
      max_temperature: 70 °C
      temperature_step: 0.1 °C
    away_config:
      default_target_temperature_low: 65
2 Likes