Advertisement
NiklasO

IVT data-timer Domoticz

Jul 13th, 2016
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. commandArray = {}
  2. t1 = os.time()
  3. s = uservariables_lastupdate['IVTData']
  4. -- returns a date time like 2013-07-11 17:23:12
  5.  
  6. year = string.sub(s, 1, 4)
  7. month = string.sub(s, 6, 7)
  8. day = string.sub(s, 9, 10)
  9. hour = string.sub(s, 12, 13)
  10. minutes = string.sub(s, 15, 16)
  11. seconds = string.sub(s, 18, 19)
  12.  
  13. t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
  14. difference = (os.difftime (t1, t2))
  15.  
  16. print("IVTData last updated: " .. s .. " (" .. difference .. " seconds)." )
  17.  
  18. textDeviceIdx = 461
  19. commandArray[textDeviceIdx] = {['UpdateDevice'] = textDeviceIdx..'|0|'.. difference}
  20.  
  21. if (difference > 300) then
  22.    commandArray['SendNotification']='IVTData!#IVTData saknas sen mer än 5 minuter!'
  23. end
  24.  
  25. return commandArray
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement