Turn on lights with door lock - Second fly in ointment

A bit earlier, some folks here helped me come up with a scheme to time my lights coming on when the door is unlocked by sunrise and sunset. It’s working great – except I need to add something…

The scenario is: We’re leaving the house, we turn off all of the lights, go into the foyer and unlock the door – and the lights come back on (as expected by the automation). So then we have to go back into the house and turn the lights back off again, then leave (hopefully before the deadbolt re-lock sequence times out, which will turn the lights on again).

How can I add to my code to prevent this? I would like to able to turn the lights off in the house, unlock the door and leave. The lights would not come back on again until we return home and unlock the door.

My current code is:

- id: '1578666729834'
  alias: Interior lights on when front door unlocks after sunset
  description: ''
  trigger:
  - entity_id: lock.schlage_allegion_be469_touchscreen_deadbolt_locked
    platform: state
    to: unlocked
  condition:
  - condition: or
    conditions:
    - after: sunset
      after_offset: "-01:30:00"
      condition: sun
    - before: sunrise
      condition: sun
  action:
  - scene: scene.front_door_unlock_lights_on

Not quite sure why you are turning off the lights before you leave, why not just have the action of leaving turn off the lights.
Or if you must turn off all lights, with the exception of foyer, and have that on a delay to off (say 2mins)

  trigger:
  - entity_id: lock.schlage_allegion_be469_touchscreen_deadbolt_locked
    platform: state
    to: locked
  action:
  - scene: scene.front_door_lock_lights_off

@tom_l, @Mutt I’m wondering if this would create another scenario where someone is home with the lights on, and someone comes in the front door and when the door auto-locks, the lights go out?

Make the scene only control the foyer lights?

@tom_l, I had that set originally, but the main purpose of this is for my wife to feel comfortable coming home in the dark (we live in a relatively remote mountain area and some of the hill people are… interesting). So I altered the program to light up more of the house. The foyer setup definitely worked great, because it was easy to shut off the lights before leaving.

Rather than us guess what you want, I think you need to consider the options and work out what you AND your wife want to happen.
So far the picture you are painting is that your wife doesn’t like this house and is fairly uncomfortable in it (maybe just because of its location) if so … Move ! .
Do you have device trackers ? eg life360 on your phones ?
I assume the reason you want (seemingly) most of the house lit when you return is because you are wary of intruders, having gained entry whilst you were away ?
You need to sit down and write a specification of how it should work, don’t give a carpenter a vague gesture and complain when he gives you a 1 legged stool