Advertisement
boomx

z-weather v0.5

May 18th, 2016
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. --[[
  2. %% properties
  3. 299 value
  4. %% globals
  5. --]]
  6.  
  7. -- BITTE BEACHTEN: BETA-VERSION
  8. -- ZU ERSTELLENDE GLOBALE VARIABLEN: time_past & wind_zweather
  9. -- ID muss angepasst werden, ID vom Pulsecounter
  10.  
  11. local z_weather = 299
  12.  
  13. if (tonumber(fibaro:getValue(z_weather, "value")) > 0) then
  14. fibaro:debug('Z-Weather-Szene gestartet - ' ..os.date("%c"))
  15. if (tonumber(fibaro:getGlobalValue('time_past')) == 0) then
  16. fibaro:debug('Noch kein Wert in die Variable geschrieben - Wird automatisch angelegt.')
  17. fibaro:setGlobal('time_past', os.time()-900)
  18. end
  19. local time_past = fibaro:getGlobal('time_past')
  20. local last_run = (os.time() - time_past)/60
  21. fibaro:debug('Letzter Lauf der Szene vor ' ..math.floor(last_run).. ' min.')
  22. fibaro:debug('Pulsecount Z-Weather: ' ..fibaro:getValue(z_weather, "value"))
  23. multi = 1
  24. if (last_run < 60) then
  25. while last_run < 60 do
  26. multi = multi + 1
  27. last_run = last_run + last_run
  28. end
  29. local speed = math.floor((fibaro:getValue(z_weather, "value")*7.53984)*multi)
  30. fibaro:setGlobal('wind_zweather', speed)
  31. else
  32. fibaro:debug('Z-Weather ist im Stromsparmodus; Daten werden nicht mehr zeitnah übermittelt...')
  33. local speed = math.floor((fibaro:getValue(z_weather, "value")*7.53984)/(last_run/60))
  34. fibaro:setGlobal('wind_zweather', speed)
  35. end
  36. fibaro:call(z_weather, "reset")
  37. fibaro:debug('Berechnete Windgeschwindigkeit: ' ..(fibaro:getGlobal('wind_zweather')/100).. ' km/h')
  38. fibaro:debug('Pulsecount resettet.')
  39. end
  40. fibaro:setGlobal('time_past', tostring(os.time()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement