Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- root@debian# less weatherupdater.lua
- local os = require('os')
- if content.subject == "event.environment.timechanged" then
- 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
- inventory = getInventory()
- current_pressure = getVariable('current_pressure')
- current_temp = tonumber(getVariable('current_temp'))
- current_humidity = tonumber(getVariable('current_humidity'))
- -- caculate dewpoint
- dew_point = ((((current_temp -32)/1.8) - ((100 - current_humidity)/5)) * 9/5) +32
- dew_point = string.format("%.1f", dew_point)
- print (dew_point)
- wunder_date = os.date("!%Y-%m-%d+%H%%3A%M%%3A%S")
- wunder_url = "http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=xxxx3&PASSWORD=xxxx&action=updateraw&dateutc=" .. wunder_date
- wunder_url = wunder_url .. "&winddir=0&windspeedmph=0&windgustmph=0&dailyrainin=0&rainin=0"
- wunder_url = wunder_url .. "&baromin=" .. current_pressure
- wunder_url = wunder_url .. "&tempf=" .. current_temp
- wunder_url = wunder_url .. "&humidity=" .. current_humidity
- wunder_url = wunder_url .. "&dewptf=" .. dew_point
- os.execute ('curl ' .. '"' .. wunder_url .. '"')
- end
- end
- ( /etc/opt/agocontrol/lua )
- root@debian# less wunderground.lua
- local os = require('os')
- -- Set Pressure
- if content.subject == "event.environment.pressurechanged" then
- inventory = getInventory()
- wunder_pressure = string.format("%.2f",(tonumber(content.level) * 0.000295301))
- setVariable('current_pressure', tostring(wunder_pressure))
- print ("Pressure is " .. inventory.variables.current_pressure)
- end
- -- Set Outside Temp
- if (content.subject == "event.environment.temperaturechanged") and (content.uuid == "9591db57-319c-420b-a07d-7d50a393c990") then
- inventory = getInventory()
- print ("Temp is " .. content.level)
- wunder_temp = string.format("%.1f",tonumber(content.level))
- setVariable('current_temp', tostring(wunder_temp))
- end
- -- Set Outside Humidity
- if (content.subject == "event.environment.humiditychanged") and (content.uuid == "d7c3274e-84a1-4213-b081-d9ac26724fa3") then
- inventory = getInventory()
- print ("Humidity is " .. content.level)
- wunder_humidity = string.format("%d",tonumber(content.level))
- setVariable('current_humidity', tostring(wunder_humidity))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement