Why does not the Office Light turns on?

Hey guys, need some help debugging this automation since it is not working as I want and I am not sure what could I be missing. This is what the automation looks like:

- id: '1676394605387'
  alias: Setup Office for Work
  description: ''
  trigger:
  - platform: event
    event_type: ios.action_fired
    event_data:
      actionName: WorkTime
  condition:
  - condition: state
    entity_id: fan.office_fan
    state: 'off'
  - condition: or
    conditions:
    - condition: state
      entity_id: light.office_light
      state: 'off'
  action:
  - service: fan.turn_on
    data:
      percentage: 100
    target:
      entity_id: fan.office_fan
  - condition: state
    entity_id: fan.office_fan
    state: 'off'
  - condition: state
    entity_id: climate.home
    state: 'off'
  - condition: state
    entity_id: weather.home
    attribute: temperature
    state: '>=76'
  - service: light.turn_on
    data: {}
    target:
      entity_id: light.office_light
  - condition: state
    entity_id: light.office_light
    state: 'off'
  mode: single

the general idea is: to turn on the office fan/light if they are not ON already.

  • The first condition check if the fan and the climate are off and the temperature sensor is equal to or above 76
  • The second condition check if the light off

But for some reason, only the fan gets turned on and the light remains off, why? conditions are met because the light and the climate are off and the sensor temperature is 69 … :thinking:

Where did you see in the documentation that you can create a State Condition using this invalid syntax?

    state: '>=76'

Replace the State Condition with a Numeric State Condition.

  - condition: numeric_state
    entity_id: weather.home
    attribute: temperature
    above: 75

What’s the intended purpose of the State Condition at the very end of the automation?

I did not see it, next time I will check the docs first, it was added by the UI it looks weird to me at first but then I leave it and of course, as a result, it never worked

What’s the intended purpose of the State Condition at the very end of the automation?
Do you mean this one?

  - condition: state
    entity_id: light.office_light
    state: 'off'

I was trying to say “turn on the light only if it is off” not sure if that makes sense or is correct as I did it.

Thanks for your help so far

The UI only adds whatever you type or choose from a selection menu and this >=76 would not appear in a selection.

If that’s what you want it to do then you should put it before the light.turn_on service call.

Like …

  - condition: state
    entity_id: light.office_light
    state: 'off'
  - service: light.turn_on
    data: {}
    target:
      entity_id: light.office_light

if so then I have to fix the one for the fan and move the condition over to the service call, am I correct?

Describe exactly how you want the automation to control the fan and light and I’ll create the automation.

Okay, the automation should turn on the light if it is off and should turn on the fan if it is off the climate.home is off, and the weather.home temperature is reporting 76 or more.

Currently I have this as per your notes here:

- id: '1676394605387'
  alias: Setup Office for Work
  description: ''
  trigger:
  - platform: event
    event_type: ios.action_fired
    event_data:
      actionName: WorkTime
  condition: []
  action:
  - condition: state
    entity_id: fan.office_fan
    state: 'off'
  - condition: state
    entity_id: climate.home
    state: 'off'
  - condition: numeric_state
    entity_id: weather.home
    attribute: temperature
    above: 76
  - service: fan.turn_on
    data:
      percentage: 100
    target:
      entity_id: fan.office_fan
  - condition: state
    entity_id: light.office_light
    state: 'off'
  - service: light.turn_on
    data: {}
    target:
      entity_id: light.office_light
  mode: single

but again it just turns on the fan. Here is the trace for such an execution some minutes ago:

{
  "trace": {
    "last_step": "action/1/entity_id/0",
    "run_id": "27bd84575bbcaf08ff0e2f5a35548705",
    "state": "stopped",
    "script_execution": "aborted",
    "timestamp": {
      "start": "2023-02-15T14:35:21.657370+00:00",
      "finish": "2023-02-15T14:35:22.159240+00:00"
    },
    "domain": "automation",
    "item_id": "1676394605387",
    "trigger": null,
    "trace": {
      "trigger": [
        {
          "path": "trigger",
          "timestamp": "2023-02-15T14:35:21.657505+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.setup_office_for_work",
              "state": "on",
              "attributes": {
                "last_triggered": "2023-02-15T13:18:05.559948+00:00",
                "mode": "single",
                "current": 0,
                "id": "1676394605387",
                "friendly_name": "Setup Office for Work"
              },
              "last_changed": "2023-02-14T20:09:33.336197+00:00",
              "last_updated": "2023-02-15T13:18:06.014545+00:00",
              "context": {
                "id": "01GSAKK87QFD8K1JFPCSCQ9BBH",
                "parent_id": "01GSAKK87PQ2WHW0GJXTJB2FWX",
                "user_id": null
              }
            },
            "trigger": {
              "platform": null
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2023-02-15T14:35:21.659141+00:00",
          "changed_variables": {
            "context": {
              "id": "01GSAR0QNSG2C0K5T7J0R4WGXE",
              "parent_id": "01GSAR0QNR2437YT10T7MDC65W",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "fan",
              "service": "turn_on",
              "service_data": {
                "percentage": 100,
                "entity_id": [
                  "fan.office_fan"
                ]
              },
              "target": {
                "entity_id": [
                  "fan.office_fan"
                ]
              }
            },
            "running_script": false,
            "limit": 10
          }
        }
      ],
      "action/1": [
        {
          "path": "action/1",
          "timestamp": "2023-02-15T14:35:22.157279+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/1/entity_id/0": [
        {
          "path": "action/1/entity_id/0",
          "timestamp": "2023-02-15T14:35:22.157385+00:00",
          "result": {
            "result": false,
            "state": "on",
            "wanted_state": "off"
          }
        }
      ]
    },
    "config": {
      "id": "1676394605387",
      "alias": "Setup Office for Work",
      "description": "",
      "trigger": [
        {
          "platform": "event",
          "event_type": "ios.action_fired",
          "event_data": {
            "actionName": "WorkTime"
          }
        }
      ],
      "condition": [
        {
          "condition": "state",
          "entity_id": "fan.office_fan",
          "state": "off"
        },
        {
          "condition": "or",
          "conditions": [
            {
              "condition": "state",
              "entity_id": "light.office_light",
              "state": "off"
            }
          ]
        }
      ],
      "action": [
        {
          "service": "fan.turn_on",
          "data": {
            "percentage": 100
          },
          "target": {
            "entity_id": "fan.office_fan"
          }
        },
        {
          "condition": "state",
          "entity_id": "fan.office_fan",
          "state": "off"
        },
        {
          "condition": "state",
          "entity_id": "climate.home",
          "state": "off"
        },
        {
          "condition": "state",
          "entity_id": "weather.home",
          "attribute": "temperature",
          "state": ">=76"
        },
        {
          "service": "light.turn_on",
          "data": {},
          "target": {
            "entity_id": "light.office_light"
          }
        },
        {
          "condition": "state",
          "entity_id": "light.office_light",
          "state": "off"
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01GSAR0QNSG2C0K5T7J0R4WGXE",
      "parent_id": "01GSAR0QNR2437YT10T7MDC65W",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Setup Office for Work",
      "message": "triggered",
      "source": null,
      "entity_id": "automation.setup_office_for_work",
      "context_id": "01GSAR0QNSG2C0K5T7J0R4WGXE",
      "when": 1676471721.657619,
      "domain": "automation"
    },
    {
      "when": 1676471721.844387,
      "state": "on",
      "entity_id": "fan.office_fan",
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "Setup Office for Work",
      "context_message": "triggered",
      "context_entity_id": "automation.setup_office_for_work"
    }
  ]
}

You should know that the original automation you posted attempts to logically OR two conditions but doesn’t do it correctly. The two conditions are actually logically ANDed which is probably not what you want.

The trace you posted still shows the automation attempting to process the invalid State Condition"

        {
          "condition": "state",
          "entity_id": "weather.home",
          "attribute": "temperature",
          "state": ">=76"
        },

This lines?

condition:
  - condition: state
    entity_id: fan.office_fan
    state: 'off'
  - condition: or
    conditions:
    - condition: state
      entity_id: light.office_light
      state: 'off'

yea I noticed something weird there and since I tried to check the same down where the service call is made then I removed the conditions from there to avoid issues still I am having them :frowning:

Hmm that is weird, I have changed the automation and even the UI shows the changes:

Review this and let me know if it’s how you want the automation to work:

- id: '1676394605387'
  alias: Setup Office for Work
  description: ''
  trigger:
    - platform: event
      event_type: ios.action_fired
      event_data:
        actionName: WorkTime
  condition:
    - condition: or
      conditions:
        - condition: state
          entity_id: fan.office_fan
          state: "off"
        - condition: state
          entity_id: light.office_light
          state: "off"
  action:
    - if:
        - condition: state
          entity_id: fan.office_fan
          state: "off"
      then:
        - service: fan.turn_on
          data:
            percentage: 100
          target:
            entity_id: fan.office_fan
    - if:
        - condition: state
          entity_id: light.office_light
          state: "off"
        - condition: state
          entity_id: climate.home
          state: "off"
        - condition: numeric_state
          entity_id: weather.home
          attribute: temperature
          above: 75
      then:
        - service: light.turn_on
          target:
            entity_id: light.office_light
  mode: single

I did a small modification because the temperature checking belongs to the fan not to the light:

- id: '1676394605387'
  alias: Setup Office for Work
  description: ''
  trigger:
    - platform: event
      event_type: ios.action_fired
      event_data:
        actionName: WorkTime
  condition: [ ]
  action:
    - if:
        - condition: state
          entity_id: fan.office_fan
          state: "off"
        - condition: state
          entity_id: climate.home
          state: 'off'
        - condition: numeric_state
          entity_id: weather.home
          attribute: temperature
          above: 75
      then:
        - service: fan.turn_on
          data:
            percentage: 100
          target:
            entity_id: fan.office_fan
    - if:
        - condition: state
          entity_id: light.office_light
          state: 'off'
      then:
        - service: light.turn_on
          target:
            entity_id: light.office_light
  mode: single

However, it stops if the first conditions are not met. Right now the temperature is at 70 so the automation won’t turn on the fan but it stops there and won’t turn on the light either. Below is the trace:

{
  "trace": {
    "last_step": "action/2/entity_id/0",
    "run_id": "3c470b2593af287d4cee7b8717d7be97",
    "state": "stopped",
    "script_execution": "aborted",
    "timestamp": {
      "start": "2023-02-15T15:05:37.760546+00:00",
      "finish": "2023-02-15T15:05:37.766530+00:00"
    },
    "domain": "automation",
    "item_id": "1676394605387",
    "trigger": "event 'ios.action_fired'",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2023-02-15T15:05:37.760623+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.setup_office_for_work",
              "state": "on",
              "attributes": {
                "last_triggered": "2023-02-15T15:05:28.023108+00:00",
                "mode": "single",
                "current": 0,
                "id": "1676394605387",
                "friendly_name": "Setup Office for Work"
              },
              "last_changed": "2023-02-15T14:52:28.862363+00:00",
              "last_updated": "2023-02-15T15:05:28.025236+00:00",
              "context": {
                "id": "01GSASQVPPGTKBRZTR6FKVAC0R",
                "parent_id": "01GSASQVPPAPHH2WVSREMSHVRS",
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "event",
              "event": {
                "event_type": "ios.action_fired",
                "data": {
                  "actionID": "WorkTime",
                  "actionName": "WorkTime",
                  "sourceDeviceID": "reyniers_iphone_",
                  "sourceDeviceName": "Reynier’s iPhone 😎",
                  "sourceDevicePermanentID": "D87E62F8-E557-465E-BF78-C5889608E797",
                  "triggerSource": "watch"
                },
                "origin": "REMOTE",
                "time_fired": "2023-02-15T15:05:37.759662+00:00",
                "context": {
                  "id": "01GSASR56ZHEZQ7D0PW14S49DQ",
                  "parent_id": null,
                  "user_id": "400ef95814c14c3c8864b3ccb9f8b4ab"
                }
              },
              "description": "event 'ios.action_fired'"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2023-02-15T15:05:37.764562+00:00",
          "changed_variables": {
            "context": {
              "id": "01GSASR570AZVE6ZJXQF8CM6DX",
              "parent_id": "01GSASR56ZHEZQ7D0PW14S49DQ",
              "user_id": null
            }
          },
          "result": {
            "result": true
          }
        }
      ],
      "action/0/entity_id/0": [
        {
          "path": "action/0/entity_id/0",
          "timestamp": "2023-02-15T15:05:37.764652+00:00",
          "result": {
            "result": true,
            "state": "off",
            "wanted_state": "off"
          }
        }
      ],
      "action/1": [
        {
          "path": "action/1",
          "timestamp": "2023-02-15T15:05:37.764744+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/1/entity_id/0": [
        {
          "path": "action/1/entity_id/0",
          "timestamp": "2023-02-15T15:05:37.764794+00:00",
          "result": {
            "result": true,
            "state": "off",
            "wanted_state": "off"
          }
        }
      ],
      "action/2": [
        {
          "path": "action/2",
          "timestamp": "2023-02-15T15:05:37.764850+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/2/entity_id/0": [
        {
          "path": "action/2/entity_id/0",
          "timestamp": "2023-02-15T15:05:37.764963+00:00",
          "result": {
            "result": false,
            "state": 67,
            "wanted_state_above": 76
          }
        }
      ]
    },
    "config": {
      "id": "1676394605387",
      "alias": "Setup Office for Work",
      "description": "",
      "trigger": [
        {
          "platform": "event",
          "event_type": "ios.action_fired",
          "event_data": {
            "actionName": "WorkTime"
          }
        }
      ],
      "condition": [],
      "action": [
        {
          "condition": "state",
          "entity_id": "fan.office_fan",
          "state": "off"
        },
        {
          "condition": "state",
          "entity_id": "climate.home",
          "state": "off"
        },
        {
          "condition": "numeric_state",
          "entity_id": "weather.home",
          "attribute": "temperature",
          "above": 76
        },
        {
          "service": "fan.turn_on",
          "data": {
            "percentage": 100
          },
          "target": {
            "entity_id": "fan.office_fan"
          }
        },
        {
          "condition": "state",
          "entity_id": "light.office_light",
          "state": "off"
        },
        {
          "service": "light.turn_on",
          "data": {},
          "target": {
            "entity_id": "light.office_light"
          }
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01GSASR570AZVE6ZJXQF8CM6DX",
      "parent_id": "01GSASR56ZHEZQ7D0PW14S49DQ",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Setup Office for Work",
      "message": "triggered by event 'ios.action_fired'",
      "source": "event 'ios.action_fired'",
      "entity_id": "automation.setup_office_for_work",
      "context_id": "01GSASR570AZVE6ZJXQF8CM6DX",
      "when": 1676473537.760748,
      "domain": "automation"
    }
  ]
}

Then why did your original version check the temperature after turning on the fan? In effect, it was checking the temperature before turning on the light.

Here’s what the trace reports it is executing. It looks like your original version without the use of if-then.

      "action": [
        {
          "condition": "state",
          "entity_id": "fan.office_fan",
          "state": "off"
        },
        {
          "condition": "state",
          "entity_id": "climate.home",
          "state": "off"
        },
        {
          "condition": "numeric_state",
          "entity_id": "weather.home",
          "attribute": "temperature",
          "above": 76
        },
        {
          "service": "fan.turn_on",
          "data": {
            "percentage": 100
          },
          "target": {
            "entity_id": "fan.office_fan"
          }
        },
        {
          "condition": "state",
          "entity_id": "light.office_light",
          "state": "off"
        },
        {
          "service": "light.turn_on",
          "data": {},
          "target": {
            "entity_id": "light.office_light"
          }
        }
      ],

That might be me miss understanding of how the whole automation thing does work. I thought at first it was sequential but that does not seem to be the case. The temperature matter just for the fan, not the light. Sorry for the confusion.

The right automation would be:

  • Turns on the fan if it was off, the AC (climate.home) was off, and the AC temperature sensor (weather.home) is reporting above 76.
  • Turns on the light if it was off

If both are off then at least the light should be turned on. If the fan conditions are met both should be turned on. Is it more clear now?

It is sequential. Which means if you want to perform a test before turning on a fan, put the test before turning on the fan, not after it (like in the original example).

Yes, but the latest trace you posted doesn’t appear to be using the latest example I had suggested.

Got it! thanks for confirming that!

Yes, but the latest trace you posted doesn’t appear to be using the latest example I had suggested.

Odd, I had restarted HA and triggered the automation from my watch and now is working perfectly! Trace log attached below:

{
  "trace": {
    "last_step": "action/1/then/0",
    "run_id": "b07ace0f70b66a3a89b03890cf7c493e",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2023-02-15T20:17:28.264827+00:00",
      "finish": "2023-02-15T20:17:28.898123+00:00"
    },
    "domain": "automation",
    "item_id": "1676394605387",
    "trigger": "event 'ios.action_fired'",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2023-02-15T20:17:28.264979+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.setup_office_for_work",
              "state": "on",
              "attributes": {
                "last_triggered": "2023-02-15T18:11:54.754347+00:00",
                "mode": "single",
                "current": 0,
                "id": "1676394605387",
                "friendly_name": "Setup Office for Work"
              },
              "last_changed": "2023-02-15T20:16:03.594611+00:00",
              "last_updated": "2023-02-15T20:16:03.594611+00:00",
              "context": {
                "id": "01GSBBGJGAKYDYXWQ9H7WHVNAS",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "event",
              "event": {
                "event_type": "ios.action_fired",
                "data": {
                  "actionID": "WorkTime",
                  "actionName": "WorkTime",
                  "sourceDeviceID": "reyniers_iphone_",
                  "sourceDeviceName": "Reynier’s iPhone 😎",
                  "sourceDevicePermanentID": "D87E62F8-E557-465E-BF78-C5889608E797",
                  "triggerSource": "watch"
                },
                "origin": "REMOTE",
                "time_fired": "2023-02-15T20:17:28.262477+00:00",
                "context": {
                  "id": "01GSBBK566HSHJSDYP0BVP92ZG",
                  "parent_id": null,
                  "user_id": "400ef95814c14c3c8864b3ccb9f8b4ab"
                }
              },
              "description": "event 'ios.action_fired'"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2023-02-15T20:17:28.268082+00:00",
          "changed_variables": {
            "context": {
              "id": "01GSBBK568M6BXWDCE3Z3JDKV2",
              "parent_id": "01GSBBK566HSHJSDYP0BVP92ZG",
              "user_id": null
            }
          },
          "result": {
            "choice": "then"
          }
        }
      ],
      "action/0/if": [
        {
          "path": "action/0/if",
          "timestamp": "2023-02-15T20:17:28.268511+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/if/condition/0": [
        {
          "path": "action/0/if/condition/0",
          "timestamp": "2023-02-15T20:17:28.268563+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/if/condition/0/entity_id/0": [
        {
          "path": "action/0/if/condition/0/entity_id/0",
          "timestamp": "2023-02-15T20:17:28.268600+00:00",
          "result": {
            "result": true,
            "state": "off",
            "wanted_state": "off"
          }
        }
      ],
      "action/0/if/condition/1": [
        {
          "path": "action/0/if/condition/1",
          "timestamp": "2023-02-15T20:17:28.268720+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/if/condition/1/entity_id/0": [
        {
          "path": "action/0/if/condition/1/entity_id/0",
          "timestamp": "2023-02-15T20:17:28.268766+00:00",
          "result": {
            "result": true,
            "state": "off",
            "wanted_state": "off"
          }
        }
      ],
      "action/0/if/condition/2": [
        {
          "path": "action/0/if/condition/2",
          "timestamp": "2023-02-15T20:17:28.268843+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/if/condition/2/entity_id/0": [
        {
          "path": "action/0/if/condition/2/entity_id/0",
          "timestamp": "2023-02-15T20:17:28.268941+00:00",
          "result": {
            "result": true,
            "state": 82
          }
        }
      ],
      "action/0/then/0": [
        {
          "path": "action/0/then/0",
          "timestamp": "2023-02-15T20:17:28.269562+00:00",
          "result": {
            "params": {
              "domain": "fan",
              "service": "turn_on",
              "service_data": {
                "percentage": 100,
                "entity_id": [
                  "fan.office_fan"
                ]
              },
              "target": {
                "entity_id": [
                  "fan.office_fan"
                ]
              }
            },
            "running_script": false,
            "limit": 10
          }
        }
      ],
      "action/1": [
        {
          "path": "action/1",
          "timestamp": "2023-02-15T20:17:28.789891+00:00",
          "result": {
            "choice": "then"
          }
        }
      ],
      "action/1/if": [
        {
          "path": "action/1/if",
          "timestamp": "2023-02-15T20:17:28.790111+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/1/if/condition/0": [
        {
          "path": "action/1/if/condition/0",
          "timestamp": "2023-02-15T20:17:28.790140+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/1/if/condition/0/entity_id/0": [
        {
          "path": "action/1/if/condition/0/entity_id/0",
          "timestamp": "2023-02-15T20:17:28.790156+00:00",
          "result": {
            "result": true,
            "state": "off",
            "wanted_state": "off"
          }
        }
      ],
      "action/1/then/0": [
        {
          "path": "action/1/then/0",
          "timestamp": "2023-02-15T20:17:28.790559+00:00",
          "result": {
            "params": {
              "domain": "light",
              "service": "turn_on",
              "service_data": {},
              "target": {
                "entity_id": [
                  "light.office_light"
                ]
              }
            },
            "running_script": false,
            "limit": 10
          }
        }
      ]
    },
    "config": {
      "id": "1676394605387",
      "alias": "Setup Office for Work",
      "description": "",
      "trigger": [
        {
          "platform": "event",
          "event_type": "ios.action_fired",
          "event_data": {
            "actionName": "WorkTime"
          }
        }
      ],
      "condition": [],
      "action": [
        {
          "if": [
            {
              "condition": "state",
              "entity_id": "fan.office_fan",
              "state": "off"
            },
            {
              "condition": "state",
              "entity_id": "climate.home",
              "state": "off"
            },
            {
              "condition": "numeric_state",
              "entity_id": "weather.home",
              "attribute": "temperature",
              "above": 75
            }
          ],
          "then": [
            {
              "service": "fan.turn_on",
              "data": {
                "percentage": 100
              },
              "target": {
                "entity_id": "fan.office_fan"
              }
            }
          ]
        },
        {
          "if": [
            {
              "condition": "state",
              "entity_id": "light.office_light",
              "state": "off"
            }
          ],
          "then": [
            {
              "service": "light.turn_on",
              "target": {
                "entity_id": "light.office_light"
              }
            }
          ]
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01GSBBK568M6BXWDCE3Z3JDKV2",
      "parent_id": "01GSBBK566HSHJSDYP0BVP92ZG",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Setup Office for Work",
      "message": "triggered by event 'ios.action_fired'",
      "source": "event 'ios.action_fired'",
      "entity_id": "automation.setup_office_for_work",
      "context_id": "01GSBBK568M6BXWDCE3Z3JDKV2",
      "when": 1676492248.265092,
      "domain": "automation"
    },
    {
      "when": 1676492248.441081,
      "state": "on",
      "entity_id": "fan.office_fan",
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "Setup Office for Work",
      "context_message": "triggered by event 'ios.action_fired'",
      "context_source": "event 'ios.action_fired'",
      "context_entity_id": "automation.setup_office_for_work"
    },
    {
      "when": 1676492249.023702,
      "state": "on",
      "entity_id": "light.office_light",
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "Setup Office for Work",
      "context_message": "triggered by event 'ios.action_fired'",
      "context_source": "event 'ios.action_fired'",
      "context_entity_id": "automation.setup_office_for_work"
    },
    {
      "when": 1676492249.024505,
      "state": "on",
      "entity_id": "light.homelightsexceptkid",
      "icon": "mdi:lightbulb-group",
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "Setup Office for Work",
      "context_message": "triggered by event 'ios.action_fired'",
      "context_source": "event 'ios.action_fired'",
      "context_entity_id": "automation.setup_office_for_work"
    }
  ]
}

I have marked one of your replies as the solution since the only change I made was move some conditions over but your solution does exactly what I was looking for.

1 Like

Yes, now that trace is clearly showing that it’s using the suggested example (the one with the if-then statements).

If you’re interested, here’s how to compose the automation using Template Conditions in shorthand notation.

- id: '1676394605387'
  alias: Setup Office for Work
  description: ''
  trigger:
    - platform: event
      event_type: ios.action_fired
      event_data:
        actionName: WorkTime
  condition: [ ]
  action:
    - if:
        - "{{ is_state('fan.office_fan', 'off') }}"
        - "{{ is_state('climate.home', 'off') }}"
        - "{{ state_attr('weather.home', 'temperature') >= 76 }}"
      then:
        - service: fan.turn_on
          data:
            percentage: 100
          target:
            entity_id: fan.office_fan
    - if: "{{ is_state('light.office_light', 'off') }}"
      then:
        - service: light.turn_on
          target:
            entity_id: light.office_light
  mode: single
1 Like