One automation starting another one

I have a very simple automation that sets two input booleans at 6.30am:-

alias: Guest Room(s) TRV's on from 6.30am
description: Turn On TRV's from 6.30am
trigger:
  - platform: time
    at: "06:30:00"
condition: []
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.green_room_trv_switch
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.ensuite_room_trv_switch
mode: single

I can see from the trace this morning that it fired as expected:-

However, I have another automation which is triggered on either of the input booleans changing, here is the trigger part of that:-

alias: Guest Room(s) - Dynamic TRV Adjust v2 (heat/off)
description: ""
trigger:
  - platform: state
    id: ensuite_r
    entity_id:
      - input_boolean.ensuite_room_trv_switch
  - platform: state
    id: green_r
    entity_id:
      - input_boolean.green_room_trv_switch

I was expecting the first script that ran at 6.30am to then trigger the second, but I have no trace run for the second at 6.30am (nothing even near):-1:

Do I have to do something specific to make one automation fire as the result of a previous one ?

If the entities you’re using in your trigger were already on, then it’s not gonna trigger, because the trigger happens when the entity changes state, and there’s no state transition when “on” goes to “on”.

@Rudd-O - you are absolutely correct. Both input booleans were already on at 6.30am:-

Is there a need for separate automations? Perhaps they can be consolidated.

If you are interested in trying that, post all of the second automation.

Maybe you can turn your second automation on directly with the automation.trigger service, and then that automation, when triggered, can turn your input booleans on. Then in the same automation, you add a second trigger that, when your input booleans are turned off, it undoes whatever it did during the first triggger.

What’s your goal, ultimately, with the input booleans and the automation?

This is not a recommended design practice.

When examining an automation, it’s trigger section effectively documents the criteria for activating it. By employing automation.trigger, an entirely different activation criteria is employed that’s external to the automation.

In other words, the automation is no longer self-contained but a cog in a larger mechanism that’s not self-evident.

I’m interested in consolidating both automations into a single one, and i think there is a pretty simple way I can do this. I’ll post back if I get into difficulties!

However, having reviewed the second automation, it doesn’t actually matter if it doesn’t fire if both booleans are already on, so its fine.

Thankyou once again @Rudd-O and @123

1 Like

What’s the purpose of the two input_booleans in terms of controlling the TRVs? Do you ever turn them on manually or are they only turned on at 6:30 by the automation?

And to add to this.
If you need to trigger an automation, then what you need is a script.
To make things easier to debug then keep automations on “auto” and the scripts are manually run or run by an automation. Mixing the two will just make it hard.

The input booleans are switches for two generic thermostats connected to two TRV’s that don’t have a heater switch entity, so I turn them on an off via an automation.

However, this second automation also has a time condition so it doesn’t fire between the hours of 10.30pm and 6.29am, because the actuators on the TRv’s can be noisy in the silence of the night.

This means that there is a potential that the input boolean can be out of sync with the TRV, if the generic thermostat turns it on/off, but the time condition aborts the automation run.

So what I do is at 6.30am, incase thats happened in the night, I set the input booleans to ‘on’, because this is also the time the main boiler kicks in for the house. (The TRV’s can’t call for heat, they are just acting as limiters).

This is both automations:-

alias: Guest Room(s) TRV's on from 6.30am
description: Turn On TRV's from 6.30am
trigger:
  - platform: time
    at: "06:30:00"
condition: []
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.green_room_trv_switch
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.ensuite_room_trv_switch
mode: single

And this is the second:-

alias: Guest Room(s) - Dynamic TRV Adjust v2 (heat/off)
description: ""
trigger:
  - platform: state
    id: ensuite_r
    entity_id:
      - input_boolean.ensuite_room_trv_switch
  - platform: state
    id: green_r
    entity_id:
      - input_boolean.green_room_trv_switch
condition:
  - condition: time
    after: "06:29:59"
    enabled: true
  - condition: time
    before: "22:30:00"
    enabled: true
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: input_boolean.green_room_trv_switch
            state: "on"
          - condition: template
            value_template: "{{ trigger.id == 'green_r'}}"
          - condition: or
            conditions:
              - condition: state
                entity_id: input_boolean.guest_mode_green
                state: "on"
              - condition: state
                entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_4
                state: "on"
        sequence:
          - service: climate.set_hvac_mode
            data:
              hvac_mode: heat
            target:
              entity_id: climate.haozee_trv_green_room_thermostat
      - conditions:
          - condition: state
            entity_id: input_boolean.ensuite_room_trv_switch
            state: "on"
          - condition: template
            value_template: "{{ trigger.id == 'ensuite_r'}}"
          - condition: or
            conditions:
              - condition: state
                entity_id: input_boolean.guest_mode_ensuite
                state: "on"
              - condition: state
                entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_5
                state: "on"
        sequence:
          - service: climate.set_hvac_mode
            data:
              hvac_mode: heat
            target:
              entity_id: climate.haozee_trv_ensuite_room_thermostat
      - conditions:
          - condition: state
            entity_id: input_boolean.green_room_trv_switch
            state: "off"
          - condition: template
            value_template: "{{ trigger.id == 'green_r'}}"
        sequence:
          - service: climate.set_hvac_mode
            data:
              hvac_mode: "off"
            target:
              entity_id: climate.haozee_trv_green_room_thermostat
      - conditions:
          - condition: state
            entity_id: input_boolean.ensuite_room_trv_switch
            state: "off"
          - condition: template
            value_template: "{{ trigger.id == 'ensuite_r'}}"
        sequence:
          - service: climate.set_hvac_mode
            data:
              hvac_mode: "off"
            target:
              entity_id: climate.haozee_trv_ensuite_room_thermostat
      - conditions:
          - condition: template
            value_template: "{{ trigger.id == 'green_r'}}"
          - condition: state
            entity_id: input_boolean.guest_mode_green
            state: "off"
          - condition: state
            entity_id: input_boolean.green_room_trv_switch
            state: "on"
          - condition: state
            entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_4
            state: "off"
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.green_room_trv_switch
          - if:
              - condition: template
                value_template: "{{states('sensor.green_room_heating_state')=='on' }}"
            then:
              - service: climate.set_hvac_mode
                data:
                  hvac_mode: "off"
                target:
                  entity_id: climate.haozee_trv_green_room_thermostat
      - conditions:
          - condition: template
            value_template: "{{ trigger.id == 'ensuite_r'}}"
          - condition: state
            entity_id: input_boolean.guest_mode_ensuite
            state: "off"
          - condition: state
            entity_id: input_boolean.ensuite_room_trv_switch
            state: "on"
          - condition: state
            entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_opening_5
            state: "off"
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.ensuite_room_trv_switch
          - if:
              - condition: template
                value_template: "{{states('sensor.ensuite_room_heating_state')=='on' }}"
            then:
              - service: climate.set_hvac_mode
                data:
                  hvac_mode: "off"
                target:
                  entity_id: climate.haozee_trv_ensuite_room_thermostat
mode: queued