How do you think domoticz knows to cancel the timer you have set at "set off after..."?
You need to "build" your own timer. So add "AwayTimer" variable or virtual switch to use as a flag.
Then just add bit more cases there(Havent tested but it should work this way):
Code: Select all
If Away = On and AwayTimer = Off and Media = On <-- case when you leave the house
set AwayTimer = On After 5 minutes
Else if Away = On and AwayTimer = On and Media = On <-- case when timer time has passed and you are still away
set AwayTimer = Off
set Media = Off
Else if Away = Off and AwayTimer = On <-- case where you cancel the timer eg. return home within 5 minutes
set AwayTimer = Off
set Media = On <-- not sure if needed here
Else if Away = Off <-- case when you return to home
set Media = On
Perhaps some "cancel timers of device xxx" block could help to make these more simple looking.
I think its the same with PIR. You could check the "smart pir script" from wiki.