Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 9.37 KB | None | 0 0
  1. automation:
  2.  ############################################## HEATING ##############################################
  3.   # Restart OTGW-MQTT if offline
  4.   - alias: Restart OTGW-MQTT if offline
  5.     hide_entity: false
  6.     initial_state: false
  7.     trigger:
  8.     - entity_id: binary_sensor.otgw_mqtt
  9.       platform: state
  10.       from: 'on'
  11.       to: 'off'
  12.     action:
  13.     - service: script.restart_otgw_mqtt_service
  14.   # Set DHW temp on slider change
  15.   - alias: Set DHW temp on slider change
  16.     hide_entity: true
  17.     initial_state: true
  18.     trigger:
  19.       platform: state
  20.       entity_id: input_number.dhw_setpoint
  21.     condition:
  22.       condition: state
  23.       entity_id: input_boolean.away_mode
  24.       state: 'off'
  25.     action:
  26.       service: script.set_home_dhw_setpoint
  27.  
  28.   # Restart OTGW-MQTT periodicaly
  29.   - alias: Restart OTGW-MQTT periodicaly
  30.     hide_entity: false
  31.     initial_state: false
  32.     trigger:
  33.       platform: time_pattern
  34.       minutes: /5
  35.       seconds: '0'
  36.     condition:
  37.       condition: state
  38.       entity_id: binary_sensor.otgw_esp
  39.       state: 'on'
  40.     action:
  41.     - service: script.restart_otgw_mqtt_service
  42.   # OTGW-MQTT offline notification
  43.   - alias: OTGW-MQTT offline notification
  44.     hide_entity: true
  45.     initial_state: true
  46.     trigger:
  47.       platform: state
  48.       entity_id: binary_sensor.otgw_mqtt
  49.       to: 'off'
  50.       for: '00:10:00'
  51.     action:
  52.     - service: notify.my_homeassistant_samsung
  53.       data:
  54.         message: "Alert! Serwis OTGW-MQTT jest niedostępny od 10 minut"
  55.         data:
  56.           priority: high
  57.           url: /lovelace/heating
  58.     - service: input_boolean.turn_on
  59.       entity_id: input_boolean.otgw_failure_detected
  60.     - service: shell_command.run_heating_diagnostics
  61.   # Restart OTGW-MQTT if esp online
  62.   - alias: Restart OTGW-MQTT if esp online
  63.     hide_entity: false
  64.     initial_state: true
  65.     trigger:
  66.       platform: state
  67.       entity_id: binary_sensor.otgw_esp
  68.       to: 'on'
  69.     action:
  70.       service: script.full_restart_otgw_mqtt_service
  71.   # Stop OTGW-MQTT if esp offline
  72.   - alias: Stop OTGW-MQTT if esp offline
  73.     hide_entity: false
  74.     initial_state: true
  75.     trigger:
  76.       platform: state
  77.       entity_id: binary_sensor.otgw_esp
  78.       to: 'off'
  79.     action:
  80.       service: script.stop_otgw_mqtt_service
  81.   # Set CH temp on slider change
  82.   - alias: Set CH temp on slider change
  83.     hide_entity: true
  84.     initial_state: true
  85.     trigger:
  86.       platform: state
  87.       entity_id: input_number.ch_setpoint
  88.     action:
  89.       service: script.set_ch_setpoint
  90.   # Restart OTGW-MQTT periodicaly Full
  91.   - alias: Restart OTGW-MQTT periodicaly full
  92.     hide_entity: false
  93.     initial_state: true
  94.     trigger:
  95.       platform: time_pattern
  96.       minutes: /30
  97.       seconds: '30'
  98.     condition:
  99.       condition: state
  100.       entity_id: binary_sensor.otgw_esp
  101.       state: 'on'
  102.     action:
  103.     - service: script.full_restart_otgw_mqtt_service
  104.   #Turn on heating
  105.   - alias: Turn on heating
  106.     hide_entity: true
  107.     initial_state: true
  108.     trigger:
  109.       platform: template
  110.       value_template: "{% if states('sensor.lowest_temp') | float < states('sensor.tech_home_away_temp_setpoint') | float - 0.2 %}true{% endif %}"
  111.     condition:
  112.       - condition: state
  113.         entity_id: input_select.set_heat_or_not
  114.         state: 'Tak'
  115.     action:
  116.       service: script.ch_enable
  117.   #Turn off heating
  118.   - alias: Turn off heating
  119.     hide_entity: true
  120.     initial_state: true
  121.     trigger:
  122.       platform: template
  123.       value_template: "{% if states('sensor.lowest_temp') | float >= states('sensor.tech_home_away_temp_setpoint') | float + 0.2 %}true{% endif %}"
  124.     action:
  125.       service: script.ch_disable
  126.   # Heating watchdog
  127.   - alias: Heating watchdog
  128.     hide_entity: true
  129.     initial_state: true
  130.     trigger:
  131.       platform: template
  132.       value_template: "{% if states('sensor.lowest_temp') | float >= states('sensor.tech_home_away_temp_setpoint') | float + 0.5 %}true{% endif %}"
  133.     condition:
  134.       condition: state
  135.       entity_id: sensor.boiler_current_mode
  136.       state: 'Ogrzewanie'
  137.     action:
  138.       service: mqtt.publish
  139.       data:
  140.         topic: "otgw/set/central_heating/control_setpoint"
  141.         payload: "0"
  142.   # Set heating on slider change
  143.   - alias: Set heating on slider change
  144.     hide_entity: true
  145.     initial_state: true
  146.     trigger:
  147.       platform: state
  148.       entity_id: input_number.home_temp_setpoint
  149.     action:
  150.       service: script.check_and_heat
  151.  
  152.   # Automatic OTGW recovery
  153.   - alias: Automatic OTGW recovery
  154.     hide_entity: false
  155.     trigger:
  156.       platform: time_pattern
  157.       minutes: "/5"
  158.       seconds: 0
  159.     condition:
  160.     - condition: state
  161.       entity_id: input_boolean.otgw_failure_detected
  162.       state: 'on'
  163.     action:
  164.       - service: script.full_restart_otgw_mqtt_service
  165.   # OTGW-MQTT recovered detection
  166.   - alias: OTGW-MQTT recovered detection
  167.     hide_entity: true
  168.     initial_state: true
  169.     trigger:
  170.       platform: state
  171.       entity_id: binary_sensor.otgw_mqtt
  172.       from: 'off'
  173.       to: 'on'
  174.       for: '00:05:00'
  175.     action:
  176.     - service: input_boolean.turn_off
  177.       entity_id: input_boolean.otgw_failure_detected
  178.   # OTGW-MQTT recovered notification
  179.   - alias: OTGW-MQTT recovered notification
  180.     hide_entity: true
  181.     initial_state: true
  182.     trigger:
  183.       platform: state
  184.       entity_id: input_boolean.otgw_failure_detected
  185.       from: 'on'
  186.       to: 'off'
  187.     action:
  188.     - service: notify.my_homeassistant_samsung
  189.       data:
  190.         message: "Serwis OTGW-MQTT przywrócony automatycznie"
  191.         data:
  192.           priority: high
  193.           url: /lovelace/heating
  194.  
  195.  
  196. script:
  197.  ############################################ HEATING ############################################
  198.   #Set home DHW setpoint
  199.   set_home_dhw_setpoint:
  200.     sequence:
  201.       - service: mqtt.publish
  202.         data_template:
  203.           topic: "otgw/set/hot_water/temperature"
  204.           payload: "{{ states('input_number.dhw_setpoint') }}"
  205.   #Disable DHW
  206.   dhw_disable:
  207.     sequence:
  208.       - service: mqtt.publish
  209.         data:
  210.           topic: "otgw/set/hot_water/enable"
  211.           payload: "0"
  212.       - delay:
  213.           seconds: 2
  214.       - service: script.restart_otgw_mqtt_service
  215.       - delay:
  216.           seconds: 2
  217.   #Enable DHW
  218.   dhw_enable:
  219.     sequence:
  220.       - service: mqtt.publish
  221.         data:
  222.           topic: "otgw/set/hot_water/enable"
  223.           payload: "1"
  224.       - delay:
  225.           seconds: 2
  226.       - service: script.restart_otgw_mqtt_service
  227.       - delay:
  228.           seconds: 2
  229.   #Restart OTGW-MQTT service
  230.   restart_otgw_mqtt_service:
  231.     sequence:
  232.       - service: mqtt.publish
  233.         data:
  234.           topic: "otgw/restart"
  235.           payload: "1"
  236.   #Restart OTGW-MQTT service full
  237.   full_restart_otgw_mqtt_service:
  238.     sequence:
  239.       - service: mqtt.publish
  240.         data:
  241.           topic: "otgw/restart"
  242.           payload: "1"
  243.       - delay:
  244.           seconds: 5
  245.       - service: script.set_home_dhw_setpoint
  246.       - delay:
  247.           seconds: 1
  248.       - service: mqtt.publish
  249.         data_template:
  250.           topic: "otgw/set/hot_water/enable"
  251.           payload: >-
  252.             {% if is_state('input_boolean.away_mode', 'on') %}
  253.               0
  254.             {% else %}
  255.               1
  256.             {% endif %}
  257.       - delay:
  258.           seconds: 1
  259.       - service: script.set_ch_setpoint
  260.       - delay:
  261.           seconds: 1
  262.       - service: script.check_and_heat
  263.       - delay:
  264.           seconds: 2
  265.       - service: mqtt.publish
  266.         data:
  267.           topic: "otgw/restart"
  268.           payload: "1"
  269.   #Set CH setpoint
  270.   set_ch_setpoint:
  271.     sequence:
  272.       - service: mqtt.publish
  273.         data_template:
  274.           topic: "otgw/set/central_heating/setpoint"
  275.           payload: "{{ states('input_number.ch_setpoint') }}"
  276.   #Stop OTGW-MQTT service
  277.   stop_otgw_mqtt_service:
  278.     sequence:
  279.       - service: mqtt.publish
  280.         data:
  281.           topic: "otgw/stop"
  282.           payload: "1"
  283.   #Enable CH
  284.   ch_enable:
  285.     sequence:
  286.       - delay:
  287.           seconds: 2
  288.       - service: mqtt.publish
  289.         data:
  290.           topic: "otgw/set/central_heating/control_setpoint"
  291.           payload: "80"
  292.       - delay:
  293.           seconds: 2
  294.       - service: script.restart_otgw_mqtt_service
  295.   #Disable CH
  296.   ch_disable:
  297.     sequence:
  298.       - delay:
  299.           seconds: 2
  300.       - service: mqtt.publish
  301.         data:
  302.           topic: "otgw/set/central_heating/control_setpoint"
  303.           payload: "0"
  304.       - delay:
  305.           seconds: 2
  306.       - service: script.restart_otgw_mqtt_service
  307.   #Check and heat
  308.   check_and_heat:
  309.     sequence:
  310.       - service_template: >
  311.          {% if is_state('input_select.set_heat_or_not', 'Tak') %}
  312.             {% if states('sensor.lowest_temp') | float <= states('sensor.tech_home_away_temp_setpoint') | float - 0.2 %}
  313.               script.ch_enable
  314.             {% else %}
  315.               {% if states('sensor.lowest_temp') | float >= states('sensor.tech_home_away_temp_setpoint') | float + 0.2 %}
  316.                 script.ch_disable
  317.               {% else %}
  318.                 {% if is_state('sensor.boiler_current_mode', 'Ogrzewanie') %}
  319.                   script.ch_enable
  320.                 {% else %}
  321.                   script.ch_disable
  322.                 {% endif %}
  323.               {% endif %}
  324.             {% endif %}
  325.           {% else %}
  326.             script.ch_disable
  327.           {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement