########################### ## 8 -- AUTOMATIONS # ########################### automation: ############################################################ ## 9 -- RECARGA ESTADO RELES DE LOS 2 TERMOSTATOS ## ############################################################ - alias: 'Control rele1 calef salon' initial_state: True hide_entity: false trigger: - platform: mqtt topic: tele/sonoff_b3/STATE condition: - condition: state entity_id: switch.sonoff_b3_1 state: 'off' - condition: template value_template: '{{trigger.payload_json.POWER1 == "ON"}}' action: - service: mqtt.publish data: topic: "stat/sonoff_b3/POWER1" payload: "ON" - alias: 'Control rele2 calef salon' initial_state: True hide_entity: false trigger: - platform: mqtt topic: tele/sonoff_b3/STATE condition: - condition: state entity_id: switch.sonoff_b3_2 state: 'off' - condition: template value_template: '{{trigger.payload_json.POWER2 == "ON"}}' action: - service: mqtt.publish data: topic: "stat/sonoff_b3/POWER2" payload: "ON" ###################################################################### ## 10 -- REVISION DEL RELE DEL DIGITAL SEGUN ESTADO DEL CLIMATE ## ###################################################################### - alias: 'Termostato Fisico salon' initial_state: True hide_entity: false trigger: - platform: homeassistant event: start - platform: state entity_id: climate.radiador_salon - platform: time_pattern minutes: '/5' # seconds: 00 action: - delay: 00:00:30 - service_template: >- {%- if (states.climate.radiador_salon.attributes.hvac_action == 'heating') or (states.climate.radiador_salon.attributes.hvac_action == 'idle') or is_state('binary_sensor.door_window_sensor_158d00020439ac', 'on') or is_state('binary_sensor.door_window_sensor_158d0001c224d0', 'on') or is_state('binary_sensor.door_window_sensor_158d0002043a10', 'on') %} switch.turn_on {%- elif (states.climate.radiador_salon.attributes.hvac_action == 'off') and is_state('binary_sensor.door_window_sensor_158d00020439ac', 'off') and is_state('binary_sensor.door_window_sensor_158d0001c224d0', 'off') and is_state('binary_sensor.door_window_sensor_158d0002043a10', 'off') %} switch.turn_off {% endif %} entity_id: switch.sonoff_b3_2 - delay: 00:00:05 - service_template: >- {%- if (states.climate.radiador_salon.attributes.hvac_action == 'idle') or (states.climate.radiador_salon.attributes.hvac_action == 'off') or is_state('binary_sensor.door_window_sensor_158d00020439ac', 'on') or is_state('binary_sensor.door_window_sensor_158d0001c224d0', 'on') or is_state('binary_sensor.door_window_sensor_158d0002043a10', 'on') %} switch.turn_off {%- elif (states.climate.radiador_salon.attributes.hvac_action == 'heating') and is_state('binary_sensor.door_window_sensor_158d00020439ac', 'off') and is_state('binary_sensor.door_window_sensor_158d0001c224d0', 'off') and is_state('binary_sensor.door_window_sensor_158d0002043a10', 'off') %} switch.turn_on {% endif %} entity_id: switch.sonoff_b3_1 ########################################### ## 11 -- CONTROL MODO MANUAL ## ########################################### - alias: 'Manual On - Auto OFF' initial_state: True hide_entity: false trigger: - platform: state entity_id: input_boolean.activar_manual from: 'off' to: 'on' action: - service: input_boolean.turn_off entity_id: input_boolean.activar_auto, input_boolean.modo_vacaciones - delay: 00:00:02 - service: automation.trigger entity_id: automation.recargar_temperaturas - service_template: >- {%- if ( states.binary_sensor.door_window_sensor_158d0001c224d0.state == 'off') and (states.binary_sensor.door_window_sensor_158d00020439ac.state == 'off') and (states.binary_sensor.door_window_sensor_158d0002043a10.state == 'off') %} climate.turn_on {%- else %} homeassistant.update_entity {% endif %} entity_id: climate.radiador_salon ########################################### ## 12 -- APAGADO DE CLIMATE ## ########################################### - alias: 'Desactivar Climate' initial_state: True hide_entity: false trigger: - platform: state entity_id: input_boolean.activar_manual, input_boolean.activar_auto, input_boolean.modo_vacaciones from: 'on' to: 'off' action: - service_template: >- {%- if is_state('input_boolean.modo_vacaciones', 'off') and is_state('input_boolean.activar_auto', 'off') and is_state('input_boolean.activar_manual', 'off')%} climate.turn_off {% endif %} entity_id: climate.radiador_salon ######################################################## ## 13 -- CLIMATE ACTIVO POR CIERRE PUERTA/VENTANA ## ######################################################## - alias: 'Ventana cerrada + clima' initial_state: True hide_entity: false trigger: - platform: state entity_id: binary_sensor.door_window_sensor_158d00020439ac from: 'on' to: 'off' for: minutes: 2 # seconds: 10 - platform: state entity_id: binary_sensor.door_window_sensor_158d0001c224d0 from: 'on' to: 'off' for: minutes: 2 - platform: state entity_id: binary_sensor.door_window_sensor_158d0002043a10 from: 'on' to: 'off' for: minutes: 2 condition: - condition: or conditions: - condition: state entity_id: input_boolean.activar_auto state: 'on' - condition: state entity_id: input_boolean.activar_manual state: 'on' - condition: state entity_id: input_boolean.modo_vacaciones state: 'on' action: - service: climate.turn_on entity_id: climate.radiador_salon - service: automation.trigger entity_id: automation.recargar_temperaturas ############################################################# ## 14 -- CLIMATE OFF POR APERTURA DE PUERTA/VENTANA ## ############################################################# - alias: 'Ventana Abierta Climate' initial_state: True hide_entity: false trigger: - platform: state entity_id: binary_sensor.door_window_sensor_158d00020439ac from: 'off' to: 'on' for: minutes: 2 # seconds: 10 - platform: state entity_id: binary_sensor.door_window_sensor_158d0001c224d0 from: 'off' to: 'on' for: minutes: 2 - platform: state entity_id: binary_sensor.door_window_sensor_158d0002043a10 from: 'off' to: 'on' for: minutes: 2 action: - service_template: >- {%- if (states.climate.radiador_salon.attributes.hvac_action == 'idle') or (states.climate.radiador_salon.attributes.hvac_action == 'heating')%} climate.turn_off {% endif %} entity_id: climate.radiador_salon - service: switch.turn_on entity_id: switch.sonoff_b3_2 ####################################################### ## 15 -- REINICIO DE CLIMATE POR REINICIO DE HA ## ####################################################### - alias: 'Restart HASS + Climate' initial_state: True hide_entity: false trigger: - platform: homeassistant event: start - platform: time_pattern minutes: '/5' # seconds: 00 condition: - condition: and conditions: - condition: state entity_id: binary_sensor.door_window_sensor_158d00020439ac state: 'off' - condition: state entity_id: binary_sensor.door_window_sensor_158d0001c224d0 state: 'off' - condition: state entity_id: binary_sensor.door_window_sensor_158d0002043a10 state: 'off' - condition: or conditions: - condition: state entity_id: input_boolean.activar_auto state: 'on' - condition: state entity_id: input_boolean.activar_manual state: 'on' - condition: state entity_id: input_boolean.modo_vacaciones state: 'on' action: - delay: 00:00:30 - service: climate.turn_on entity_id: climate.radiador_salon - delay: 00:00:10 - service: automation.trigger entity_id: automation.recargar_temperaturas ########################################### ## 16 -- MODO AUTO ON ## ########################################### - alias: 'Climate Auto On' initial_state: True hide_entity: false trigger: - platform: state entity_id: input_boolean.activar_auto from: 'off' to: 'on' action: - service: input_boolean.turn_off entity_id: input_boolean.activar_manual, input_boolean.modo_vacaciones - service: automation.trigger entity_id: automation.recargar_temperaturas - service_template: >- {%- if ( states.binary_sensor.door_window_sensor_158d0001c224d0.state == 'off') and (states.binary_sensor.door_window_sensor_158d00020439ac.state == 'off') and (states.binary_sensor.door_window_sensor_158d0002043a10.state == 'off') %} climate.turn_on {%- else %} homeassistant.update_entity {% endif %} entity_id: climate.radiador_salon ########################################### ## 17 -- MODO FUERA/NO PROGRAMADO ON ## ########################################### - alias: 'Modo vacaciones ON' initial_state: True hide_entity: false trigger: - platform: state entity_id: input_boolean.modo_vacaciones from: 'off' to: 'on' action: - service: input_boolean.turn_off entity_id: input_boolean.activar_auto, input_boolean.activar_manual - delay: 00:00:02 - service: automation.trigger entity_id: automation.recargar_temperaturas - service_template: >- {%- if ( states.binary_sensor.door_window_sensor_158d0001c224d0.state == 'off') and (states.binary_sensor.door_window_sensor_158d00020439ac.state == 'off') and (states.binary_sensor.door_window_sensor_158d0002043a10.state == 'off') %} climate.turn_on {%- else %} homeassistant.update_entity {% endif %} entity_id: climate.radiador_salon ########################################################### ## 18 -- RECARGAR TEMPERATURAS Y HORARIOS DEFINIDOS ## ########################################################### - alias: 'recargar temperaturas' initial_state: True hide_entity: false trigger: - platform: homeassistant event: start - platform: time_pattern minutes: '/5' # seconds: 00 - platform: state entity_id: input_number.temp_modo_fuera_noprog, input_number.modo_manual - platform: state entity_id: input_number.temp_prog_1_w, input_number.p1_horas_w_on, input_number.p1_minutos_w_on, input_number.p1_horas_w_off, input_number.p1_minutos_w_off - platform: state entity_id: input_number.temp_prog_2_w, input_number.p2_horas_w_on, input_number.p2_minutos_w_on, input_number.p2_horas_w_off, input_number.p2_minutos_w_off - platform: state entity_id: input_number.temp_prog_3_w, input_number.p3_horas_w_on, input_number.p3_minutos_w_on, input_number.p3_horas_w_off, input_number.p3_minutos_w_off - platform: state entity_id: input_number.temp_prog_4_w, input_number.p4_horas_w_on, input_number.p4_minutos_w_on, input_number.p4_horas_w_off, input_number.p4_minutos_w_off - platform: state entity_id: input_number.temp_prog_1_f, input_number.p1_horas_f_on, input_number.p1_minutos_f_on, input_number.p1_horas_f_off, input_number.p1_minutos_f_off - platform: state entity_id: input_number.temp_prog_2_f, input_number.p2_horas_f_on, input_number.p2_minutos_f_on, input_number.p2_horas_f_off, input_number.p2_minutos_f_off - platform: state entity_id: input_boolean.p1_finde_on, input_boolean.p2_finde_on, input_boolean.p1_work_on, input_boolean.p2_work_on, input_boolean.p3_work_on, input_boolean.p4_work_on action: - delay: 00:00:10 - service: climate.set_temperature entity_id: climate.radiador_salon data_template: temperature: >- {%- if is_state('input_boolean.p1_work_on', 'on') and is_state('binary_sensor.workday_sensor', 'on') and is_state('input_boolean.modo_vacaciones', 'off') and is_state('input_boolean.activar_manual', 'off') and (states('sensor.minutos_on') | int > states('sensor.sensor_p1_w_on')|int) and (states('sensor.minutos_on') | int < states('sensor.sensor_p1_w_off')|int) %} {{ states.input_number.temp_prog_1_w.state }} {%- elif is_state('input_boolean.p2_work_on', 'on') and is_state('binary_sensor.workday_sensor', 'on') and is_state('input_boolean.modo_vacaciones', 'off') and is_state('input_boolean.activar_manual', 'off') and (states('sensor.minutos_on') | int > states('sensor.sensor_p2_w_on')|int) and (states('sensor.minutos_on') | int < states('sensor.sensor_p2_w_off')|int) %} {{ states.input_number.temp_prog_2_w.state }} {%- elif is_state('input_boolean.p3_work_on', 'on') and is_state('binary_sensor.workday_sensor', 'on') and is_state('input_boolean.modo_vacaciones', 'off') and is_state('input_boolean.activar_manual', 'off') and (states('sensor.minutos_on') | int > states('sensor.sensor_p3_w_on')|int) and (states('sensor.minutos_on') | int < states('sensor.sensor_p3_w_off')|int) %} {{ states.input_number.temp_prog_3_w.state }} {%- elif is_state('input_boolean.p4_work_on', 'on') and is_state('binary_sensor.workday_sensor', 'on') and is_state('input_boolean.modo_vacaciones', 'off') and is_state('input_boolean.activar_manual', 'off') and (states('sensor.minutos_on') | int > states('sensor.sensor_p4_w_on')|int) and (states('sensor.minutos_on') | int < states('sensor.sensor_p4_w_off')|int) %} {{ states.input_number.temp_prog_4_w.state }} {%- elif is_state('input_boolean.p1_finde_on', 'on') and is_state('binary_sensor.workday_sensor', 'off') and is_state('input_boolean.modo_vacaciones', 'off') and is_state('input_boolean.activar_manual', 'off') and (states('sensor.minutos_on') | int > states('sensor.sensor_p1_finde_on')|int) and (states('sensor.minutos_on') | int < states('sensor.sensor_p1_finde_off')|int) %} {{ states.input_number.temp_prog_1_f.state }} {%- elif is_state('input_boolean.p2_finde_on', 'on') and is_state('binary_sensor.workday_sensor', 'off') and is_state('input_boolean.modo_vacaciones', 'off') and is_state('input_boolean.activar_manual', 'off') and (states('sensor.minutos_on') | int > states('sensor.sensor_p2_finde_on')|int) and (states('sensor.minutos_on') | int < states('sensor.sensor_p2_finde_off')|int) %} {{ states.input_number.temp_prog_2_f.state}} {%- elif is_state('input_boolean.activar_manual', 'on') %} {{ states.input_number.modo_manual.state }} {% else %} {{ states.input_number.temp_modo_fuera_noprog.state }} {% endif %}