Help programming switch

I would like to program two on/off switch with very little success.

I have two switch. Let’s named them sw1 and sw2. What I would like is that if sw1 turns on for more than 5 mins, to automatically turn on sw2. But if it’s turn off before the five minutes, NOT to turn on sw2. Irrelevant if both switch are on, to put a timer and within 40 mins, to turn off both switches.

I was able to create two scene with a trigger, but where I’m facing difficult is, if you turn in sw1 and turn it on before 5 mins, it will still turn on sw2 but it won’t turn it off afterwards.

I recommend using the Program Logic Event Generator (PLEG) plugin for this type of programming. While it would be possible to do it by adding Lua code to your scenes, the solution would not be very robust and would fail if Vera restarted during one of the time intervals. PLEG restarts its timers after a Vera restart.

See PLEG Basics for an introduction.