Can somebody clarify why I'm getting send two notifications with 1 minute apart with this script.
I thought the time script run once a minute and I use a time diff. that are within 90 secs between greater than and smaller than. So it should not be triggered twice within two runs?
Is it the script that is wrong or my understanding of scripts?
Thanks,
BR Søren
Code: Select all
-- script_time_garagedooopen.lua
-- script from https://www.domoticz.com/wiki/Event_script_examples#Send_a_warning_when_the_garage_door_has_been_open_for_more_than_10_minutes
Domoticz_Devicename = 'Garage | Port 2'
t1 = os.time()
s = otherdevices_lastupdate[''..Domoticz_Devicename..'']
-- returns a date time like 2013-07-11 17:23:12
token = "xxx"
chatid = xxx
message = ''..Domoticz_Devicename..' har stået åbent i mere end 30 minutter!'
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
commandArray = {}
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
if (otherdevices[''..Domoticz_Devicename..''] == 'Open' and difference > 1800 and difference < 1890) then
os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..message..'" "https://api.telegram.org/bot'..token..'/sendMessage" ')
print('<b style="color:Blue">'..message..' Send pushnotification</b>')
end
return commandArray