Templating in conditions/triggers

Hello,

I have this automation for one of my climate devices:

- alias: 'kitchen_climate_weekend'
  trigger:
    platform: time
    seconds: '/1'
  condition:
        - condition: and
          conditions:
            - condition: state
              entity_id: sensor.tracker_family_presence
              state: 'on'   
            - condition: state
              entity_id: climate.neq1489832
              state: 'auto'                      
            - condition: state
              entity_id: sensor.climate_awaymode
              state: 'off'     
            - condition: template
              value_template: "{{ states.climate.neq1489832.attributes.temperature != states.input_slider.climate_livingroom_comfort_temperature.state }}"
            - condition: state
              entity_id: binary_sensor.neq0850976_state
              state: 'off'
            - condition: time             
              after: '08:30:00'
              before: '12:30:00'
              weekday:
              - sat
              - sun      
  action:
      - service: climate.set_temperature
        data:
          entity_id: climate.neq1489832
          temperature: !secret kitchen_climate_comfort_temperature  

As you can see I’m able to set the temperature via a input slider while HASS is running.

I know that it’s not possible to use templating in time conditions or time triggers. Is there any possibility to set time/days for my automation via input controls (slider, selects,…) - Even very hackish solutions are welcome :slight_smile:

Thanks in Advance!

This post may help you - it’s for an alarm clock based on input selects and sliders but the techniques are similar:

That’s my current approach:

  • alias: ‘livingroom_climate’
    trigger:
    platform: time
    seconds: ‘/1’
    condition:
    - condition: and
    conditions:
    - condition: state
    entity_id: ‘sensor.tracker_family_presence’
    state: ‘on’
    - condition: state
    entity_id: climate.neq1489811
    state: ‘auto’
    - condition: state
    entity_id: sensor.climate_awaymode
    state: ‘off’
    - condition: template
    value_template: “{{ states.climate.neq1489811.attributes.temperature != states.input_slider.climate_livingroom_comfort_temperature.state | int }}”
    - condition: state
    entity_id: binary_sensor.jmd4015744_state
    state: ‘off’
    - condition: and
    conditions:
    - condition: template
    value_template: “{{ states.input_slider.climate_livingroom_timer_hours_start.state | int == now().strftime(‘%H’) | int}}”
    - condition: template
    value_template: “{{ states.input_slider.climate_livingroom_timer_minutes_start.state | int == now().strftime(‘%M’) | int }}”

action:
- service: climate.set_temperature
data_template:
entity_id: climate.neq1489811
temperature: “{{ states.input_slider.climate_livingroom_comfort_temperature.state | int }}”
- service: mqtt.publish
data:
topic: ‘hass/climate/livingroom_active’
payload: ‘ON’
retain: ‘true’

  • alias: ‘livingroom_climate_off’
    trigger:
    platform: time
    seconds: ‘/1’
    condition:
    - condition: and
    conditions:
    - condition: state
    entity_id: ‘sensor.tracker_family_presence’
    state: ‘on’
    - condition: state
    entity_id: climate.neq1489811
    state: ‘auto’
    - condition: state
    entity_id: sensor.climate_awaymode
    state: ‘off’
    - condition: template
    value_template: “{{ states.climate.neq1489811.attributes.temperature != states.input_slider.climate_bedroom_standard_temperature.state | int }}”
    - condition: state
    entity_id: binary_sensor.jmd4015744_state
    state: ‘off’
    - condition: and
    conditions:
    - condition: template
    value_template: “{{ states.input_slider.climate_livingroom_timer_hours_stop.state | int == now().strftime(‘%H’) | int}}”
    - condition: template
    value_template: “{{ states.input_slider.climate_livingroom_timer_minutes_stop.state | int == now().strftime(‘%M’) | int }}”

action:
- service: climate.set_temperature
data_template:
entity_id: climate.neq1489811
temperature: “{{ states.input_slider.climate_bedroom_standard_temperature.state | int }}”
- service: mqtt.publish
data:
topic: ‘hass/climate/livingroom_active’
payload: ‘OFF’
retain: ‘true’

Any smarter solutions are welcome :slight_smile: