There are a lot of moving pieces here and I’m not sure I understand them all.
With the new triggeringItem implicit variable I think you can do this easily, but it will require using Switchs for your buttons (I’ve been told one cannot sendCommand to a Contact). Then you can find out which Switch received the command and select the right Scene Item using Associated Items DP.
Obviously, the Group Persistence hack would probably also work in this case and you could keep the trigger the same, though will need persistence and Thread::sleep.
Or are you referencing the not the Contacts but the actual light Switches? If you are talking about the actual light Switches then what you are proposing with the forEach looks reasonable.
Possibly. My first thought would be to start a timer when the button is first pressed. If it is still pressed when the timer goes off dim a bit and start the timer again. Repeat until the button is released or the light reaches 0. The Cascading Timers or Design Pattern: Recursive Timers.
Use Generic Presence Detection, add this as a sensor. Then be sure to apply the Expire binding to time it out after a certain amount of time.
Or use the Wasp in the Box algorithm. At a high level, if the wasp in the box buzzes you know it is in the box. If the box hasn’t been opened, no matter how long ago the wasp buzzed, you know it is still in the box. Your buttons are the buzz and door sensors are your box opening sensor.