This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Weather Info from API
#1
Hello, 
Please, I hope you could help me in my issue
However, I was trying to get the weather infomation from apixu.com and write them on the KNX bus.
I just followed the exemple on the openrb.com this one (https://openrb.com/featch-weather-forecast-from-apixu), I only changed the key variable as it's mentioned in the exemple.

This is the scheduled script that I used.
Code:
require('json') https = require('ssl.https') escape = require('socket.url').escape key = '737ad147e5be532e3d78995a68f4a160' location = 'Norway' url = 'https://api.apixu.com/v1/forecast.json?key=%s&q=%s&days=2' url = string.format(url, key, escape(location)) res = https.request(url) data = json.pdecode(res) if type(data) ~= 'table' then   alert('failed to load weather data')   return end if data.error then   log('error', data.error)   return end current = data.current today = data.forecast.forecastday[ 1 ].day tomorrow = data.forecast.forecastday[ 2 ].day -- log(current, today, tomorrow) -- temperature in C grp.write('32/1/1', current.temp_c) -- "feels like" temperature in C grp.write('32/1/2', current.feelslike_c) -- humidity as percentage grp.write('32/1/3', current.humidity) -- wind speed in kilometers per hour grp.write('32/1/4', current.wind_kph) -- uv index grp.write('32/1/5', current.uv) -- weather condition text grp.write('32/1/6', current.condition.text) -- pressure in millibars grp.write('32/1/7', current.pressure_mb) -- precipitation amount in millimeters grp.write('32/1/8', current.precip_mm) -- minimum temperature in celsius for the day grp.write('32/2/1', today.mintemp_c) -- maximum temperature in celsius for the day grp.write('32/2/2', today.maxtemp_c) -- average temperature in celsius for the day grp.write('32/2/3', today.avgtemp_c) -- average humidity as percentage grp.write('32/2/4', today.avghumidity) -- maximum wind speed in kilometers per hour grp.write('32/2/5', today.maxwind_kph) -- uv index grp.write('32/2/6', today.uv) -- weather condition text grp.write('32/2/7', today.condition.text) -- total precipitation in millimeters grp.write('32/2/8', today.totalprecip_mm) -- minimum temperature in celsius for the day grp.write('32/3/1', tomorrow.mintemp_c) -- maximum temperature in celsius for the day grp.write('32/3/2', tomorrow.maxtemp_c) -- average temperature in celsius for the day grp.write('32/3/3', tomorrow.avgtemp_c) -- average humidity as percentage grp.write('32/3/4', tomorrow.avghumidity) -- maximum wind speed in kilometers per hour grp.write('32/3/5', tomorrow.maxwind_kph) -- uv index grp.write('32/3/6', tomorrow.uv) -- weather condition text grp.write('32/3/7', tomorrow.condition.text) -- total precipitation in millimeters grp.write('32/3/8', tomorrow.totalprecip_mm)


No data was found on those groupe addresses, 
Or if you could give me any other solution, I only wants to write 1 on the KNX bus if there's a snow tomorrow, the place is Bergen in Norway

Very grateful in advance
Reply


Messages In This Thread
Weather Info from API - by Fahd - 24.02.2022, 23:52
RE: Weather Info from API - by admin - 25.02.2022, 08:31
RE: Weather Info from API - by Mrinj - 27.05.2022, 13:14
RE: Weather Info from API - by admin - 27.05.2022, 13:19
RE: Weather Info from API - by Mrinj - 27.05.2022, 13:23
RE: Weather Info from API - by AlexLV - 08.06.2022, 05:51
RE: Weather Info from API - by RomansP - 08.06.2022, 08:52
RE: Weather Info from API - by AlexLV - 09.06.2022, 08:21
RE: Weather Info from API - by RomansP - 09.06.2022, 11:04
RE: Weather Info from API - by RomansP - 10.06.2022, 07:53
RE: Weather Info from API - by Mrinj - 22.06.2022, 08:00
RE: Weather Info from API - by Fahd - 22.06.2022, 09:59
RE: Weather Info from API - by RomansP - 22.06.2022, 08:17
RE: Weather Info from API - by Mrinj - 22.06.2022, 16:24
RE: Weather Info from API - by admin - 23.06.2022, 06:24
RE: Weather Info from API - by Mrinj - 23.06.2022, 06:36
RE: Weather Info from API - by Acla - 09.07.2022, 23:16
RE: Weather Info from API - by admin - 11.07.2022, 06:28
RE: Weather Info from API - by Acla - 11.07.2022, 21:30
RE: Weather Info from API - by RomansP - 12.07.2022, 06:20
RE: Weather Info from API - by fabiorusco - 31.10.2022, 10:48
RE: Weather Info from API - by RomansP - 31.10.2022, 13:48
RE: Weather Info from API - by fabiorusco - 03.11.2022, 06:51
RE: Weather Info from API - by fabiorusco - 03.11.2022, 13:07
RE: Weather Info from API - by RomansP - 03.11.2022, 14:44
RE: Weather Info from API - by fabiorusco - 03.11.2022, 15:09
RE: Weather Info from API - by P_marienborg - 17.01.2023, 09:15
RE: Weather Info from API - by admin - 17.01.2023, 09:15
RE: Weather Info from API - by alias74 - 09.06.2023, 08:07

Forum Jump: