Advertisement
Guest User

Untitled

a guest
Apr 26th, 2025
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 10.31 KB | None | 0 0
  1. esphome:
  2.   name: opentherm
  3.   platform: ESP32
  4.   board: lolin_s2_mini
  5.   on_boot:
  6.     priority: -100
  7.     then:
  8.       - number.set:
  9.           id: t_dhw_set
  10.           value: 55
  11.       - number.set:
  12.           id: max_t_set
  13.           value: 80
  14.  
  15. logger:
  16. # "NONE", "ERROR", "WARN", "INFO", "CONFIG", "DEBUG", "VERBOSE", "VERY_VERBOSE"
  17.   level: INFO
  18.   logs:
  19.     api: WARN
  20.     binary_sensor: WARN
  21.     climate: INFO
  22.     homeassistant.sensor: WARN
  23.     homeassistant: WARN
  24.     logger: INFO
  25.     mdns: WARN
  26.     number: INFO
  27.     opentherm: ERROR
  28.     component: ERROR
  29.     pid.autotune: INFO
  30.     pid: INFO
  31.     template: INFO
  32.     text_sensor: INFO
  33.  
  34.  
  35. api:
  36. ota:
  37.   platform: esphome
  38. wifi:
  39.   ap:
  40.     ssid: "Thermostat"
  41. captive_portal:
  42. web_server:
  43.   version: 3
  44.   log: false
  45.  
  46. opentherm:
  47.   in_pin: 33
  48.   out_pin: 35
  49.   sync_mode: true
  50.   ch_enable: true
  51.   dhw_enable: true
  52.   cooling_enable: false
  53.   otc_active: false
  54.   ch2_active: false
  55.  
  56. output:
  57.   - platform: opentherm
  58.     t_set:
  59.       id: boiler_setpoint    # setpoint range for boiler water temp in C
  60.       min_value: 45
  61.       max_value: 80
  62.       zero_means_zero: true
  63.  
  64. number:
  65.   - platform: template
  66.     name: "Boiler Setpoint Setting"
  67.     id: tset_setting         # Number input for boiler_setpoint for testing or other thermostat control in HA, boiler_setpoint is controlled by esphome PID thermostat normally
  68.     min_value: 45
  69.     max_value: 80
  70.     mode: box
  71.     step: 1
  72.     lambda: "return id(boiler_setpoint).state;"
  73.     set_action:
  74.       - lambda: "id(boiler_setpoint).write_state(x);"
  75.  
  76.   - platform: opentherm
  77.     t_dhw_set:
  78.       id: t_dhw_set         # Domestic Hot Water Setpoint
  79.       name: "Boiler DHW Setpoint"
  80.     max_t_set:
  81.       id: max_t_set
  82.       name: "Boiler Max Setpoint"
  83. #    otc_hc_ratio:
  84. #      id: ot_hc_ratio       # Heat Curve when using outside temperature sensor and weather compensation
  85. #      name: "OTC heat curve ratio:
  86.  
  87.   - platform: template
  88.     name: "CH max t_set"
  89.     id: ch_max_t_set         # Maximum boiler setpoint, this is limited by a setting in the boiler but can be set lower
  90.     mode: box
  91.     entity_category: config
  92.     min_value: 0
  93.     max_value: 100
  94.     step: 0.1
  95.     lambda: "return id(boiler_setpoint).get_max_value();"
  96.     set_action:
  97.       - lambda: "id(boiler_setpoint).set_max_value(x);"
  98.  
  99.   - platform: template
  100.     name: "CH min t_set"     # Minimum boiler setpoint flow temperature, set this to a setting that the boiler can modulate to without cycling off and on execessively 45C works for average radiator setups. Underfloor heating could be lower.
  101.     id: ch_min_t_set
  102.     mode: box
  103.     entity_category: config
  104.     min_value: 0
  105.     max_value: 100
  106.     step: 0.1
  107.     lambda: "return id(boiler_setpoint).get_min_value();"
  108.     set_action:
  109.       - lambda: "id(boiler_setpoint).set_min_value(x);"
  110.  
  111.  
  112.   - platform: template
  113.     name: "PID Proportional"
  114.     id: thermostat_kp
  115.     mode: box
  116.     entity_category: config
  117.     min_value: 0
  118.     max_value: 100
  119.     step: 0.00001
  120.     lambda: "return id(central_heating_ot).get_kp();"
  121.     set_action:
  122.       - lambda: "id(central_heating_ot).set_kp(x);"
  123.  
  124.   - platform: template
  125.     name: "PID Integral"
  126.     id: thermostat_ki
  127.     mode: box
  128.     entity_category: config
  129.     min_value: 0
  130.     max_value: 100
  131.     step: 0.00001
  132.     lambda: "return id(central_heating_ot).get_ki();"
  133.     set_action:
  134.       - lambda: "id(central_heating_ot).set_ki(x);"
  135.  
  136.   - platform: template
  137.     name: "PID Derivative"
  138.     id: thermostat_kd
  139.     mode: box
  140.     entity_category: config
  141.     min_value: 0
  142.     max_value: 9999
  143.     step: 0.001
  144.     lambda: "return id(central_heating_ot).get_kd();"
  145.     set_action:
  146.       - lambda: "id(central_heating_ot).set_kd(x);"
  147.  
  148.  
  149. sensor:
  150. # Not all opentherm sensors provided by the opentherm component are implemented by each boiler manufacturer
  151. # Non-working sensors seem to report zero rather than not available in both sensors and binary_sensors
  152.   - platform: opentherm
  153.     rel_mod_level:
  154.       name: "Boiler Relative modulation level"
  155.       filters:
  156.         - throttle_average: 15s
  157.     ch_pressure:
  158.       name: "Boiler Water pressure in CH circuit"
  159.       filters:
  160.         - throttle_average: 60s
  161.     t_boiler:
  162.       name: "Boiler water temperature"
  163.       filters:
  164.         - throttle_average: 15s
  165.     t_ret:
  166.       name: "Boiler water return temperature"
  167.     t_dhw:
  168.       name: "Boiler DHW temperature"
  169.       filters:
  170.         - throttle_average: 15s
  171.     t_dhw_set:
  172.       name: "Boiler Domestic hot water temperature setpoint"
  173.     dhw_flow_rate:
  174.       name: "DHW Flow Rate"
  175.  
  176.   # The following gets temperature from two other esphome devices and applies kalman filer
  177.   # These sensors preferably should have two decimals be smoothed with filters to get rid of noise and update frequently
  178.   # This helps the PID algorithm to adjust itself appropriately
  179.   - platform: homeassistant
  180.     name: lounge_dallas
  181.     id: lounge_dallas
  182.     entity_id: sensor.lounge_dallas
  183.     filters:
  184.       heartbeat: 15s
  185.   - platform: homeassistant
  186.     name: kitchen_dallas
  187.     id: kitchen_dallas
  188.     entity_id: sensor.kitchen_dallas
  189.     filters:
  190.       heartbeat: 15s
  191.   - platform: combination
  192.     type: kalman
  193.     id: "t_room"    
  194.     name: "Ground Floor Temperature"
  195.     unit_of_measurement: "°C"
  196.     accuracy_decimals: 2
  197.     process_std_dev: 0.001
  198.     sources:
  199.       - source: lounge_dallas
  200.         error: 0.1
  201.       - source: kitchen_dallas
  202.         error: 0.1
  203.  
  204.   - platform: homeassistant
  205.     name: Heating Setpoint
  206.     id: t_room_set
  207.     entity_id: climate.central_heating_ot
  208.     attribute: temperature
  209.     internal: false
  210.     state_class: measurement
  211.     unit_of_measurement: °C
  212.  
  213.   - platform: pid
  214.     name: "PID Climate Result"
  215.     type: RESULT
  216.     accuracy_decimals: 6
  217.   - platform: pid
  218.     name: "PID Climate Error"
  219.     type: ERROR
  220.     accuracy_decimals: 6
  221.   - platform: pid
  222.     name: "PID Climate Proportional"
  223.     type: PROPORTIONAL
  224.     accuracy_decimals: 6
  225.   - platform: pid
  226.     name: "PID Climate Integral"
  227.     type: INTEGRAL
  228.     accuracy_decimals: 6
  229.   - platform: pid
  230.     name: "PID Climate Derivative"
  231.     type: DERIVATIVE
  232.     accuracy_decimals: 6
  233.   - platform: pid
  234.     name: "PID Climate Heat"
  235.     id: pid_climate_heat
  236.     type: HEAT
  237.     accuracy_decimals: 6
  238.   - platform: pid
  239.     name: "PID Climate Kp"
  240.     type: KP
  241.     accuracy_decimals: 6
  242.   - platform: pid
  243.     name: "PID Climate Ki"
  244.     type: KI
  245.     accuracy_decimals: 6
  246.   - platform: pid
  247.     name: "PID Climate Kd"
  248.     type: KD
  249.     accuracy_decimals: 6
  250.   - platform: uptime
  251.     name: Opentherm Uptime
  252.     id: ot_uptime
  253.     update_interval: 60s
  254.     entity_category: "diagnostic"
  255.   - platform: template
  256.     name: "Boiler Setpoint"
  257.     id: pid_setpoint
  258.     unit_of_measurement: "°C"
  259.     icon: "mdi:fire"
  260.     device_class: "temperature"
  261.     state_class: "measurement"
  262.     accuracy_decimals: 2
  263.     update_interval: 10s
  264.     lambda: return id(boiler_setpoint).state;
  265.  
  266. binary_sensor:
  267. # Not all opentherm sensors provided by the opentherm component are implemented by each boiler manufacturer
  268. # Non-working sensors seem to report zero rather than not available in both sensors and binary_sensors
  269.   - platform: opentherm
  270.     fault_indication:
  271.       name: "Boiler Fault indication"
  272.     ch_active:
  273.       name: "Boiler Central Heating active"
  274.     dhw_active:
  275.       name: "Boiler Domestic Hot Water active"
  276.     flame_on:
  277.       name: "Boiler Flame on"
  278.     diagnostic_indication:
  279.       name: "Boiler Diagnostic event"
  280. #    dhw_present:
  281. #      name: "Boiler DHW present"
  282. #    control_type_on_off:
  283. #      name: "Boiler Control type is on/off"
  284. #    dhw_storage_tank:
  285. #      name: "Boiler DHW storage tank"
  286. #    master_pump_control_allowed:
  287. #      name: "Boiler Master pump control allowed"
  288. #    dhw_setpoint_transfer_enabled:
  289. #      name: "Boiler DHW setpoint transfer enabled"
  290. #    max_ch_setpoint_transfer_enabled:
  291. #      name: "Boiler CH maximum setpoint transfer enabled"
  292. #    dhw_setpoint_rw:
  293. #      name: "Boiler DHW setpoint read/write"
  294. #    max_ch_setpoint_rw:
  295. #     name: "Boiler CH maximum setpoint read/write"
  296.     service_request:
  297.       name: "Service Request"
  298.     lockout_reset:
  299.       name: "Lockout Reset"
  300.     low_water_pressure:
  301.       name: "Low Water Pressure"
  302.     flame_fault:
  303.       name: "Gas/Flame Fault"
  304.     air_pressure_fault:
  305.       name: "Air Pressure Fault"
  306.     water_over_temp:
  307.       name: "Water Over Temp"
  308.  
  309.  
  310. switch:
  311.   - platform: opentherm
  312.     ch_enable:
  313.       name: "Boiler Central Heating enabled"
  314.       restore_mode: RESTORE_DEFAULT_ON
  315.     dhw_enable:
  316.       name: "Boiler Domestic Hot Water enabled"
  317.       restore_mode: RESTORE_DEFAULT_ON
  318.     cooling_enable:
  319.       name: "Boiler Cooling enabled"
  320.       restore_mode: RESTORE_DEFAULT_OFF
  321.     otc_active:
  322.       name: "Boiler Outside temperature compensation active"
  323.       restore_mode: RESTORE_DEFAULT_OFF
  324.     ch2_active:
  325.       name: "Boiler Central Heating 2 active"
  326.       restore_mode: RESTORE_DEFAULT_OFF
  327.   - platform: restart
  328.     name: "Opentherm Restart"
  329.  
  330. climate:
  331.   - platform: pid
  332.     id: central_heating_ot
  333.     name: "Central heating OT"
  334.     heat_output: boiler_setpoint
  335.     default_target_temperature: 20.4
  336.     sensor: t_room
  337.     control_parameters:
  338. # Suggested default: kp: 0.7 ki: 0.003 kd: 0.0
  339. # previous 23/1/24  kp: 0.6790622 ki: 0.0003784035 kd: 304.652
  340. # autotune 23/1 kp: 0.949 ki: 0.00021 kd: 1052
  341. # autotune 25/3 kp: 0.90407 ki: 0.00006 kd: 3196.35376
  342.       kp: 2
  343.       ki: 0.00003
  344.       kd: 0.9
  345. #      min_integral: 0
  346. #      max_integral: 0.25
  347. #      starting_integral_term: 0
  348.       output_averaging_samples: 2
  349.       derivative_averaging_samples: 8
  350.     deadband_parameters:
  351.       threshold_high: 0.5
  352.       threshold_low: -0.3
  353.       kp_multiplier: 0.05
  354.       ki_multiplier: 0.05
  355.       kd_multiplier: 0.0
  356.       deadband_output_averaging_samples: 20
  357.     visual:
  358.       min_temperature: 10
  359.       max_temperature: 23
  360.       temperature_step: 0.1
  361.  
  362. button:
  363.   - platform: template
  364.     name: "PID Climate Autotune"
  365.     on_press:
  366.       - climate.pid.set_control_parameters:
  367.           id: central_heating_ot
  368.           kp: 0.0
  369.           ki: 0.0
  370.           kd: 0.0
  371.       - climate.pid.autotune: central_heating_ot
  372.   - platform: template
  373.     name: "Reset Integral term"
  374.     on_press:
  375.       - climate.pid.reset_integral_term: central_heating_ot
  376.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement