Shcherban

Untitled

Jan 25th, 2021
530
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Config.yaml:
  2. climate:
  3. #
  4.   - platform: mqtt
  5.     modes:
  6.      - "off"
  7.       - "heat"
  8.     name: Dormitor HVAC
  9.     current_temperature_topic: "HVAC/dormitor/ct"
  10.     mode_command_topic: "HVAC/dormitor/mode/set"
  11.     temperature_command_topic: "HVAC/dormitor/st"
  12.     min_temp: 12
  13.     max_temp: 26
  14.     value_template: "{{ value }}"
  15.     temp_step: 0.5
  16. #
  17.   - platform: mqtt
  18.     modes:
  19.      - "off"
  20.       - "heat"
  21.     name: Copii HVAC
  22.     current_temperature_topic: "HVAC/copii/ct"
  23.     mode_command_topic: "HVAC/copii/mode/set"
  24.     temperature_command_topic: "HVAC/copii/st"
  25.     min_temp: 12
  26.     max_temp: 26
  27.     value_template: "{{ value }}"
  28.     temp_step: 0.5
  29. #
  30.   - platform: mqtt
  31.     modes:
  32.      - "off"
  33.       - "heat"
  34.     name: Sufragerie HVAC
  35.     current_temperature_topic: "HVAC/sufragerie/ct"
  36.     mode_command_topic: "HVAC/dormitor/sufragerie/set"
  37.     temperature_command_topic: "HVAC/sufragerie/st"
  38.     min_temp: 12
  39.     max_temp: 26
  40.     value_template: "{{ value }}"
  41.     temp_step: 0.5
  42. #
  43. binary_sensor:
  44. #
  45.   - platform: mqtt
  46.     name: copii_geam
  47.     state_topic: 'zigbee2mqtt/Copii_geam'
  48.     value_template: "{{ value_json.contact }}"
  49.     payload_on: false
  50.     payload_off: true
  51.     qos: 0
  52.     retain: true
  53. #
  54.   - platform: mqtt
  55.     name: dormitor_geam
  56.     state_topic: 'zigbee2mqtt/Dormitor_geam'
  57.     value_template: "{{ value_json.contact }}"
  58.     payload_on: false
  59.     payload_off: true
  60.     qos: 0
  61.     retain: true
  62. #
  63.   - platform: mqtt
  64.     name: sufragerie_geam
  65.     state_topic: 'zigbee2mqtt/Sufragerie_geam'
  66.     value_template: "{{ value_json.contact }}"
  67.     payload_on: false
  68.     payload_off: true
  69.     qos: 0
  70.     retain: true
  71. #
  72.  
  73.  
  74.  
  75. Automations:
  76. #
  77. - alias: temp_dormitor
  78.   trigger:
  79.     - platform: state
  80.       entity_id: sensor.0x00158d000465809a_temperature
  81.   action:
  82.     service: mqtt.publish
  83.     data:
  84.       payload: "{{ states('sensor.0x00158d000465809a_temperature') }}"
  85.       topic: "HVAC/dormitor/ct"
  86.       qos: 0
  87.       retain: true
  88. #
  89. - alias: temp_copii
  90.   trigger:
  91.     - platform: state
  92.       entity_id: sensor.0x00158d000464b329_temperature
  93.   action:
  94.     service: mqtt.publish
  95.     data:
  96.       payload: "{{ states('sensor.0x00158d000464b329_temperature') }}"
  97.       topic: "HVAC/copii/ct"
  98.       qos: 0
  99.       retain: true
  100. #
  101. - alias: temp_sufragerie
  102.   trigger:
  103.     - platform: state
  104.       entity_id: sensor.0x00158d00045d01f4_temperature
  105.   action:
  106.     service: mqtt.publish
  107.     data:
  108.       payload: "{{ states('sensor.0x00158d00045d01f4_temperature') }}"
  109.       topic: "HVAC/sufragerie/ct"
  110.       qos: 0
  111.       retain: true
  112. #
  113. - alias: trv_copii
  114.   trigger:
  115.   - platform: state
  116.     entity_id: climate.copii_hvac, sensor.0x00158d000464b329_temperature, binary_sensor.copii_geam
  117.   action:
  118.   - service: mqtt.publish
  119.     data:
  120.       payload_template: >-
  121.         {% set targetTemp = state_attr('climate.copii_hvac', 'temperature') %}
  122.         {% set currentTemp = states('sensor.0x00158d000464b329_temperature') %}
  123.         {% set window = states('binary_sensor.copii_geam') %}
  124.         {% if targetTemp == None or currentTemp == None or currentTemp == 'unknown' or window == None %}
  125.             {{ {"system_mode": "heat"} }}
  126.         {% else %}
  127.           {% if targetTemp|float > currentTemp|float and window == 'off' %}
  128.             {{ {"system_mode": "heat"} }}
  129.           {% else %}
  130.             {{ {"system_mode": "off"} }}
  131.           {% endif %}
  132.         {% endif %}
  133.       topic: "zigbee2mqtt/Copii/set"
  134.   - event: FIRE_OT_RECALC_EVENT
  135. #
  136. - alias: trv_dormitor
  137.   trigger:
  138.   - platform: state
  139.     entity_id: climate.dormitor_hvac, sensor.0x00158d000465809a_temperature, binary_sensor.dormitor_geam
  140.   action:
  141.   - service: mqtt.publish
  142.     data:
  143.       payload_template: >-
  144.         {% set targetTemp = state_attr('climate.dormitor_hvac', 'temperature') %}
  145.         {% set currentTemp = states('sensor.0x00158d000465809a_temperature') %}
  146.         {% set window = states('binary_sensor.dormitor_geam') %}
  147.         {% if targetTemp == None or currentTemp == None or currentTemp == 'unknown' or window == None %}
  148.             {{ {"system_mode": "heat"} }}
  149.         {% else %}
  150.           {% if targetTemp|float > currentTemp|float and window == 'off' %}
  151.             {{ {"system_mode": "heat"} }}
  152.           {% else %}
  153.             {{ {"system_mode": "off"} }}
  154.           {% endif %}
  155.         {% endif %}
  156.       topic: "zigbee2mqtt/Dormitor/set"
  157.   - event: FIRE_OT_RECALC_EVENT
  158. #
  159. - alias: trv_sufragerie
  160.   trigger:
  161.   - platform: state
  162.     entity_id: climate.sufragerie_hvac, sensor.0x00158d00045d01f4_temperature, binary_sensor.sufragerie_geam
  163.   action:
  164.   - service: mqtt.publish
  165.     data:
  166.       payload_template: >-
  167.         {% set targetTemp = state_attr('climate.sufragerie_hvac', 'temperature') %}
  168.         {% set currentTemp = states('sensor.0x00158d00045d01f4_temperature') %}
  169.         {% set window = states('binary_sensor.sufragerie_geam') %}
  170.         {% if targetTemp == None or currentTemp == None or currentTemp == 'unknown' or window == None %}
  171.             {{ {"system_mode": "heat"} }}
  172.         {% else %}
  173.           {% if targetTemp|float > currentTemp|float and window == 'off' %}
  174.             {{ {"system_mode": "heat"} }}
  175.           {% else %}
  176.             {{ {"system_mode": "off"} }}
  177.           {% endif %}
  178.         {% endif %}
  179.       topic: "zigbee2mqtt/Sufragerie/set"
  180.   - event: FIRE_OT_RECALC_EVENT
  181. #
  182. - alias: OpenTherm Calculation
  183.   trigger:
  184.     - platform: event
  185.       event_type: FIRE_OT_RECALC_EVENT
  186.   action:
  187.     - service: mqtt.publish
  188.       data:
  189.         payload_template: >-
  190.           {% set targetTemp1 = state_attr('climate.dormitor_hvac', 'temperature') %}
  191.           {% set currentTemp1 = states('sensor.0x00158d000465809a_temperature') %}
  192.           {% set window1 = states('binary_sensor.dormitor_geam') %}
  193.           {% set targetTemp2 = state_attr('climate.copii_hvac', 'temperature') %}
  194.           {% set currentTemp2 = states('sensor.0x00158d000464b329_temperature') %}
  195.           {% set window2 = states('binary_sensor.copii_geam') %}
  196.           {% set targetTemp3 = state_attr('climate.sufragerie_hvac', 'temperature') %}
  197.           {% set currentTemp3 = states('sensor.0x00158d00045d01f4_temperature') %}
  198.           {% set window3 = states('binary_sensor.sufragerie_geam') %}
  199.           {% if targetTemp1|float > currentTemp1|float and window1 == 'off' %}
  200.             {% set result1 = targetTemp1 %}
  201.           {% else %}
  202.             {% set result1 = '30' %}
  203.           {% endif %}
  204.           {% if targetTemp2|float > currentTemp2|float and window2 == 'off' %}
  205.             {% set result2 = targetTemp2 %}
  206.           {% else %}
  207.             {% set result2 = '30' %}
  208.           {% endif %}
  209.           {% if targetTemp3|float > currentTemp3|float and window3 == 'off' %}
  210.             {% set result3 = targetTemp3 %}
  211.           {% else %}
  212.             {% set result3 = '30' %}
  213.           {% endif %}
  214.           {% if result1 == [result1|float, result2|float, result3|float]|min and result1 < 30 %}
  215.             {% set result = (targetTemp1,currentTemp1|float) %}
  216.           {% else %}
  217.             {% if result2 == [result1|float, result2|float, result3|float]|min and result2 < 30 %}
  218.               {% set result = (targetTemp2,currentTemp2|float) %}
  219.             {% else %}
  220.               {% if result3 == [result1|float, result2|float, result3|float]|min and result3 < 30 %}
  221.                 {% set result = (targetTemp3,currentTemp3|float) %}
  222.               {% else %}
  223.                 {% set result = (1.0,20.0) %}
  224.               {% endif%}
  225.             {% endif %}
  226.           {% endif %}
  227.           {{ result }}
  228.       topic: "HVAC/otresult"
  229.       retain: true
  230. #
  231. - alias: OpenTherm Force Recalc
  232.   trigger:
  233.     - platform: time_pattern
  234.       seconds: "/20"
  235.   action:
  236.     - event: FIRE_OT_RECALC_EVENT
  237. #
  238. - alias: OpenTherm Send
  239.   trigger:
  240.     - platform: mqtt
  241.       topic: "HVAC/otresult"
  242.   action:
  243.     - service: mqtt.publish
  244.       data: trigger.data.split(',')[0]
  245.       topic: "opentherm-thermostat/setpoint-temperature/set"
  246.       retain: false
  247.       qos: 0
  248.     - service: mqtt.publish
  249.       data: trigger.data.split(',')[1]
  250.       topic: "opentherm-thermostat/current-temperature/set"
  251.       retain: false
  252.       qos: 0
RAW Paste Data