Advertisement
boomx

Z-Weather eng

May 31st, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. --[[
  2. %% properties
  3. 299 value
  4. %% globals
  5. --]]
  6.  
  7. -- YOU NEED THE GLOBAL VARS: time_past & wind_zweather
  8.  
  9. local z_weather = 299
  10.  
  11. if (tonumber(fibaro:getValue(z_weather, "value")) > 0) then
  12. fibaro:debug('Z-Weather triggered - ' ..os.date("%c"))
  13. if (tonumber(fibaro:getGlobal('time_past')) == 0) then
  14. fibaro:setGlobal('time_past', os.time()-900)
  15. end
  16. local time_past = fibaro:getGlobal('time_past')
  17. local last_run = (os.time() - time_past)/60
  18. fibaro:debug('Last run ' ..math.floor(last_run).. ' min.')
  19. fibaro:debug('Pulsecount Z-Weather: ' ..fibaro:getValue(z_weather, "value"))
  20. multi = 1
  21. if (last_run < 60) then
  22. while last_run < 60 do
  23. multi = multi + 1
  24. last_run = last_run + last_run
  25. end
  26. local speed = math.floor((fibaro:getValue(z_weather, "value")*7.53984)*multi)
  27. fibaro:setGlobal('wind_zweather', speed)
  28. else
  29. fibaro:debug('Z-Weather is power saving; Data will not be passed in a timely manner...')
  30. local speed = math.floor((fibaro:getValue(z_weather, "value")*7.53984)/(last_run/60))
  31. fibaro:setGlobal('wind_zweather', speed/100)
  32. end
  33. fibaro:call(z_weather, "reset")
  34. fibaro:debug('Calculated wind speed: ' ..(fibaro:getGlobal('wind_zweather')).. ' km/h')
  35. fibaro:debug('Pulsecount resettet.')
  36. end
  37. fibaro:setGlobal('time_past', tostring(os.time()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement