weather: beep, disable inside sensor
parent
e9ad7e59e3
commit
5bf192e1be
|
@ -1,21 +1,21 @@
|
|||
local socket = require("socket")
|
||||
local http = require("socket.http")
|
||||
local https = require("https")
|
||||
local json = require("vendor.json")
|
||||
|
||||
local weatherURL = 'https://openweathermap.org/data/2.5/weather?id=6695624&units=metric&appid=b1b15e88fa797225412429c1c50c122a1'
|
||||
local insideURL = 'http://dht01.waw.hackerspace.pl/'
|
||||
local insideData = {}
|
||||
local weatherURL = 'https://openweathermap.org/data/2.5/weather?id=6695624&units=metric&appid=439d4b804bc8187953eb36d2a8c26a02'
|
||||
--local insideURL = 'https://dht01.waw.hackerspace.pl/'
|
||||
--local insideData = {}
|
||||
|
||||
local r, c, h = http.request(weatherURL)
|
||||
local c, r, h = https.request(weatherURL)
|
||||
if c == 200 then
|
||||
local data = json.decode(r)
|
||||
|
||||
local r, c, h = http.request(insideURL)
|
||||
if c == 200 then
|
||||
for n in string.gmatch(string.gsub(r, ",", "."), ":%s*(%S+)[*%%]") do
|
||||
insideData[#insideData+1] = n
|
||||
end
|
||||
end
|
||||
--local r, c, h = http.request(insideURL)
|
||||
--if c == 200 then
|
||||
-- for n in string.gmatch(string.gsub(r, ",", "."), ":%s*(%S+)[*%%]") do
|
||||
-- insideData[#insideData+1] = n
|
||||
-- end
|
||||
--end
|
||||
|
||||
love.thread.getChannel('weather'):push({
|
||||
weather = data.weather[1].main:lower(),
|
||||
|
@ -23,8 +23,8 @@ if c == 200 then
|
|||
lastUpdate = data.dt,
|
||||
sunRise = data.sys.sunrise,
|
||||
sunSet = data.sys.sunset,
|
||||
insideTemperature = insideData[1],
|
||||
insideHumidity = insideData[2],
|
||||
insideTemperature = nil,
|
||||
insideHumidity = nil,
|
||||
})
|
||||
print("Update finished")
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue