Is there a good way to get this to work?

Hi guys, I was wondering if anybody knew a good way to get this to work.

I had this working at one point but would like to make it simpler without the booleans and inputnumbers.
I was going to do the janet project but couldnt figure it out. So i figured I would try to do a smaller TTS anouncement using my binary sensors instead.
automation.yaml

    - id: family_greeting
      alias: Family Greeting
      trigger:
        platform: state
        entity_id:
          - binary_sensor.cameron_home
          - binary_sensor.corey_home
          - binary_sensor.courtney_home
          - binary_sensor.mom_home
          - binary_sensor.morgan_home
          - binary_sensor.wendy_home
        from: 'off'
        to: 'on'
        for: '00:01:00'
      action:
        - wait_template: "{{ is_state('script.janet_speech_engine', 'off') }}"
        - service: script.janet_speech_engine
          data_template:
            person: >
              {{ trigger.to_state.name }}
              {%- for s in states.binary_sensor
                    |rejectattr('entity_id','eq',trigger.entity_id)
                    |selectattr('state','eq','on')
                    if '_home' in s.entity_id and
                       (now() - s.last_changed).total_seconds() < 60 -%}
                {{ (' and ' if loop.last else ', ') ~ s.name }}
              {%- endfor %}
            message: >
              {{ ["Welcome back home PERSON",
                  "Guess who is home. PERSON is!",
                  "PERSON is now in the house.",
                  "Welcome Home PERSON.  We have missed you. Or at least I did.",
                  "Our home is now complete, Rest your head and relax your feet, Welcome Back PERSON",
                  "Life is like a song, you’re back where you belong, Welcome home PERSON",
                  "Hey there PERSON Welcome Home!",
                  "Knock Knock. Who is There? PERSON is!",
                  "PERSON, you are home!",
                  "I know a secret. PERSON is home!"
                 ] | random }}

script.yaml

janet_speech_engine:
  sequence:
    - wait_template: >-
        {{ not is_state(states('input_select.janet_notification_media_player'), 'playing') }}   
    - service: script.janet_notification_hub
      data_template:
        speech_message: "{{ message.replace('PERSON',person) }}"
        media_player: "{{ states('input_select.janet_notification_media_player') }}"

Got my answer, mods you can delete this thread if you would like.