Run an action only if automation was triggered by time trigger

Hi,

I’d like to have an input_select control (day/evening/night/auto) to override my heating settings.
I have an automation to set the temperature on my thermostats which is triggered by either a time trigger or by a state change of various input controls.
It basically looks like this:

trigger:
  - platform: time
    ...
  - platform: state
  ...
  - platform: state
  ...

The action: part calls a couple of climate.set_temperature services to set the temperatures.
My goal is now to reset the input_select control back to ‘auto’, if this automation was triggered by the time trigger (and not by changing the state of any of the input controls).

I tried it like this:

action:
  - service: climate.set_temperature
    ...
  - service: climate.set_temperature
    ...
  - condition:
      condition: template
      value_template: '{{ trigger.platform == "time" }}'
  - service: input_select.select_option
    entity_id: input_select.heatingmode
    data: 'auto'

This gets me:

[homeassistant.bootstrap] Invalid config for [automation]: [condition] is an invalid option for [automation]. Check: automation->action->3->condition.

when validating the config.

The documentation is not clear if a condition can be applied to only a subset of the services called in the action: clause (i.e. the ones after the condition:).

Does anyone know the correct syntax? Or if it is supposed to work like this at all?

TIA,
Sebastian

Ok, I figured it out… to change the value of an input_select control the syntax is:

  - service: input_select.select_option
    data:
      entity_id: input_select.heatingmode
      option: 'auto'

So the whole thing now looks like this for the “Evening” settings:
(“Day” and “Night” settings work accordingly)

alias: 'Heating Evening'
trigger:
  - platform: time
    hours: 16
    minutes: 00
    seconds: 00
  - platform: state
    entity_id: input_slider.heating_livingroom_evening
  - platform: state
    entity_id: input_slider.heating_bedroom_evening
  - platform: state
    entity_id: input_slider.heating_office_evening
  - platform: state
    entity_id: input_boolean.venting
    state: 'off'
  - platform: state
    entity_id: input_select.heatingmode
    state: 'Evening'
condition:
  - condition: or
    conditions:
      - condition: template
        value_template: '{{ 16 <= now().hour < 21 }}'
      - condition: state
        entity_id: input_select.heatingmode
        state: 'Evening'
action:
  - service: climate.set_temperature
    data_template:
      entity_id: climate.danfoss_z_thermostat_014g0013_heating_1_4
      temperature: '{{ states.input_slider.heating_livingroom_evening.state | int }}'
  - service: climate.set_temperature
    data_template:
      entity_id: climate.danfoss_z_thermostat_014g0013_heating_1_3
      temperature: '{{ states.input_slider.heating_bedroom_evening.state | int }}'
  - service: climate.set_temperature
    data_template:
      entity_id: climate.danfoss_z_thermostat_014g0013_heating_1_2
      temperature: '{{ states.input_slider.heating_office_evening.state | int }}'
  - condition: and
    conditions:
      - condition: template
        value_template: '{{ trigger.platform == "time" }}'
      - condition: state
        entity_id: input_select.heatingmode
        state: 'Evening'
  - service: input_select.select_option
    data:
      entity_id: input_select.heatingmode
      option: 'auto'

What it does:
I currently have three thermostats that I can control via sliders; each has a slider for day/evening/night settings.
The settings primarily get triggered either at a specific time or by changing one of the sliders.
Of course, changing the evening slider during the day should not instantly trigger the evening automation.
Then there’s a boolean input “ventingmode” that, if set to “on”, prevents the automation from being activated.
(with ventingmode == “on”, all thermostats are set to their minimum temperature settings; useful for opening a few windows when it’s cold outside)

So then there’s cases when I come home early and I’d like the evening settings to be applied before their scheduled time.
For this I now have an input_select control “heatingmode” with values day/evening/night/auto. Auto being the default state.
So I come home and set it to “evening” -> the evening heating settings are applied instantly.
But since I don’t want the heating to be stuck at the evening settings as long as this control is set to “evening”, I reset the control to “auto” when the evening automation would have been activated regularly.

The only thing that needs some more thought is the case when for example the night settings are applied and I decide to stick with “evening” a little longer - the heatingmode control would only be reset when the evening automation would (time) trigger the next day.

Sebastian