Advertisement
boomx

Pulsecount

May 17th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. --[[
  2. %% properties
  3. 299 value
  4. %% globals
  5. --]]
  6.  
  7. local z_weather = 299
  8.  
  9. if (tonumber(fibaro:getValue(z_weather, "value")) > 0) then
  10. fibaro:debug('Z-Weather-Szene gestartet - ' ..os.date("%c"))
  11. if (tonumber(fibaro:getGlobalValue('time_past')) == 0) then
  12. fibaro:debug('Noch kein Wert in die Variable geschrieben - Wird automatisch angelegt.')
  13. fibaro:setGlobal('time_past', os.time()-900)
  14. end
  15. local time_past = fibaro:getGlobal('time_past')
  16. local last_run = (os.time() - time_past)/60
  17. fibaro:debug('Letzter Lauf der Szene vor ' ..math.floor(last_run).. ' min.')
  18. fibaro:debug('Pulsecount Z-Weather: ' ..fibaro:getValue(z_weather, "value"))
  19. multi = 1
  20. while last_run < 60 do
  21. multi = multi + 1
  22. last_run = last_run + last_run
  23. end
  24. fibaro:call(z_weather, "reset")
  25. local speed = math.floor((fibaro:getValue(z_weather, "value")*7.53)*multi)
  26. fibaro:debug('Berechnete Windgeschwindigkeit: ' ..(speed/100).. ' km/h')
  27. fibaro:debug('Pulsecount resettet.')
  28. fibaro:setGlobal('time_past', tostring(os.time()))
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement