summaryrefslogtreecommitdiffstats
path: root/screens/weather_thread.lua
diff options
context:
space:
mode:
Diffstat (limited to 'screens/weather_thread.lua')
-rw-r--r--screens/weather_thread.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/screens/weather_thread.lua b/screens/weather_thread.lua
new file mode 100644
index 0000000..7638c9a
--- /dev/null
+++ b/screens/weather_thread.lua
@@ -0,0 +1,18 @@
+local socket = require("socket")
+local http = require("socket.http")
+local json = require("vendor.json")
+local inspect = require('vendor.inspect')
+-- local weatherURL = 'http://api.wunderground.com/api/0def10027afaebb7/conditions/q/PL/Warszawa.json'
+local weatherURL = 'https://openweathermap.org/data/2.5/weather?id=6695624&units=metric&appid=b1b15e88fa797225412429c1c50c122a1'
+
+local r, c, h = http.request(weatherURL)
+if c == 200 then
+ local data = json.decode(r)
+ print(inspect(data), data.main.temp)
+ love.thread.getChannel('weather'):push({
+ weather = data.weather[1].main:lower(),
+ temperature = data.main.temp,
+ })
+else
+ print("failed")
+end