I can't crack the multi-conditions from automation editor

I’m now trying to solve this over the past 3 days and sadly failing. I’m trying to configure automation via the editor in the front end since for some reasons (might be a curse on me…) even editing in the code fails.

I have an input booleans that sets to Morning, Afternoon, etc based on time but also if it’s a workday or not.

I’m trying ot align my thermostats to this. The code below is build by the automation editor but it doesn’t fire on state change. What I am I doing wrong?

- id: '1603109179471'
  alias: Home  THERMOSTATS (based on part of day)
  description: ''
  trigger:
  - platform: event
    event_data:
      entity_id: input_select.part_of_day
      from: Morning
    event_type: state_changed
  - platform: event
    event_data:
      entity_id: input_select.part_of_day
      from: Afternoon
    event_type: state_changed
  - platform: event
    event_data:
      entity_id: input_select.part_of_day
      from: Evening
    event_type: state_changed
  - platform: event
    event_data:
      entity_id: input_select.part_of_day
      from: Midnight
    event_type: state_changed
  condition:
  - condition: state
    entity_id: input_select.summer_or_winter
    state: Winter
  action:
  - condition: state
    entity_id: input_select.part_of_day
    state: Evening
  - service: climate.set_temperature
    entity_id: climate.heat
    data:
      temperature: 22
  - condition: state
    entity_id: input_select.part_of_day
    state: '"Afternoon"'
  - service: climate.set_temperature
    entity_id: climate.heat
    data:
      temperature: 20
  - condition: state
    entity_id: input_select.part_of_day
    state: '"Morning"'
  - service: climate.set_temperature
    entity_id: climate.heat
    data:
      temperature: 23
  - service: climate.set_temperature
    entity_id: climate.badkamer
    data:
      temperature: 20
  - condition: state
    entity_id: input_select.part_of_day
    state: Midnight
  - service: climate.set_temperature
    entity_id: climate.heat
    data:
      temperature: 16
  - service: climate.set_temperature
    entity_id: climate.boven
    data:
      temperature: 17
  - service: climate.set_temperature
    entity_id: climate.kantoor
    data:
      temperature: 16
  - service: climate.set_temperature
    entity_id: climate.badkamer
    data:
      temperature: 16
  mode: restart

This should be a state platform, not event.

  trigger:
  - platform: event
    event_data:
      entity_id: input_select.part_of_day
      from: Morning

Like so:

  trigger:
  - platform: state
    event_data:
      entity_id: input_select.part_of_day
      from: Morning

Done but nothing happens. The automation is not triggered (I change manually the input select).

Which mode should I use? It’s on restart now
Is it necessary to lay out all options or would this work for “any change”?

  trigger:
  - platform: state
    event_data:
      entity_id: input_select.part_of_day

Any clue why it is not firing? Thanks!

Sorry, it’s still not right. Like this;

 trigger:
 - platform: state
   entity_id: input_select.part_of_day
   from: Morning

Still no luck. Nothing happens when I change the input select. Here’s the code now:

- id: homethermostats
  alias: Home  THERMOSTATS (based on part of day)
  description: ''
  trigger:
  - platform: state
    entity_id: input_select.part_of_day
    from: Morning
    to: Afternoon
    attribute: options
  - platform: state
    entity_id: input_select.part_of_day
    from: Afternoon
    to: Evening
    attribute: options
  - platform: state
    entity_id: input_select.part_of_day
    from: Evening
    to: Midnight
    attribute: options
  - platform: state
    entity_id: input_select.part_of_day
    from: Midnight
    to: Morning
    attribute: options
  condition: []
  action:
  - condition: state
    entity_id: input_select.part_of_day
    state: Evening
    attribute: options
  - service: climate.set_temperature
    entity_id: climate.heat
    data:
      temperature: 22
  - condition: state
    entity_id: input_select.part_of_day
    state: Afternoon
    attribute: options
  - service: climate.set_temperature
    entity_id: climate.heat
    data:
      temperature: 20
  - condition: state
    entity_id: input_select.part_of_day
    state: Morning
    attribute: options
  - service: climate.set_temperature
    entity_id: climate.heat
    data:
      temperature: 23
  - service: climate.set_temperature
    entity_id: climate.badkamer
    data:
      temperature: 20
  - condition: state
    entity_id: input_select.part_of_day
    state: Midnight
    attribute: options
  - service: climate.set_temperature
    entity_id: climate.heat
    data:
      temperature: 16
  - service: climate.set_temperature
    entity_id: climate.boven
    data:
      temperature: 17
  - service: climate.set_temperature
    entity_id: climate.kantoor
    data:
      temperature: 16
  - service: climate.set_temperature
    entity_id: climate.badkamer
    data:
      temperature: 16
  mode: restart

The problem isn’t your trigger it is how you have constructed your actions.

You could use this trigger which will trigger on any change of state of the input select:

- id: homethermostats
  alias: Home  THERMOSTATS (based on part of day)
  description: ''
  trigger:
  - platform: state
    entity_id: input_select.part_of_day

Then for the actions use the choose action as shown in the examples here: https://www.home-assistant.io/docs/scripts/#choose-a-group-of-actions

1 Like

Thanks for the help everyone. I’m posting my final (Working) code here. A couple of interesting notes:
I have a custom component called “Climate.Groups”. In my house, there are 3 different radiators in one room so that was handy. This works with google assistant but… it never worked in this automation.
I also have evo home smart radiators everywhere and the recommended way is via evohome.set_zone_override. I did, it worked once, and never wanted to change again (not sure if there is a timeout on the API or something). So I reverted to climate service instead.

The working code:


I have an input select called
input_select.part_of_day

options:
  - Midnight
  - Morning
  - Afternoon
  - Evening
editable: true
friendly_name: Part of Day

I have the binary sensor “workday” - (out of the box - simply add this to configuration.yaml)

  - platform: workday
    country: NL

I have an automation to set the input select phases during the day (morning, afternoon, etc)

  • I also use this to set my lights during the day to different levels of intensity but that’ not in this code here
  • (I have a stupid cat that triggers lots of sensor lights during the night…)
- id: 'partofdaylloyd'
  alias: Home Part of Day
  description: ''
  trigger:
  - platform: time
    at: '06:00:01'
  - platform: time
    at: '11:00:01'
  - platform: time
    at: '18:00:01'
  - platform: time
    at: '23:00:01'
  - platform: time
    at: '09:00:00'
  condition: []
  action:
    - choose:
        # IF Midnight
        - conditions:
            - condition: time
              after: '23:00:00'
          sequence:
            - service: input_select.select_option
              entity_id: input_select.part_of_day
              data:
               option: Midnight
        # ELIF Evening
        - conditions:
            - condition: time
              after: '18:00:00'
          sequence:
             - service: input_select.select_option
               entity_id: input_select.part_of_day
               data:
                 option: Evening
        # ELIF Afternoon
        - conditions:
            - condition: time
              after: '11:00:00'
          sequence:
             - service: input_select.select_option
               entity_id: input_select.part_of_day
               data:
                 option: Afternoon
        # ELIF Morning workday on
        - conditions:
            - condition: time
              after: '06:00:00'
            - condition: state
              entity_id: binary_sensor.workday_sensor
              state: 'on'
          sequence:
             - service: input_select.select_option
               entity_id: input_select.part_of_day
               data:
                 option: Morning
        # ELIF Morning workday off
        - conditions:
            - condition: time
              after: '09:00:00'
            - condition: state
              entity_id: binary_sensor.workday_sensor
              state: 'off'
          sequence:
             - service: input_select.select_option
               entity_id: input_select.part_of_day
               data:
                 option: Morning

      # ELSE Midnight
      default:
        - service: input_select.select_option
          entity_id: input_select.part_of_day
          data:
            option: Midnight

And finally the automation discussed in this thread to setup my thermostats.

- id: homethermostats
  alias: Home  THERMOSTATS (based on part of day)
  description: ''
  trigger:
  - platform: state
    entity_id: input_select.part_of_day
  condition: []
  action:
    - choose:
        # IF Evening
        - conditions:
            - condition: state
              entity_id: input_select.part_of_day
              state: Evening
          sequence:
            - service: evohome.set_zone_override
              entity_id: climate.gang
              data:
               setpoint: 21
            - service: evohome.set_zone_override
              entity_id: climate.woonkamer
              data:
               setpoint: 21
        # ELIF Afternoon
        - conditions:
            - condition: state
              entity_id: input_select.part_of_day
              state: Afternoon
          sequence:
             - service: evohome.set_zone_override
               entity_id: climate.gang
               data:
                 setpoint: 19
             - service: evohome.set_zone_override
               entity_id: climate.woonkamer
               data:
                 setpoint: 19
             - service: evohome.set_zone_override
               entity_id: climate.badkamer
               data:
                 setpoint: 16
        # ELIF Morning
        - conditions:
            - condition: state
              entity_id: input_select.part_of_day
              state: Morning
          sequence:
             - service: evohome.set_zone_override
               entity_id: climate.gang
               #works
               data:
                 setpoint: 21
             - service: evohome.set_zone_override
               entity_id: climate.woonkamer
               #works
               data:
                 setpoint: 21
             - service: evohome.set_zone_override
               entity_id: climate.badkamer
               data:
                 setpoint: 21
      # ELSE night
      default:
        - service: evohome.set_zone_override
          entity_id: climate.gang
          data:
            setpoint: 16
        - service: evohome.set_zone_override
          entity_id: climate.woonkamer
          data:
            setpoint: 16
        - service: evohome.set_zone_override
          entity_id: climate.slaapkamer
          data:
            setpoint: 16
        - service: evohome.set_zone_override
          entity_id: climate.slaapzolderkamer
          data:
            setpoint: 16
        - service: evohome.set_zone_override
          entity_id: climate.kantoor
          data:
            setpoint: 16
        - service: evohome.set_zone_override
          entity_id: climate.badkamer
          data:
            setpoint: 16
        - service: evohome.set_zone_override
          entity_id: climate.wc_woonkame
          data:
            setpoint: 16


why dont you simply use a part_of_day sensor, instead of the first automation?

      part_of_day:
        friendly_name: Part of day
        value_template: >
          {% set trigger = states('sensor.time') %}
          {% set hour = now().hour %}
          {% if hour in range(0,6) %} Night
          {% elif hour in range(6,12) %} Morning
          {% elif hour in range(12,18) %} Afternoon
          {% else %} Evening
          {% endif %}

and use the states of that sensor in the conditions of the second automation?

btw, though I only have 1 climate entity, and can’t test it, I would think this:

        - service: evohome.set_zone_override
          entity_id: climate.gang
          data:
            setpoint: 16
        - service: evohome.set_zone_override
          entity_id: climate.woonkamer
          data:
            setpoint: 16
        - service: evohome.set_zone_override
          entity_id: climate.slaapkamer
          data:
            setpoint: 16
        - service: evohome.set_zone_override
          entity_id: climate.slaapzolderkamer
          data:
            setpoint: 16
        - service: evohome.set_zone_override
          entity_id: climate.kantoor
          data:
            setpoint: 16
        - service: evohome.set_zone_override
          entity_id: climate.badkamer
          data:
            setpoint: 16
        - service: evohome.set_zone_override
          entity_id: climate.wc_woonkame
          data:
            setpoint: 16

could be shorthanded to:

        - service: evohome.set_zone_override
          entity_id:
            - climate.gang
            - climate.woonkamer
            - climate.slaapkamer
            - climate.slaapzolderkamer
            - climate.kantoor
            - climate.badkamer
            - climate.wc_woonkame
          data:
            setpoint: 16

the same would apply for the other actions.

Yes, indeed much more elegant - and it has to do that I’m not a very strong coder - I just try to adapt codes I find here and there until it works :wink:
(I had tried the template sensor already and gave up after many many tried where I coudn’t make it work… and lack understanding why - that’s why I went back to automation )

BTW, the system evohome.set_zone_override failed on me (it would only work ad hoc) but strangely the climate.set_temperature worked fine.