Advertisement
dinki

Untitled

Oct 21st, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. root@debian# less weatherupdater.lua
  2. local os = require('os')
  3. if content.subject == "event.environment.timechanged" then
  4. if content.minute == 00 or content.minute == 10 or content.minute == 20 or content.minute == 30 or content.minute == 40 or content.minute == 50 then
  5. inventory = getInventory()
  6. current_pressure = getVariable('current_pressure')
  7. current_temp = tonumber(getVariable('current_temp'))
  8. current_humidity = tonumber(getVariable('current_humidity'))
  9. -- caculate dewpoint
  10. dew_point = ((((current_temp -32)/1.8) - ((100 - current_humidity)/5)) * 9/5) +32
  11. dew_point = string.format("%.1f", dew_point)
  12. print (dew_point)
  13. wunder_date = os.date("!%Y-%m-%d+%H%%3A%M%%3A%S")
  14. wunder_url = "http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=xxxx3&PASSWORD=xxxx&action=updateraw&dateutc=" .. wunder_date
  15. wunder_url = wunder_url .. "&winddir=0&windspeedmph=0&windgustmph=0&dailyrainin=0&rainin=0"
  16. wunder_url = wunder_url .. "&baromin=" .. current_pressure
  17. wunder_url = wunder_url .. "&tempf=" .. current_temp
  18. wunder_url = wunder_url .. "&humidity=" .. current_humidity
  19. wunder_url = wunder_url .. "&dewptf=" .. dew_point
  20. os.execute ('curl ' .. '"' .. wunder_url .. '"')
  21. end
  22. end
  23. ( /etc/opt/agocontrol/lua )
  24. root@debian# less wunderground.lua
  25. local os = require('os')
  26.  
  27. -- Set Pressure
  28. if content.subject == "event.environment.pressurechanged" then
  29. inventory = getInventory()
  30. wunder_pressure = string.format("%.2f",(tonumber(content.level) * 0.000295301))
  31. setVariable('current_pressure', tostring(wunder_pressure))
  32. print ("Pressure is " .. inventory.variables.current_pressure)
  33. end
  34.  
  35. -- Set Outside Temp
  36. if (content.subject == "event.environment.temperaturechanged") and (content.uuid == "9591db57-319c-420b-a07d-7d50a393c990") then
  37. inventory = getInventory()
  38. print ("Temp is " .. content.level)
  39. wunder_temp = string.format("%.1f",tonumber(content.level))
  40. setVariable('current_temp', tostring(wunder_temp))
  41. end
  42.  
  43. -- Set Outside Humidity
  44. if (content.subject == "event.environment.humiditychanged") and (content.uuid == "d7c3274e-84a1-4213-b081-d9ac26724fa3") then
  45. inventory = getInventory()
  46. print ("Humidity is " .. content.level)
  47. wunder_humidity = string.format("%d",tonumber(content.level))
  48. setVariable('current_humidity', tostring(wunder_humidity))
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement