Hallo,
Al jarenlang maak ik gebruik van Domoticz en momenteel ben ik aan het overswitchen naar Homey. In Domoticz had ik een script dat mij om de 4 minuten een melding stuurt als de garagedeur openstaat. Nu wil ik dezelfde functionaliteit in Homey. Kan iemand mij misschien verder helpen?
Alvast dank
Het script dat ik in Domoticz gebruikte:
commandArray = {}
if (otherdevices[‘Garagedeur Script’]==‘On’) then
sensors = {‘Garagedeur’}
– All times in minutes
firstWarningTimeMinutes = 2
– Then repeat every … minutes
repeatTimeMinutes = 2
– First %s is the sensor name, the second one the time in minutes
firstWarningMessage = ‘Info#Let op, “%s” staat al meer dan %s minuten open!’
repeatWarningMessage = ‘Waarschuwing#LET OP, “%s” nog steeds open! Tijd open: %s minuten!!’
– Don’t edit below this line
firstWarningTime = firstWarningTimeMinutes * 60
repeatTime = repeatTimeMinutes * 60
timeNow = os.time()
– commandArray = {}
for index,sensor in pairs(sensors) do
s = otherdevices_lastupdate[sensor]
– returns a date time like 2013-07-11 17:23:12
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)
timeLastOpened = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (timeNow, timeLastOpened))
if (otherdevices[sensor] ~= 'Open' or difference < firstWarningTime) then
-- Door closed or within margin
return commandArray
end
if (difference <= (firstWarningTime + 60)) then
-- First warning
commandArray['SendNotification'] = string.format(firstWarningMessage, sensor, tostring(firstWarningTimeMinutes))
else
offset = (difference - firstWarningTime) % repeatTime
if offset > 0 and offset <= 60 then
commandArray['SendNotification'] = string.format(repeatWarningMessage, sensor, tostring(math.floor(difference / 60)))
end
end
end
return commandArray
end