Garden lighting automation fault

Good evening everyone

I hope I am in the right place and not in the wrong section. If I am, please accept my apologies.
I have been using Home Assistant for several years now and have integrated almost everything in my house from the solar system to boiler monitoring and am very satisfied.

As I am now in the process of trying to renew or summarize old automations, I have now encountered a problem that I am now biting my teeth out.
The problem is that I have divided the lighting in my garden up to the garage into different groups so that everything up to and including the garage is not illuminated when I step outside the door.
So far I have solved this with individual automations and it has worked. Now that I have slowly lost track of all the automations, I wanted to redesign and summarize them.

But now I have the problem that the first part of the automation works and the first part of the outdoor lighting goes on as it should. But the other parts just don’t want to and I can’t find the error. I hope someone can help me here.
To start the automation I have a Zigbee motion detector and the rest is triggered via the people sensors of my Unifi cameras.
I also see in the automation that each trigger works or indicates but the light simply does not switch.
I have also triggered the lights manually with the labels and it works there. So it must be somewhere in the logic.

Here is the automation. Thank you already. Greetings from Switzerland


alias: Home Aussenlichtsteuerung
description: ""
triggers:
  - type: occupied
    device_id: 3f20ae222847465ac96ebe0e90939da5
    entity_id: b4500e411f15eab603c8a2c1857b0a50
    domain: binary_sensor
    trigger: device
  - type: occupied
    device_id: e5dc9261210178d75a4d7e3851e4153d
    entity_id: 7cfdaffd1dceb09c707b1ea4e5fc40b8
    domain: binary_sensor
    trigger: device
  - type: turned_on
    device_id: 9d1d2fbffdd9c7063a6443d6f668506d
    entity_id: e2f79899bb132f74a719d88c9d95796b
    domain: binary_sensor
    trigger: device
  - type: turned_on
    device_id: f73cea3298336ec034d18b799be44fda
    entity_id: cf32195722ce8d45189932751aa979fd
    domain: binary_sensor
    trigger: device
  - type: occupied
    device_id: 30662a923c784cad28b53b379f60da9e
    entity_id: e113217dcfca91d01b62e1e5d0c2d27d
    domain: binary_sensor
    trigger: device
  - type: not_occupied
    device_id: 3f20ae222847465ac96ebe0e90939da5
    entity_id: b4500e411f15eab603c8a2c1857b0a50
    domain: binary_sensor
    trigger: device
    for:
      hours: 0
      minutes: 3
      seconds: 0
    enabled: true
  - type: not_occupied
    device_id: e5dc9261210178d75a4d7e3851e4153d
    entity_id: 7cfdaffd1dceb09c707b1ea4e5fc40b8
    domain: binary_sensor
    trigger: device
    for:
      hours: 0
      minutes: 3
      seconds: 0
    enabled: true
  - type: turned_off
    device_id: 9d1d2fbffdd9c7063a6443d6f668506d
    entity_id: 8d4228af8488e5f7a0a6ce7a126baa3b
    domain: binary_sensor
    trigger: device
    for:
      hours: 0
      minutes: 3
      seconds: 0
    enabled: true
  - type: turned_off
    device_id: f73cea3298336ec034d18b799be44fda
    entity_id: cf32195722ce8d45189932751aa979fd
    domain: binary_sensor
    trigger: device
    for:
      hours: 0
      minutes: 3
      seconds: 0
    enabled: true
  - type: not_occupied
    device_id: 30662a923c784cad28b53b379f60da9e
    entity_id: e113217dcfca91d01b62e1e5d0c2d27d
    domain: binary_sensor
    trigger: device
    for:
      hours: 0
      minutes: 3
      seconds: 0
    enabled: true
  - type: turned_on
    device_id: 9d1d2fbffdd9c7063a6443d6f668506d
    entity_id: 4047dea4d395ea07909f3fd8766d610c
    domain: binary_sensor
    trigger: device
  - type: turned_on
    device_id: 90efba41a64dd7d1833b3b2c919f764f
    entity_id: 595faab90316f8554969e1ebb58423c2
    domain: binary_sensor
    trigger: device
conditions:
  - type: is_on
    condition: device
    device_id: 9d1d2fbffdd9c7063a6443d6f668506d
    entity_id: 4047dea4d395ea07909f3fd8766d610c
    domain: binary_sensor
    enabled: true
actions:
  - choose:
      - conditions:
          - condition: or
            conditions:
              - type: is_occupied
                condition: device
                device_id: e5dc9261210178d75a4d7e3851e4153d
                entity_id: 7cfdaffd1dceb09c707b1ea4e5fc40b8
                domain: binary_sensor
              - type: is_occupied
                condition: device
                device_id: 3f20ae222847465ac96ebe0e90939da5
                entity_id: b4500e411f15eab603c8a2c1857b0a50
                domain: binary_sensor
        sequence:
          - action: light.turn_on
            metadata: {}
            data: {}
            target:
              label_id: eingangslicht
          - wait_for_trigger:
              - type: not_occupied
                device_id: e5dc9261210178d75a4d7e3851e4153d
                entity_id: 7cfdaffd1dceb09c707b1ea4e5fc40b8
                domain: binary_sensor
                trigger: device
                for:
                  hours: 0
                  minutes: 3
                  seconds: 0
              - type: not_occupied
                device_id: 3f20ae222847465ac96ebe0e90939da5
                entity_id: b4500e411f15eab603c8a2c1857b0a50
                domain: binary_sensor
                trigger: device
                for:
                  hours: 0
                  minutes: 3
                  seconds: 0
            timeout:
              hours: 0
              minutes: 10
              seconds: 0
          - action: light.turn_off
            metadata: {}
            data: {}
            target:
              label_id: eingangslicht
        alias: "Steuerung: Eingang"
      - conditions:
          - type: is_on
            condition: device
            device_id: 9d1d2fbffdd9c7063a6443d6f668506d
            entity_id: e2f79899bb132f74a719d88c9d95796b
            domain: binary_sensor
        sequence:
          - action: switch.turn_on
            metadata: {}
            data: {}
            target:
              label_id:
                - gartenlicht
                - garagenlicht
          - wait_for_trigger:
              - type: turned_off
                device_id: 9d1d2fbffdd9c7063a6443d6f668506d
                entity_id: e2f79899bb132f74a719d88c9d95796b
                domain: binary_sensor
                trigger: device
                for:
                  hours: 0
                  minutes: 3
                  seconds: 0
            timeout:
              hours: 0
              minutes: 10
              seconds: 0
          - action: switch.turn_off
            metadata: {}
            data: {}
            target:
              label_id:
                - gartenlicht
                - garagenlicht
        alias: "Steuerung: Garten"
      - conditions:
          - condition: and
            conditions:
              - type: is_occupied
                condition: device
                device_id: 30662a923c784cad28b53b379f60da9e
                entity_id: e113217dcfca91d01b62e1e5d0c2d27d
                domain: binary_sensor
              - type: is_on
                condition: device
                device_id: 90efba41a64dd7d1833b3b2c919f764f
                entity_id: 595faab90316f8554969e1ebb58423c2
                domain: binary_sensor
        sequence:
          - action: switch.turn_on
            metadata: {}
            data: {}
            target:
              label_id: garagenlicht
          - wait_for_trigger:
              - type: not_occupied
                device_id: 30662a923c784cad28b53b379f60da9e
                entity_id: e113217dcfca91d01b62e1e5d0c2d27d
                domain: binary_sensor
                trigger: device
                for:
                  hours: 0
                  minutes: 3
                  seconds: 0
            timeout:
              hours: 0
              minutes: 10
              seconds: 0
          - action: switch.turn_off
            metadata: {}
            data: {}
            target:
              label_id: garagenlicht
        alias: "Steuerung: Garage in"
      - conditions:
          - type: is_on
            condition: device
            device_id: f73cea3298336ec034d18b799be44fda
            entity_id: cf32195722ce8d45189932751aa979fd
            domain: binary_sensor
        sequence:
          - action: switch.turn_on
            metadata: {}
            data: {}
            target:
              label_id: garagenlicht_draussen
          - wait_for_trigger:
              - type: turned_off
                device_id: f73cea3298336ec034d18b799be44fda
                entity_id: cf32195722ce8d45189932751aa979fd
                domain: binary_sensor
                trigger: device
                for:
                  hours: 0
                  minutes: 3
                  seconds: 0
            timeout:
              hours: 0
              minutes: 10
              seconds: 0
          - action: switch.turn_off
            metadata: {}
            data: {}
            target:
              label_id: garagenlicht_draussen
        alias: "Steuerung: Garage"
mode: single



Try using the trace feature to work out what is happening:

Good evening tom_l

Thank you very much for your quick reply.
I’ve been trying to do this since yesterday but I’m still not making much sense of this function.
I still don’t see the error.
This trigger works but the options do not… strange.
Greetings


![Screenshot 2025-02-08 210301|690x445]
(upload://8S2ihab79GX4ULnyWKDoOj0NDq4.png)


{
  "trace": {
    "last_step": "trigger",
    "run_id": "e0e29439f72e5886ba361995f8704e17",
    "state": "stopped",
    "script_execution": "failed_single",
    "timestamp": {
      "start": "2025-02-08T20:04:43.948817+00:00",
      "finish": "2025-02-08T20:04:43.949230+00:00"
    },
    "domain": "automation",
    "item_id": "1738679547501",
    "trigger": null,
    "trace": {
      "trigger": [
        {
          "path": "trigger",
          "timestamp": "2025-02-08T20:04:43.948903+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.home_aussenlicht",
              "state": "on",
              "attributes": {
                "id": "1738679547501",
                "last_triggered": "2025-02-08T20:01:08.231862+00:00",
                "mode": "single",
                "current": 1,
                "friendly_name": "Home Aussenlichtsteuerung"
              },
              "last_changed": "2025-02-07T21:01:12.634623+00:00",
              "last_reported": "2025-02-08T20:01:08.236863+00:00",
              "last_updated": "2025-02-08T20:01:08.231905+00:00",
              "context": {
                "id": "01JKKJDM47TV92636XJPJYG3P4",
                "parent_id": "01JKKJDM471EMCTFB66TSEJK5X",
                "user_id": null
              }
            },
            "trigger": {
              "platform": null
            }
          }
        }
      ]
    },
    "config": {
      "id": "1738679547501",
      "alias": "Home Aussenlichtsteuerung",
      "description": "",
      "triggers": [
        {
          "type": "occupied",
          "device_id": "3f20ae222847465ac96ebe0e90939da5",
          "entity_id": "b4500e411f15eab603c8a2c1857b0a50",
          "domain": "binary_sensor",
          "trigger": "device"
        },
        {
          "type": "occupied",
          "device_id": "e5dc9261210178d75a4d7e3851e4153d",
          "entity_id": "7cfdaffd1dceb09c707b1ea4e5fc40b8",
          "domain": "binary_sensor",
          "trigger": "device"
        },
        {
          "type": "turned_on",
          "device_id": "9d1d2fbffdd9c7063a6443d6f668506d",
          "entity_id": "e2f79899bb132f74a719d88c9d95796b",
          "domain": "binary_sensor",
          "trigger": "device"
        },
        {
          "type": "turned_on",
          "device_id": "f73cea3298336ec034d18b799be44fda",
          "entity_id": "cf32195722ce8d45189932751aa979fd",
          "domain": "binary_sensor",
          "trigger": "device"
        },
        {
          "type": "occupied",
          "device_id": "30662a923c784cad28b53b379f60da9e",
          "entity_id": "e113217dcfca91d01b62e1e5d0c2d27d",
          "domain": "binary_sensor",
          "trigger": "device"
        },
        {
          "type": "not_occupied",
          "device_id": "3f20ae222847465ac96ebe0e90939da5",
          "entity_id": "b4500e411f15eab603c8a2c1857b0a50",
          "domain": "binary_sensor",
          "trigger": "device",
          "for": {
            "hours": 0,
            "minutes": 3,
            "seconds": 0
          },
          "enabled": true
        },
        {
          "type": "not_occupied",
          "device_id": "e5dc9261210178d75a4d7e3851e4153d",
          "entity_id": "7cfdaffd1dceb09c707b1ea4e5fc40b8",
          "domain": "binary_sensor",
          "trigger": "device",
          "for": {
            "hours": 0,
            "minutes": 3,
            "seconds": 0
          },
          "enabled": true
        },
        {
          "type": "turned_off",
          "device_id": "9d1d2fbffdd9c7063a6443d6f668506d",
          "entity_id": "8d4228af8488e5f7a0a6ce7a126baa3b",
          "domain": "binary_sensor",
          "trigger": "device",
          "for": {
            "hours": 0,
            "minutes": 3,
            "seconds": 0
          },
          "enabled": true
        },
        {
          "type": "turned_off",
          "device_id": "f73cea3298336ec034d18b799be44fda",
          "entity_id": "cf32195722ce8d45189932751aa979fd",
          "domain": "binary_sensor",
          "trigger": "device",
          "for": {
            "hours": 0,
            "minutes": 3,
            "seconds": 0
          },
          "enabled": true
        },
        {
          "type": "not_occupied",
          "device_id": "30662a923c784cad28b53b379f60da9e",
          "entity_id": "e113217dcfca91d01b62e1e5d0c2d27d",
          "domain": "binary_sensor",
          "trigger": "device",
          "for": {
            "hours": 0,
            "minutes": 3,
            "seconds": 0
          },
          "enabled": true
        },
        {
          "type": "turned_on",
          "device_id": "9d1d2fbffdd9c7063a6443d6f668506d",
          "entity_id": "4047dea4d395ea07909f3fd8766d610c",
          "domain": "binary_sensor",
          "trigger": "device"
        },
        {
          "type": "turned_on",
          "device_id": "90efba41a64dd7d1833b3b2c919f764f",
          "entity_id": "595faab90316f8554969e1ebb58423c2",
          "domain": "binary_sensor",
          "trigger": "device"
        }
      ],
      "conditions": [
        {
          "type": "is_on",
          "condition": "device",
          "device_id": "9d1d2fbffdd9c7063a6443d6f668506d",
          "entity_id": "4047dea4d395ea07909f3fd8766d610c",
          "domain": "binary_sensor",
          "enabled": true
        }
      ],
      "actions": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "or",
                  "conditions": [
                    {
                      "type": "is_occupied",
                      "condition": "device",
                      "device_id": "e5dc9261210178d75a4d7e3851e4153d",
                      "entity_id": "7cfdaffd1dceb09c707b1ea4e5fc40b8",
                      "domain": "binary_sensor"
                    },
                    {
                      "type": "is_occupied",
                      "condition": "device",
                      "device_id": "3f20ae222847465ac96ebe0e90939da5",
                      "entity_id": "b4500e411f15eab603c8a2c1857b0a50",
                      "domain": "binary_sensor"
                    }
                  ]
                }
              ],
              "sequence": [
                {
                  "action": "light.turn_on",
                  "metadata": {},
                  "data": {},
                  "target": {
                    "label_id": "eingangslicht"
                  }
                },
                {
                  "wait_for_trigger": [
                    {
                      "type": "not_occupied",
                      "device_id": "e5dc9261210178d75a4d7e3851e4153d",
                      "entity_id": "7cfdaffd1dceb09c707b1ea4e5fc40b8",
                      "domain": "binary_sensor",
                      "trigger": "device",
                      "for": {
                        "hours": 0,
                        "minutes": 3,
                        "seconds": 0
                      }
                    },
                    {
                      "type": "not_occupied",
                      "device_id": "3f20ae222847465ac96ebe0e90939da5",
                      "entity_id": "b4500e411f15eab603c8a2c1857b0a50",
                      "domain": "binary_sensor",
                      "trigger": "device",
                      "for": {
                        "hours": 0,
                        "minutes": 3,
                        "seconds": 0
                      }
                    }
                  ],
                  "timeout": {
                    "hours": 0,
                    "minutes": 10,
                    "seconds": 0
                  }
                },
                {
                  "action": "light.turn_off",
                  "metadata": {},
                  "data": {},
                  "target": {
                    "label_id": "eingangslicht"
                  }
                }
              ],
              "alias": "Steuerung: Eingang"
            },
            {
              "conditions": [
                {
                  "type": "is_on",
                  "condition": "device",
                  "device_id": "9d1d2fbffdd9c7063a6443d6f668506d",
                  "entity_id": "e2f79899bb132f74a719d88c9d95796b",
                  "domain": "binary_sensor"
                }
              ],
              "sequence": [
                {
                  "action": "switch.turn_on",
                  "metadata": {},
                  "data": {},
                  "target": {
                    "label_id": [
                      "gartenlicht",
                      "garagenlicht"
                    ]
                  }
                },
                {
                  "wait_for_trigger": [
                    {
                      "type": "turned_off",
                      "device_id": "9d1d2fbffdd9c7063a6443d6f668506d",
                      "entity_id": "e2f79899bb132f74a719d88c9d95796b",
                      "domain": "binary_sensor",
                      "trigger": "device",
                      "for": {
                        "hours": 0,
                        "minutes": 3,
                        "seconds": 0
                      }
                    }
                  ],
                  "timeout": {
                    "hours": 0,
                    "minutes": 10,
                    "seconds": 0
                  }
                },
                {
                  "action": "switch.turn_off",
                  "metadata": {},
                  "data": {},
                  "target": {
                    "label_id": [
                      "gartenlicht",
                      "garagenlicht"
                    ]
                  }
                }
              ],
              "alias": "Steuerung: Garten"
            },
            {
              "conditions": [
                {
                  "condition": "and",
                  "conditions": [
                    {
                      "type": "is_occupied",
                      "condition": "device",
                      "device_id": "30662a923c784cad28b53b379f60da9e",
                      "entity_id": "e113217dcfca91d01b62e1e5d0c2d27d",
                      "domain": "binary_sensor"
                    },
                    {
                      "type": "is_on",
                      "condition": "device",
                      "device_id": "90efba41a64dd7d1833b3b2c919f764f",
                      "entity_id": "595faab90316f8554969e1ebb58423c2",
                      "domain": "binary_sensor"
                    }
                  ]
                }
              ],
              "sequence": [
                {
                  "action": "switch.turn_on",
                  "metadata": {},
                  "data": {},
                  "target": {
                    "label_id": "garagenlicht"
                  }
                },
                {
                  "wait_for_trigger": [
                    {
                      "type": "not_occupied",
                      "device_id": "30662a923c784cad28b53b379f60da9e",
                      "entity_id": "e113217dcfca91d01b62e1e5d0c2d27d",
                      "domain": "binary_sensor",
                      "trigger": "device",
                      "for": {
                        "hours": 0,
                        "minutes": 3,
                        "seconds": 0
                      }
                    }
                  ],
                  "timeout": {
                    "hours": 0,
                    "minutes": 10,
                    "seconds": 0
                  }
                },
                {
                  "action": "switch.turn_off",
                  "metadata": {},
                  "data": {},
                  "target": {
                    "label_id": "garagenlicht"
                  }
                }
              ],
              "alias": "Steuerung: Garage in"
            },
            {
              "conditions": [
                {
                  "type": "is_on",
                  "condition": "device",
                  "device_id": "f73cea3298336ec034d18b799be44fda",
                  "entity_id": "cf32195722ce8d45189932751aa979fd",
                  "domain": "binary_sensor"
                }
              ],
              "sequence": [
                {
                  "action": "switch.turn_on",
                  "metadata": {},
                  "data": {},
                  "target": {
                    "label_id": "garagenlicht_draussen"
                  }
                },
                {
                  "wait_for_trigger": [
                    {
                      "type": "turned_off",
                      "device_id": "f73cea3298336ec034d18b799be44fda",
                      "entity_id": "cf32195722ce8d45189932751aa979fd",
                      "domain": "binary_sensor",
                      "trigger": "device",
                      "for": {
                        "hours": 0,
                        "minutes": 3,
                        "seconds": 0
                      }
                    }
                  ],
                  "timeout": {
                    "hours": 0,
                    "minutes": 10,
                    "seconds": 0
                  }
                },
                {
                  "action": "switch.turn_off",
                  "metadata": {},
                  "data": {},
                  "target": {
                    "label_id": "garagenlicht_draussen"
                  }
                }
              ],
              "alias": "Steuerung: Garage"
            }
          ]
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01JKKJM6SCRZTRNHHP5BR5TAK8",
      "parent_id": "01JKKJM6SCXQKQPWF34YP9NEYM",
      "user_id": null
    }
  },
  "logbookEntries": []
}