Not sure why my automation isn't working

I’m trying to create an automation where

  1. the light will turn on if motion is detected 30 min before sunset to 11pm.
  2. if no motion is detected for 10 min, the light turns off.

I tried combining both in the same automation. I also make #1 separate to troubleshoot. Both do not work.

alias: Chandelier On/Off Sunset
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.front_door_motion_sensor
    to: "on"
    id: motionActive
  - platform: state
    entity_id:
      - binary_sensor.front_door_motion_sensor
    to: "off"
    id: motionInactive
    for:
      hours: 0
      minutes: 10
      seconds: 0
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: motionActive
        sequence:
          - choose:
              - conditions:
                  - condition: time
                    before: "23:00:00"
                  - condition: sun
                    after: sunset
                    after_offset: "-00:30:00"
                sequence:
                  - service: light.turn_on
                    target:
                      entity_id: light.chandelier_light
                    data: {}
      - conditions:
          - condition: trigger
            id: motionInactive
        sequence:
          - service: light.turn_off
            data: {}
            target:
              entity_id: light.chandelier_light
mode: restart

alias: Chandelier Light On Sunset
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.front_door_motion_sensor
    to: "on"
    id: motionActive
condition:
  - condition: sun
    after: sunset
    after_offset: "-00:30:00"
  - condition: time
    before: "23:00:00"
action:
  - service: light.turn_on
    target:
      entity_id: light.chandelier_light
    data: {}
mode: restart

I don’t see anything wrong with the second automation. What does the trace show ?

I think if I run the automation it ignores the conditions?

First condition passes while second condition fails which makes sense

If you trigger manually, only the action is executed.

Here is the group just to make sure I have it set right

Looking at the trace, it does not run when the conditions are not met.

When the conditions are met the automation does not run.

image

As @francisp said above, manually triggering skips the trigger and conditions, so the automation with the Choose action doesn’t have a trigger ID to check against. The second automation should work, but since the conditions are bypassed the light will turn on no matter what time it is when manually triggered.

What is weird is the automation works correctly in detecting the conditions. I have a trace where it did not run since the time was after 11pm.

The automation does not working correctly in turning on the light when the conditions are met.

The automation will run when the motion sensors are triggered, it just does not seem to turn on the light.

If you go to the Traces and click the kebab menu at the top right there’s an option to download the full json file of the trace. It’s a lot easier to see what going on if we have the full thing… and you don’t have to go through the hassle posting 20 screenshots.

The first thing to do is to remove the nested Choose.

alias: Chandelier On/Off Sunset
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.front_door_motion_sensor
    to: "on"
    id: motionActive
  - platform: state
    entity_id:
      - binary_sensor.front_door_motion_sensor
    to: "off"
    id: motionInactive
    for:
      hours: 0
      minutes: 10
      seconds: 0
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: motionActive
          - condition: time
            before: "23:00:00"
          - condition: sun
            after: sunset
            after_offset: "-00:30:00"
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.chandelier_light
            data: {}
      - conditions:
          - condition: trigger
            id: motionInactive
        sequence:
          - service: light.turn_off
            data: {}
            target:
              entity_id: light.chandelier_light
mode: restart

I did not realize I had nested conditions, this was my first attempt using conditions to simplify how many automations I have.

I think removing the nested conditions fixed it?

I created a new automation and ran the automation.

{
  "trace": {
    "last_step": "action/0/choose/1/conditions/0",
    "run_id": "622ff7409990497c5c9b80b969e2b4c4",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2024-03-16T07:34:47.634761+00:00",
      "finish": "2024-03-16T07:34:47.914284+00:00"
    },
    "domain": "automation",
    "item_id": "1710574062772",
    "trigger": null,
    "trace": {
      "trigger": [
        {
          "path": "trigger",
          "timestamp": "2024-03-16T07:34:47.635243+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.chandelier_on_off_sunset_2",
              "state": "on",
              "attributes": {
                "id": "1710574062772",
                "last_triggered": null,
                "mode": "restart",
                "current": 0,
                "friendly_name": "Chandelier On/Off Sunset 2"
              },
              "last_changed": "2024-03-16T07:30:06.431478+00:00",
              "last_updated": "2024-03-16T07:30:06.431478+00:00",
              "context": {
                "id": "01HS32NZEZMAK8B2CAPFQKNPHG",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "platform": null
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2024-03-16T07:34:47.685248+00:00",
          "changed_variables": {
            "context": {
              "id": "01HS32YJ1V7ZM3ZEX9W9QZ3ZJE",
              "parent_id": "01HS32YHBCJNV3WG6QKFJPZB1Y",
              "user_id": null
            }
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2024-03-16T07:34:47.742212+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2024-03-16T07:34:47.742532+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/1": [
        {
          "path": "action/0/choose/1",
          "timestamp": "2024-03-16T07:34:47.743216+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/1/conditions/0": [
        {
          "path": "action/0/choose/1/conditions/0",
          "timestamp": "2024-03-16T07:34:47.743380+00:00",
          "result": {
            "result": false
          }
        }
      ]
    },
    "config": {
      "id": "1710574062772",
      "alias": "Chandelier On/Off Sunset 2",
      "description": "",
      "trigger": [
        {
          "platform": "state",
          "entity_id": [
            "binary_sensor.front_door_motion_sensor"
          ],
          "to": "on",
          "id": "motionActive"
        },
        {
          "platform": "state",
          "entity_id": [
            "binary_sensor.front_door_motion_sensor"
          ],
          "to": "off",
          "id": "motionInactive",
          "for": {
            "hours": 0,
            "minutes": 10,
            "seconds": 0
          }
        }
      ],
      "condition": [],
      "action": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": "motionActive"
                },
                {
                  "condition": "time",
                  "before": "23:00:00"
                },
                {
                  "condition": "sun",
                  "after": "sunset",
                  "after_offset": "-00:30:00"
                }
              ],
              "sequence": [
                {
                  "service": "light.turn_on",
                  "target": {
                    "entity_id": "light.chandelier_light"
                  },
                  "data": {}
                }
              ]
            },
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": "motionInactive"
                }
              ],
              "sequence": [
                {
                  "service": "light.turn_off",
                  "data": {},
                  "target": {
                    "entity_id": "light.chandelier_light"
                  }
                }
              ]
            }
          ]
        }
      ],
      "mode": "restart"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HS32YJ1V7ZM3ZEX9W9QZ3ZJE",
      "parent_id": "01HS32YHBCJNV3WG6QKFJPZB1Y",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Chandelier On/Off Sunset 2",
      "message": "triggered",
      "source": null,
      "entity_id": "automation.chandelier_on_off_sunset_2",
      "context_id": "01HS32YJ1V7ZM3ZEX9W9QZ3ZJE",
      "when": 1710574487.635968,
      "domain": "automation"
    }
  ]
}

Here is my original automation trace with conditions

{
  "trace": {
    "last_step": "action/0/choose/0/sequence/0/choose/0/conditions/1",
    "run_id": "55dd382766a75b6752d981deb0ed0ce1",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2024-03-16T07:24:44.887748+00:00",
      "finish": "2024-03-16T07:24:45.237174+00:00"
    },
    "domain": "automation",
    "item_id": "1710078111277",
    "trigger": "state of binary_sensor.front_door_motion_sensor",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2024-03-16T07:24:44.916819+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.chandelier_on_off_sunset",
              "state": "on",
              "attributes": {
                "id": "1710078111277",
                "last_triggered": "2024-03-16T07:23:41.964858+00:00",
                "mode": "restart",
                "current": 0,
                "friendly_name": "Chandelier On/Off Sunset"
              },
              "last_changed": "2024-03-16T05:45:25.785780+00:00",
              "last_updated": "2024-03-16T07:23:42.450280+00:00",
              "context": {
                "id": "01HS32A804S64JG0SQZAYQJDKP",
                "parent_id": "01HS32A62JBP0734C1TPR4QXHP",
                "user_id": null
              }
            },
            "trigger": {
              "id": "motionActive",
              "idx": "0",
              "alias": null,
              "platform": "state",
              "entity_id": "binary_sensor.front_door_motion_sensor",
              "from_state": {
                "entity_id": "binary_sensor.front_door_motion_sensor",
                "state": "off",
                "attributes": {
                  "entity_id": [
                    "binary_sensor.front_door_motion_sensor_1_occupancy",
                    "binary_sensor.front_door_motion_sensor_2_occupancy",
                    "binary_sensor.front_door_motion_sensor_3_occupancy",
                    "binary_sensor.front_door_motion_sensor_motion_detection"
                  ],
                  "friendly_name": "Front Door Motion Sensor"
                },
                "last_changed": "2024-03-16T07:24:39.562968+00:00",
                "last_updated": "2024-03-16T07:24:39.562968+00:00",
                "context": {
                  "id": "01HS32BZGQMR2HVR3WTC3WDKEP",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "binary_sensor.front_door_motion_sensor",
                "state": "on",
                "attributes": {
                  "entity_id": [
                    "binary_sensor.front_door_motion_sensor_1_occupancy",
                    "binary_sensor.front_door_motion_sensor_2_occupancy",
                    "binary_sensor.front_door_motion_sensor_3_occupancy",
                    "binary_sensor.front_door_motion_sensor_motion_detection"
                  ],
                  "friendly_name": "Front Door Motion Sensor"
                },
                "last_changed": "2024-03-16T07:24:44.806996+00:00",
                "last_updated": "2024-03-16T07:24:44.806996+00:00",
                "context": {
                  "id": "01HS32C5C2J48NYQ3MZGR30DF4",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of binary_sensor.front_door_motion_sensor"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2024-03-16T07:24:45.048755+00:00",
          "changed_variables": {
            "context": {
              "id": "01HS32C5EQFBCWT22GRS0W2NYA",
              "parent_id": "01HS32C5C2J48NYQ3MZGR30DF4",
              "user_id": null
            }
          },
          "result": {
            "choice": 0
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2024-03-16T07:24:45.049440+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2024-03-16T07:24:45.049750+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/0/sequence/0": [
        {
          "path": "action/0/choose/0/sequence/0",
          "timestamp": "2024-03-16T07:24:45.111849+00:00"
        }
      ],
      "action/0/choose/0/sequence/0/choose/0": [
        {
          "path": "action/0/choose/0/sequence/0/choose/0",
          "timestamp": "2024-03-16T07:24:45.112754+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/sequence/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/sequence/0/choose/0/conditions/0",
          "timestamp": "2024-03-16T07:24:45.113150+00:00",
          "result": {
            "after": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "00:00:00"
            },
            "now_time": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "00:24:45.113313"
            },
            "before": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "23:00:00"
            },
            "result": true
          }
        }
      ],
      "action/0/choose/0/sequence/0/choose/0/conditions/1": [
        {
          "path": "action/0/choose/0/sequence/0/choose/0/conditions/1",
          "timestamp": "2024-03-16T07:24:45.113820+00:00",
          "result": {
            "wanted_time_after": "2024-03-17T01:45:19.893275+00:00",
            "result": false
          }
        }
      ]
    },
    "config": {
      "id": "1710078111277",
      "alias": "Chandelier On/Off Sunset",
      "description": "",
      "trigger": [
        {
          "platform": "state",
          "entity_id": [
            "binary_sensor.front_door_motion_sensor"
          ],
          "to": "on",
          "id": "motionActive"
        },
        {
          "platform": "state",
          "entity_id": [
            "binary_sensor.front_door_motion_sensor"
          ],
          "to": "off",
          "id": "motionInactive",
          "for": {
            "hours": 0,
            "minutes": 10,
            "seconds": 0
          }
        }
      ],
      "condition": [],
      "action": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": "motionActive"
                }
              ],
              "sequence": [
                {
                  "choose": [
                    {
                      "conditions": [
                        {
                          "condition": "time",
                          "before": "23:00:00"
                        },
                        {
                          "condition": "sun",
                          "after": "sunset",
                          "after_offset": "-00:30:00"
                        }
                      ],
                      "sequence": [
                        {
                          "service": "light.turn_on",
                          "target": {
                            "entity_id": "light.chandelier_light"
                          },
                          "data": {}
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": "motionInactive"
                }
              ],
              "sequence": [
                {
                  "service": "light.turn_off",
                  "data": {},
                  "target": {
                    "entity_id": "light.chandelier_light"
                  }
                }
              ]
            }
          ]
        }
      ],
      "mode": "restart"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HS32C5EQFBCWT22GRS0W2NYA",
      "parent_id": "01HS32C5C2J48NYQ3MZGR30DF4",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Chandelier On/Off Sunset",
      "message": "triggered by state of binary_sensor.front_door_motion_sensor",
      "source": "state of binary_sensor.front_door_motion_sensor",
      "entity_id": "automation.chandelier_on_off_sunset",
      "context_id": "01HS32C5EQFBCWT22GRS0W2NYA",
      "when": 1710573884.917814,
      "domain": "automation"
    }
  ]
}

Here’s another trace with the same motion sensors but different time conditions.

I think

  1. Either my motion sensors are not triggering the automation
    or
  2. Something is wrong with my sunrise/sunset/sun next, etc entities

Can I group z-wave and zigbee motion sensors together?

{
  "trace": {
    "last_step": "action/2",
    "run_id": "c292efa90e7f68bcdaebd3e80f194342",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2024-03-16T13:38:53.035445+00:00",
      "finish": "2024-03-16T13:49:01.578632+00:00"
    },
    "domain": "automation",
    "item_id": "1710078343439",
    "trigger": "state of binary_sensor.front_door_motion_sensor",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2024-03-16T13:38:53.036482+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.front_door_ceiling_light_on_off_sunset",
              "state": "on",
              "attributes": {
                "id": "1710078343439",
                "last_triggered": "2024-03-16T13:37:41.661517+00:00",
                "mode": "restart",
                "current": 1,
                "friendly_name": "Front Door Ceiling Light On/Off Overnight"
              },
              "last_changed": "2024-03-16T13:35:46.829171+00:00",
              "last_updated": "2024-03-16T13:37:41.661856+00:00",
              "context": {
                "id": "01HS3QQ1QQN7SZN6Q078EQTNDP",
                "parent_id": "01HS3QQ0MBQPZ329E0K1TERJWM",
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "state",
              "entity_id": "binary_sensor.front_door_motion_sensor",
              "from_state": {
                "entity_id": "binary_sensor.front_door_motion_sensor",
                "state": "off",
                "attributes": {
                  "entity_id": [
                    "binary_sensor.front_door_motion_sensor_1_occupancy",
                    "binary_sensor.front_door_motion_sensor_2_occupancy",
                    "binary_sensor.front_door_motion_sensor_3_occupancy",
                    "binary_sensor.front_door_motion_sensor_motion_detection"
                  ],
                  "friendly_name": "Front Door Motion Sensor"
                },
                "last_changed": "2024-03-16T13:37:50.288681+00:00",
                "last_updated": "2024-03-16T13:37:50.288681+00:00",
                "context": {
                  "id": "01HS3QQA08AG0TZJ6S7VJYQ779",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "binary_sensor.front_door_motion_sensor",
                "state": "on",
                "attributes": {
                  "entity_id": [
                    "binary_sensor.front_door_motion_sensor_1_occupancy",
                    "binary_sensor.front_door_motion_sensor_2_occupancy",
                    "binary_sensor.front_door_motion_sensor_3_occupancy",
                    "binary_sensor.front_door_motion_sensor_motion_detection"
                  ],
                  "friendly_name": "Front Door Motion Sensor"
                },
                "last_changed": "2024-03-16T13:38:52.703359+00:00",
                "last_updated": "2024-03-16T13:38:52.703359+00:00",
                "context": {
                  "id": "01HS3QS6R0D8984KJWG3HBAJBK",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of binary_sensor.front_door_motion_sensor"
            }
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2024-03-16T13:38:53.036781+00:00",
          "result": {
            "after": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "23:00:00"
            },
            "now_time": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "06:38:53.036886"
            },
            "before": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "07:15:33"
            },
            "result": true
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2024-03-16T13:38:53.177942+00:00",
          "changed_variables": {
            "context": {
              "id": "01HS3QS7FB3WPRR8WJHA6KY41J",
              "parent_id": "01HS3QS6R0D8984KJWG3HBAJBK",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "light",
              "service": "turn_on",
              "service_data": {
                "brightness_pct": 75,
                "entity_id": [
                  "light.ceiling_light"
                ]
              },
              "target": {
                "entity_id": [
                  "light.ceiling_light"
                ]
              }
            },
            "running_script": false
          }
        }
      ],
      "action/1": [
        {
          "path": "action/1",
          "timestamp": "2024-03-16T13:38:53.235804+00:00",
          "result": {
            "delay": 600,
            "done": true
          }
        }
      ],
      "action/2": [
        {
          "path": "action/2",
          "timestamp": "2024-03-16T13:48:54.398886+00:00",
          "result": {
            "params": {
              "domain": "light",
              "service": "turn_off",
              "service_data": {},
              "target": {
                "entity_id": [
                  "light.ceiling_light"
                ]
              }
            },
            "running_script": false
          }
        }
      ]
    },
    "config": {
      "id": "1710078343439",
      "alias": "Front Door Ceiling Light On/Off Overnight",
      "description": "",
      "trigger": [
        {
          "platform": "state",
          "entity_id": [
            "binary_sensor.front_door_motion_sensor"
          ],
          "to": "on"
        }
      ],
      "condition": [
        {
          "condition": "time",
          "after": "23:00:00",
          "before": "sensor.sun_next_rising"
        }
      ],
      "action": [
        {
          "service": "light.turn_on",
          "target": {
            "entity_id": "light.ceiling_light"
          },
          "data": {
            "brightness_pct": 75
          }
        },
        {
          "delay": {
            "hours": 0,
            "minutes": 10,
            "seconds": 0,
            "milliseconds": 0
          }
        },
        {
          "service": "light.turn_off",
          "target": {
            "entity_id": "light.ceiling_light"
          },
          "data": {}
        }
      ],
      "mode": "restart"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HS3QS7FB3WPRR8WJHA6KY41J",
      "parent_id": "01HS3QS6R0D8984KJWG3HBAJBK",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Front Door Ceiling Light On/Off Overnight",
      "message": "triggered by state of binary_sensor.front_door_motion_sensor",
      "source": "state of binary_sensor.front_door_motion_sensor",
      "entity_id": "automation.front_door_ceiling_light_on_off_sunset",
      "context_id": "01HS3QS7FB3WPRR8WJHA6KY41J",
      "when": 1710596333.167728,
      "domain": "automation"
    }
  ]
}

Yes. As long as they are exposed as entities, HA doesn’t care about the source protocols.

The majority of the time it does not work. Not sure why.

{
  "trace": {
    "last_step": "action/0/choose/1/conditions/0",
    "run_id": "5c874a8f26c216efbff8a481bfe4a718",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2024-03-21T13:27:17.771771+00:00",
      "finish": "2024-03-21T13:27:17.942005+00:00"
    },
    "domain": "automation",
    "item_id": "1710574062772",
    "trigger": "state of binary_sensor.front_door_motion_sensor",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2024-03-21T13:27:17.773903+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.chandelier_on_off_sunset_2",
              "state": "on",
              "attributes": {
                "id": "1710574062772",
                "last_triggered": "2024-03-21T05:45:28.300312+00:00",
                "mode": "restart",
                "current": 0,
                "friendly_name": "Chandelier On/Off Sunset 2"
              },
              "last_changed": "2024-03-17T13:08:58.689711+00:00",
              "last_updated": "2024-03-21T05:45:28.603371+00:00",
              "context": {
                "id": "01HSFRNZF58VVKQGH037V880VW",
                "parent_id": "01HSFRNZ4M0YCBGYHCXQJ5432T",
                "user_id": null
              }
            },
            "trigger": {
              "id": "motionActive",
              "idx": "0",
              "alias": null,
              "platform": "state",
              "entity_id": "binary_sensor.front_door_motion_sensor",
              "from_state": {
                "entity_id": "binary_sensor.front_door_motion_sensor",
                "state": "off",
                "attributes": {
                  "entity_id": [
                    "binary_sensor.front_door_motion_sensor_1_occupancy",
                    "binary_sensor.front_door_motion_sensor_2_occupancy",
                    "binary_sensor.front_door_motion_sensor_3_occupancy",
                    "binary_sensor.front_door_motion_sensor_motion_detection"
                  ],
                  "friendly_name": "Front Door Motion Sensor"
                },
                "last_changed": "2024-03-21T13:26:28.160879+00:00",
                "last_updated": "2024-03-21T13:26:28.160879+00:00",
                "context": {
                  "id": "01HSGK22MQ1MXD7FGKBX500X66",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "binary_sensor.front_door_motion_sensor",
                "state": "on",
                "attributes": {
                  "entity_id": [
                    "binary_sensor.front_door_motion_sensor_1_occupancy",
                    "binary_sensor.front_door_motion_sensor_2_occupancy",
                    "binary_sensor.front_door_motion_sensor_3_occupancy",
                    "binary_sensor.front_door_motion_sensor_motion_detection"
                  ],
                  "friendly_name": "Front Door Motion Sensor"
                },
                "last_changed": "2024-03-21T13:27:17.670400+00:00",
                "last_updated": "2024-03-21T13:27:17.670400+00:00",
                "context": {
                  "id": "01HSGK3K93TY3073B73NH868FC",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of binary_sensor.front_door_motion_sensor"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2024-03-21T13:27:17.791899+00:00",
          "changed_variables": {
            "context": {
              "id": "01HSGK3KGBGHCG4TM82NX0FWD7",
              "parent_id": "01HSGK3K93TY3073B73NH868FC",
              "user_id": null
            }
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2024-03-21T13:27:17.799118+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2024-03-21T13:27:17.799503+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/0/conditions/1": [
        {
          "path": "action/0/choose/0/conditions/1",
          "timestamp": "2024-03-21T13:27:17.799760+00:00",
          "result": {
            "after": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "00:00:00"
            },
            "now_time": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "06:27:17.799838"
            },
            "before": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "23:00:00"
            },
            "result": true
          }
        }
      ],
      "action/0/choose/0/conditions/2": [
        {
          "path": "action/0/choose/0/conditions/2",
          "timestamp": "2024-03-21T13:27:17.800002+00:00",
          "result": {
            "wanted_time_after": "2024-03-22T01:50:01.322738+00:00",
            "result": false
          }
        }
      ],
      "action/0/choose/1": [
        {
          "path": "action/0/choose/1",
          "timestamp": "2024-03-21T13:27:17.802713+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/1/conditions/0": [
        {
          "path": "action/0/choose/1/conditions/0",
          "timestamp": "2024-03-21T13:27:17.802905+00:00",
          "result": {
            "result": false
          }
        }
      ]
    },
    "config": {
      "id": "1710574062772",
      "alias": "Chandelier On/Off Sunset 2",
      "description": "",
      "trigger": [
        {
          "platform": "state",
          "entity_id": [
            "binary_sensor.front_door_motion_sensor"
          ],
          "to": "on",
          "id": "motionActive"
        },
        {
          "platform": "state",
          "entity_id": [
            "binary_sensor.front_door_motion_sensor"
          ],
          "to": "off",
          "id": "motionInactive",
          "for": {
            "hours": 0,
            "minutes": 10,
            "seconds": 0
          }
        }
      ],
      "condition": [],
      "action": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": "motionActive"
                },
                {
                  "condition": "time",
                  "before": "23:00:00"
                },
                {
                  "condition": "sun",
                  "after": "sunset",
                  "after_offset": "-00:30:00"
                }
              ],
              "sequence": [
                {
                  "service": "light.turn_on",
                  "target": {
                    "entity_id": "light.chandelier_light"
                  },
                  "data": {}
                }
              ]
            },
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": "motionInactive"
                }
              ],
              "sequence": [
                {
                  "service": "light.turn_off",
                  "data": {},
                  "target": {
                    "entity_id": "light.chandelier_light"
                  }
                }
              ]
            }
          ]
        }
      ],
      "mode": "restart"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HSGK3KGBGHCG4TM82NX0FWD7",
      "parent_id": "01HSGK3K93TY3073B73NH868FC",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Chandelier On/Off Sunset 2",
      "message": "triggered by state of binary_sensor.front_door_motion_sensor",
      "source": "state of binary_sensor.front_door_motion_sensor",
      "entity_id": "automation.chandelier_on_off_sunset_2",
      "context_id": "01HSGK3KGBGHCG4TM82NX0FWD7",
      "when": 1711027637.774492,
      "domain": "automation"
    }
  ]
}

It should run when any of these motion sensors are detected?

image

{
  "trace": {
    "last_step": "action/0/choose/1/conditions/0",
    "run_id": "f9c581751f3b164b8a8f7d64d215dcfb",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2024-03-22T07:38:49.466654+00:00",
      "finish": "2024-03-22T07:38:49.593719+00:00"
    },
    "domain": "automation",
    "item_id": "1710574062772",
    "trigger": "state of binary_sensor.front_door_motion_sensor",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2024-03-22T07:38:49.467212+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.chandelier_on_off_sunset_2",
              "state": "on",
              "attributes": {
                "id": "1710574062772",
                "last_triggered": "2024-03-22T07:32:32.078675+00:00",
                "mode": "restart",
                "current": 0,
                "friendly_name": "Chandelier On/Off Sunset 2"
              },
              "last_changed": "2024-03-17T13:08:58.689711+00:00",
              "last_updated": "2024-03-22T07:32:40.831919+00:00",
              "context": {
                "id": "01HSJH707Z2MJTK883AWP0XRPA",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "motionActive",
              "idx": "0",
              "alias": null,
              "platform": "state",
              "entity_id": "binary_sensor.front_door_motion_sensor",
              "from_state": {
                "entity_id": "binary_sensor.front_door_motion_sensor",
                "state": "off",
                "attributes": {
                  "entity_id": [
                    "binary_sensor.front_door_motion_sensor_1_occupancy",
                    "binary_sensor.front_door_motion_sensor_2_occupancy",
                    "binary_sensor.front_door_motion_sensor_3_occupancy",
                    "binary_sensor.front_door_motion_sensor_motion_detection"
                  ],
                  "friendly_name": "Front Door Motion Sensor"
                },
                "last_changed": "2024-03-22T07:37:58.321640+00:00",
                "last_updated": "2024-03-22T07:37:58.321640+00:00",
                "context": {
                  "id": "01HSJHGNHK9GKXJE3ZJ8N8NSFV",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "binary_sensor.front_door_motion_sensor",
                "state": "on",
                "attributes": {
                  "entity_id": [
                    "binary_sensor.front_door_motion_sensor_1_occupancy",
                    "binary_sensor.front_door_motion_sensor_2_occupancy",
                    "binary_sensor.front_door_motion_sensor_3_occupancy",
                    "binary_sensor.front_door_motion_sensor_motion_detection"
                  ],
                  "friendly_name": "Front Door Motion Sensor"
                },
                "last_changed": "2024-03-22T07:38:49.374224+00:00",
                "last_updated": "2024-03-22T07:38:49.374224+00:00",
                "context": {
                  "id": "01HSJHJ7ZYDYQ1DB19VX91NR42",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "attribute": null,
              "description": "state of binary_sensor.front_door_motion_sensor"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2024-03-22T07:38:49.559060+00:00",
          "changed_variables": {
            "context": {
              "id": "01HSJHJ87TYKDCG521GSMT5JB7",
              "parent_id": "01HSJHJ7ZYDYQ1DB19VX91NR42",
              "user_id": null
            }
          }
        }
      ],
      "action/0/choose/0": [
        {
          "path": "action/0/choose/0",
          "timestamp": "2024-03-22T07:38:49.559625+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/0/conditions/0": [
        {
          "path": "action/0/choose/0/conditions/0",
          "timestamp": "2024-03-22T07:38:49.559865+00:00",
          "result": {
            "result": true
          }
        }
      ],
      "action/0/choose/0/conditions/1": [
        {
          "path": "action/0/choose/0/conditions/1",
          "timestamp": "2024-03-22T07:38:49.560106+00:00",
          "result": {
            "after": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "00:00:00"
            },
            "now_time": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "00:38:49.560184"
            },
            "before": {
              "__type": "<class 'datetime.time'>",
              "isoformat": "23:00:00"
            },
            "result": true
          }
        }
      ],
      "action/0/choose/0/conditions/2": [
        {
          "path": "action/0/choose/0/conditions/2",
          "timestamp": "2024-03-22T07:38:49.560399+00:00",
          "result": {
            "wanted_time_after": "2024-03-23T01:50:57.210633+00:00",
            "result": false
          }
        }
      ],
      "action/0/choose/1": [
        {
          "path": "action/0/choose/1",
          "timestamp": "2024-03-22T07:38:49.562074+00:00",
          "result": {
            "result": false
          }
        }
      ],
      "action/0/choose/1/conditions/0": [
        {
          "path": "action/0/choose/1/conditions/0",
          "timestamp": "2024-03-22T07:38:49.562339+00:00",
          "result": {
            "result": false
          }
        }
      ]
    },
    "config": {
      "id": "1710574062772",
      "alias": "Chandelier On/Off Sunset 2",
      "description": "",
      "trigger": [
        {
          "platform": "state",
          "entity_id": [
            "binary_sensor.front_door_motion_sensor"
          ],
          "to": "on",
          "id": "motionActive"
        },
        {
          "platform": "state",
          "entity_id": [
            "binary_sensor.front_door_motion_sensor"
          ],
          "to": "off",
          "id": "motionInactive",
          "for": {
            "hours": 0,
            "minutes": 10,
            "seconds": 0
          }
        }
      ],
      "condition": [],
      "action": [
        {
          "choose": [
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": "motionActive"
                },
                {
                  "condition": "time",
                  "before": "23:00:00"
                },
                {
                  "condition": "sun",
                  "after": "sunset",
                  "after_offset": "-00:30:00"
                }
              ],
              "sequence": [
                {
                  "service": "light.turn_on",
                  "target": {
                    "entity_id": "light.chandelier_light"
                  },
                  "data": {}
                }
              ]
            },
            {
              "conditions": [
                {
                  "condition": "trigger",
                  "id": "motionInactive"
                }
              ],
              "sequence": [
                {
                  "service": "light.turn_off",
                  "data": {},
                  "target": {
                    "entity_id": "light.chandelier_light"
                  }
                }
              ]
            }
          ]
        }
      ],
      "mode": "restart"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01HSJHJ87TYKDCG521GSMT5JB7",
      "parent_id": "01HSJHJ7ZYDYQ1DB19VX91NR42",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Chandelier On/Off Sunset 2",
      "message": "triggered by state of binary_sensor.front_door_motion_sensor",
      "source": "state of binary_sensor.front_door_motion_sensor",
      "entity_id": "automation.chandelier_on_off_sunset_2",
      "context_id": "01HSJHJ87TYKDCG521GSMT5JB7",
      "when": 1711093129.467691,
      "domain": "automation"
    }
  ]
}

The automation seems to work but not running during the times I do not want.

However, it does not seem to be triggered during the times I set in the automation?

If the trigger is a group containing those sensors, it should fire when the group’s state changes from off to on… it will not fire every time one of the sensors turns “on” if other group member sensors are already “on”.

You don’t have any time-based triggers… can you clarify what you mean?

I know this may seem pedantic, but in order to debug the issue we need a clear picture of what your complaint is… i.e. What isn’t happening that you expect to happen.

I think he refers to this:

If the trigger is a group containing those sensors, it should fire when the group’s state changes from off to on… it will not fire every time one of the sensors turns “on” if other group member sensors are already “on”.

Got it. I am misunderstanding what I expect the group state to do.

If I want the trigger to fire every time one of the sensors turns on, I would have to delete the group? Each motion sensor would be their own trigger in the automation?

Yes, one trigger for each motion sensor.

alias: Chandelier On/Off Sunset 2
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.front_door_motion_sensor
    to: "on"
    id: motionActive
  - platform: state
    entity_id:
      - binary_sensor.front_door_motion_sensor_1_occupancy
    to: "on"
    id: motionActive
  - platform: state
    entity_id:
      - binary_sensor.front_door_motion_sensor_2_occupancy
    to: "on"
    id: motionActive
  - platform: state
    entity_id:
      - binary_sensor.front_door_motion_sensor_3_occupancy
    to: "on"
    id: motionActive
  - platform: state
    entity_id:
      - binary_sensor.front_door_motion_sensor
    to: "off"
    id: motionInactive
    for:
      hours: 0
      minutes: 10
      seconds: 0
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: motionActive
          - condition: time
            before: "23:00:00"
          - condition: sun
            before: sunset
            before_offset: "-00:30:00"
        sequence:
          - service: light.turn_on
            target:
              entity_id: light.chandelier_light
            data: {}
      - conditions:
          - condition: trigger
            id: motionInactive
        sequence:
          - service: light.turn_off
            data: {}
            target:
              entity_id: light.chandelier_light
mode: restart

This is what I think my automation does now.

From 30 min before sunset to 11pm, if any of the four motion sensors are triggered the light will turn on. If no motion is detected for any one of the four motion sensors, the light will turn off.

If any motion is detected for 10 minutes from one of the four motion sensors, the light will not turn off.

With the restart, any motion detected will restart the count down of no motion is detected for 10 minutes.

And, is it working now?