不知道语句要怎么调用小米网关内的报警。
以下是报警开关
以下代码是测试通过的,当门窗打开超为10分钟可以开灯,二个原句我注释不。
先感谢大神指教如何调用多段开关内的选项。谢谢
代码: 全选
t1 = os.time()
s = otherdevices_lastupdate['小米门窗传感器']
-- 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)
commandArray = {}
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
if (otherdevices['小米门窗传感器'] == 'Open' and difference > 600) then
-- commandArray['SendNotification']='Garage door alert#The garage door has been open for more than 10 minutes!'
-- commandArray['小米门铃'] ='Knock on door #The garage door has been open for more than 10 minutes!'
commandArray['客厅灯4号'] = "On"
end
return commandArray