forked from hswaw/hscloud
37 lines
939 B
Lua
37 lines
939 B
Lua
local socket = require("socket")
|
|
local https = require("https")
|
|
local json = require("vendor.json")
|
|
|
|
local weatherURL = 'https://openweathermap.org/data/2.5/weather?id=6695624&units=metric&appid=439d4b804bc8187953eb36d2a8c26a02'
|
|
local spejsiotURL = 'https://spejsiot.waw.hackerspace.pl/api/1/devices'
|
|
local atURL = 'https://at.hackerspace.pl/api'
|
|
local spejsiotData = {}
|
|
local atData = nil
|
|
|
|
local c, r, h = https.request(weatherURL)
|
|
if c == 200 then
|
|
local data = json.decode(r)
|
|
|
|
local c, r, h = https.request(spejsiotURL)
|
|
if c == 200 then
|
|
spejsiotData = json.decode(r)
|
|
end
|
|
|
|
local c, r, h = https.request(atURL)
|
|
|
|
if c == 200 then
|
|
atData = json.decode(r)
|
|
end
|
|
|
|
love.thread.getChannel('newdash'):push({
|
|
weather = data.weather[1].main:lower(),
|
|
temperature = data.main.temp,
|
|
lastUpdate = data.dt,
|
|
spejsiot = spejsiotData,
|
|
at = atData,
|
|
})
|
|
print("Update finished")
|
|
else
|
|
print("Update failed")
|
|
end
|