I am looking for some help with the following:
I have a contact sensor that only send a "On" command. So i dont have a status to use for a event. Most of my events are in blocky.
To make an event i guess i has to be in Lua. Because i have no Status, i guess it has to be done with "lastupdate" from the device.
I tried to create something In lua/dzvents, but i simply dont understand the way of scripting. Can someine help me?
Please do not point me to the wiki page, because i have been there many times. But again, lua is abracadabra to me.
For my other contact sensor that sents On and off, i made this:
Code: Select all
t1 = os.time()
s = otherdevices_lastupdate['Raam']
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['Raam'] == 'Open' and difference > 3600 and difference < 3660 and otherdevices_svalues['Achtertuin'] > "18" and otherdevices_svalues['Achtertuin'] > otherdevices_svalues['1ste temp'])
or (otherdevices['Raam'] == 'Open' and difference > 3600 and difference < 3660 and otherdevices_svalues['Achtertuin'] < "5" and otherdevices_svalues['Achtertuin'] < otherdevices_svalues['1ste temp']) then
commandArray['SendNotification']='Raam open : # b #0#extradata#http'
print("Raam open")
end
return commandArray