Hi guys,
I hope someone will be able to help me
I’m trying to modify my automation in order to select a different value depending on a switch state…
If in heat mode, I will use the heateing temperature and if in cool mode, I will use the cooling temperature !
Here is the code I’m trying to adapt:
- id: heating2_timerswitch_on_choose_temp
alias: Heating Chambres when enabling timer or restoring from away select the appropriate temperature
trigger:
- platform: state
entity_id: "input_boolean.heating_timer_switch"
to: "on"
- platform: template
value_template: "{{ not is_state_attr('climate.thermostat_chambres', 'preset_mode', 'away') }}"
mode: single
max_exceeded: silent
action:
- choose:
- conditions:
- condition: template
value_template: >
{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}
{% set time_start = state_attr('input_datetime.heating_weekday_morning_start','timestamp') %}
{% set time_end = state_attr('input_datetime.heating_weekday_day_start','timestamp') %}
{{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'on')}}
sequence:
- service: climate.set_temperature
data_template:
entity_id: climate.thermostat_chambres
temperature: "{{ states('input_number.heating_temp2_morning') }}"
- conditions:
- condition: template
value_template: >
{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}
{% set time_start = state_attr('input_datetime.heating_weekday_day_start','timestamp') %}
{% set time_end = state_attr('input_datetime.heating_weekday_evening_start','timestamp') %}
{{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'on')}}
sequence:
- service: climate.set_temperature
data_template:
entity_id: climate.thermostat_chambres
temperature: "{{ states('input_number.heating_temp2_day') }}"
- conditions:
- condition: template
value_template: >
{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}
{% set time_start = state_attr('input_datetime.heating_weekday_evening_start','timestamp') %}
{% set time_end = state_attr('input_datetime.heating_weekday_night_start','timestamp') %}
{{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'on')}}
sequence:
- service: climate.set_temperature
data_template:
entity_id: climate.thermostat_chambres
temperature: "{{ states('input_number.heating_temp2_evening') }}"
- conditions:
- condition: template
value_template: >
{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}
{% set time_start = state_attr('input_datetime.heating_weekday_night_start','timestamp') %}
{% set time_end = state_attr('input_datetime.heating_weekday_morning_start','timestamp') %}
{{ (time_start <= t < 86400 or 0 <= t < time_end) and is_state('binary_sensor.workday_sensor', 'on')}}
sequence:
- service: climate.set_temperature
data_template:
entity_id: climate.thermostat_chambres
temperature: "{{ states('input_number.heating_temp2_night') }}"
- choose:
- conditions:
- condition: template
value_template: >
{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}
{% set time_start = state_attr('input_datetime.heating_weekend_morning_start','timestamp') %}
{% set time_end = state_attr('input_datetime.heating_weekend_day_start','timestamp') %}
{{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'off')}}
sequence:
- service: climate.set_temperature
data_template:
entity_id: climate.thermostat_chambres
temperature: "{{ states('input_number.heating_temp2_morning') }}"
- conditions:
- condition: template
value_template: >
{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}
{% set time_start = state_attr('input_datetime.heating_weekend_day_start','timestamp') %}
{% set time_end = state_attr('input_datetime.heating_weekend_evening_start','timestamp') %}
{{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'off')}}
sequence:
- service: climate.set_temperature
data_template:
entity_id: climate.thermostat_chambres
temperature: "{{ states('input_number.heating_temp2_day') }}"
- conditions:
- condition: template
value_template: >
{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}
{% set time_start = state_attr('input_datetime.heating_weekend_evening_start','timestamp') %}
{% set time_end = state_attr('input_datetime.heating_weekend_night_start','timestamp') %}
{{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'off')}}
sequence:
- service: climate.set_temperature
data_template:
entity_id: climate.thermostat_chambres
temperature: "{{ states('input_number.heating_temp2_evening') }}"
- conditions:
- condition: template
value_template: >
{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}
{% set time_start = state_attr('input_datetime.heating_weekend_night_start','timestamp') %}
{% set time_end = state_attr('input_datetime.heating_weekend_morning_start','timestamp') %}
{{ (time_start <= t < 86400 or 0 <= t < time_end) and is_state('binary_sensor.workday_sensor', 'off')}}
sequence:
- service: climate.set_temperature
data_template:
entity_id: climate.thermostat_chambres
temperature: "{{ states('input_number.heating_temp2_night') }}"
For every “condition: template”, I would like to add another condition:
- condition: numeric_state
entity_id: input_select.thermostat_mode
value_template: heat
Tryed to do this, but not working:
- conditions:
- condition: template
value_template: >
{% set t = strptime((now().timestamp() | timestamp_local), "%Y-%m-%d %H:%M:%S").timestamp()-strptime(now().strftime("%Y-%m-%d 00:00:00"),"%Y-%m-%d %H:%M:%S").timestamp() %}
{% set time_start = state_attr('input_datetime.heating_weekend_morning_start','timestamp') %}
{% set time_end = state_attr('input_datetime.heating_weekend_day_start','timestamp') %}
{{ time_start <= t < time_end and is_state('binary_sensor.workday_sensor', 'off')}}
- condition: numeric_state
entity_id: input_select.thermostat_mode
value_template: heat
sequence:
- service: climate.set_temperature
data_template:
entity_id: climate.thermostat_chambres
temperature: "{{ states('input_number.heating_temp2_morning') }}"
So if in heat mode => choose this temperature from this input, and if in cool mode => choose this temperature from this input…
If someone as an idea would be really appreciated
Thanks,