Timer didn't start correct

Moderator: leecollings

Post Reply
beffin
Posts: 1
Joined: Friday 23 November 2018 17:12
Target OS: -
Domoticz version:
Contact:

Timer didn't start correct

Post by beffin »

I have a problem with a script.
When I am in bed, my bedsensor gives the signal 'Open'. When I leave, it gives the signal 'Closed'. I would like to delay the closed signal by 15 min.
I'm trying to do this with the following script:

function timedifference(timestamp)
y, m, d, H, M, S = timestamp:match("(%d+)-(%d+)-(%d+) (%d+):(%d+):(%d+)")
difference = os.difftime(os.time(), os.time{year=y, month=m, day=d, hour=H, min=M, sec=S})
return difference
end
commandArray = {}

if(otherdevices['Bedsensor']=='Closed' and otherdevices['Rolluik auto'] == 'On' ) then

if (timedifference(otherdevices_lastupdate['Bedsensor']) > 60 ) then
print ('Bedsensor 15 min dicht: Rolluiken open')
commandArray['Rolluik auto']='Off'


end

end

The timer starts running immediately when the open signal is given. the timer should start running when the bedsensor gives the signal 'Closed'.

What did i wrong in the code?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest