Improving my lighting Automations and Scripts

You can make a single main automation to call all your scripts with something like this:

alias: Control All zha lights
id: control_all_zha_lights
description: ""
mode: parallel
max: 25
trace:
  stored_traces: 25
triggers:
  - id: "Button"
    trigger: event
    event_type: zha_event    
  - entity_id:
      - binary_sensor.bedroom_hallway_occupancy_sensors
      ### LIST ALL ENTITY_IDs FOR MOTION DETECTION ###
      
    to: "on"
    id: "Occupancy"
    trigger: state
  - entity_id:
      - binary_sensor.bedroom_hallway_occupancy_sensors
      ### LIST ALL ENTITY_IDs FOR MOTION DETECTION ###

    to: "off"
    id: "Occupancy"
    trigger: state
    for:
      hours: 0
      minutes: 0
      seconds: 20

variables:
  config:
  
    #  Bedroom Hallway 
    - motions:
      - binary_sensor.bedroom_hallway_occupancy_sensors
      devices:
      - 359bc5a5f510d587696d3042b560c8b7
      multi_press_complete-3-2: Turn on Occupancy Sensing

      ### ADD OTHER ZHA COMBOS HERE DEPENDING ON DEVICE DIFFERENCES, MAP THEM TO YOUR SCRIPT INPUTS ###

      # OUTPUTS
      output:
        id: Bedroom Hallway
        nighttime_brightness: 7
        daytime_lighting_mode: Adaptive
        nighttime_lighting_mode: Nighttime
        occupancy_sensing: input_boolean.bedroom_hallway_occupancy_sensing
        lights:
        - light.bedroom_hallway_lights
    
    # ADD ADDITIONAL CONFIG ITEMS AS A LISTED ITEM HERE
      
    
  zha_event: >
    {% if trigger.id == "Button" %}
      {# This may change depending on your event data. #}
      {{ trigger.event.data.command }}-{{ trigger.event.data.endpoint_id }}-{{ trigger.event.data.params.get('total_number_of_presses_counted', 'x') }}
    {% else %}
      None
    {% endif %}
  target_config: >
    {% if zha_event is None %}
      {{ config | selectattr('motions', 'contains', trigger.entity_id) | list | first | default({}) }}
    {% else %}
      {{ config | selectattr('devices', 'contains', trigger.event.data.device_id) | list | first | default({}) }}
    {% endif %}
  trigger_id: >
    {% if zha_event is None %}
      Occupancy: Turn {{ trigger.to_state.state }} Lights
    {% elif target_config %}
      {% set event = target_config.get(zha_event) %}
      {{ "Button: " ~ event if event is not none else None }}
    {% else %}
      None
    {% endif %}
conditions:
- condition: template
  value_template: "{{ trigger_id is not None }}"
actions:
  - action: script.control_button_occupancy_day_night_lights
    data: >
      {{ dict(trigger_id=trigger_id, **target_config.output) }}

Understand this automation will be firing a lot.

You will need to make your script script.control_button_occupancy_day_night_lights parallel if it isn’t already.

The benefit of going this route is that everything from the zha_event variable and below never needs modifying. You only need to add items to the config. I added comments with how to manage it.

The take away here is that it will handle all zha events without needing to modify anything but the config and the entity_id’s in the occupancy triggers. When you add a new area, you just add a config and the occupancy entity_ids.

Your button configs will require you to watch zha_events in the event viewer and populate the information. Because you haven’t provided examples, I went off previous posts of yours for the one example I saw, which was in this post.

Your inovelli option in the config would be a zha combo button_2_double-3-x, where the x is in place of the number of presses which differs from the ikea events.

Lastly, if you need different for durations, that would just be separate triggers but you can bundle binary sensors with like durations. Just make sure to keep the trigger id as id: Occupancy.