02.05.2019, 13:29
See this post: https://forum.logicmachine.net/showthrea...5#pid12735
Weather service not working anymore?
|
02.05.2019, 13:29
See this post: https://forum.logicmachine.net/showthrea...5#pid12735
02.05.2019, 15:37
(02.05.2019, 12:51)jetsetter Wrote: Hi to all, Did you put https in the url? The script works only with http. Regards. Michel.
28.08.2019, 18:02
(18.01.2019, 07:50)admin Wrote: Since there's no response from Yahoo we suggest using https://apixu.com instead. You will have to create a free account and make sure that your script does not fetch data too quickly (not less than once in 5 minutes).Now i get always the alert failed to load weather data. What im doing wrong ? The same script has worked before. Is there something changed in the apixu ?
29.08.2019, 06:43
Works for me, try logging server response.
Replace: Code: 1 res = https.request(url)With: Code: 12 res, code, hdrs, stat = https.request(url)
log(res, code, hdrs, stat)And post what you get in Logs tab.
29.08.2019, 18:51
(29.08.2019, 06:43)admin Wrote: Works for me, try logging server response.Thanks This is what i get : weater_data_apixu 29.08.2019 20:49:37 * arg: 1 * nil * arg: 2 * nil * arg: 3 * nil * arg: 4 * nil
29.08.2019, 19:24
Which firmware version are you running? Can you send your Apixu key via PM?
29.08.2019, 19:37
30.08.2019, 06:16
This is probably due to older FW, as a work-around you can use HTTP request instead:
Code: 1234567891011121314 require('json')
http = require('socket.http')
escape = require('socket.url').escape
key = 'my_api_key'
location = 'my location name'
url = 'http://api.apixu.com/v1/forecast.json?key=%s&q=%s&days=2'
url = string.format(url, key, escape(location))
res = http.request(url)
data = json.pdecode(res)
...
06.12.2019, 11:42
I am all new to the LM and are on a steep learning path. I've been struggling to get the yr.no xml API script to work for my Yr location. However, after further inspections and testing I found out that the xml from norwegian locations have a subtle difference compared to other location. I could get all others to work, but not for any norwegian places.
For norwegian places you get an additional text section as below: <forecast> <text> <location name="Oslo"> <time from="2019-12-06" to="2019-12-06"> <title>Obs! Note!</title> <body>Tekstvarsel-tjenesten er nedlagt. The text forecast service is suspended</body> </time> </location> </text> Because of this the first index to values must be 2 instead of 1. That eventually made things work for me. I don't know why nobody has mentioned this before. Maybe this is a recent change? Or is it me missing something here...?
05.04.2020, 19:30
Hi,
how correctly attach weather icons to visualization? As example I have group with icon number or name - 250 byte string - 03n, and I have icon 03n.png. How better show it at visualization? Thank you in advance, Alex
06.04.2020, 07:39
See this example: https://forum.logicmachine.net/showthread.php?tid=2253
06.04.2020, 08:37
admin,
thank you, now will check and add to my icon's control
08.05.2020, 12:50
(30.08.2019, 06:16)admin Wrote: This is probably due to older FW, as a work-around you can use HTTP request instead: Weather service is working, but from different url url = 'http://api.weatherstack.com/current?access_key=%s&query=%s' will return table data.current like this * table: ["cloudcover"] * number: 59 ["visibility"] * number: 10 ["observation_time"] * string: 12:24 PM ["uv_index"] * number: 5 ["wind_dir"] * string: NNW ["humidity"] * number: 60 ["weather_descriptions"] * table: [1] * string: Cloudy ["wind_speed"] * number: 21 ["weather_code"] * number: 119 ["is_day"] * string: yes ["pressure"] * number: 1017 ["precip"] * number: 0.1 ["weather_icons"] * table: [1] * string: https://assets.weatherstack.com/images/w..._cloud.png ["feelslike"] * number: 10 ["temperature"] * number: 12 ["wind_degree"] * number: 327 Best regards Alex
30.07.2020, 15:01
Is there any kind of change in the weather script?
I see that the application loads it well without errors and even updates the data ... but it does not send the correct values for the season of the year in which we are ...
30.07.2020, 15:03
Which one are you using?
30.07.2020, 15:22
(30.07.2020, 15:03)admin Wrote: Which one are you using?Hello admin, this is my script. Code: 1234567891011121314151617181920212223242526272829303132333435363738394041 require('json')
http = require('socket.http')
escape = require('socket.url').escape
key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
location = 'xxxx'
url = 'http://api.weatherstack.com/current?access_key=%s&query=%s'
url = string.format(url, key, escape(location))
res = http.request(url)
data = json.pdecode(res)
if type(data) ~= 'table' then
alert('no se pudieron cargar los datos del clima')
return
end
if data.error then
log('error', data.error)
return
end
current = data.current
-- temperature
grp.write('32/1/1', current.temperature)
-- "feels like" temperature
grp.write('32/1/2', current.feelslike)
-- humidity as percentage
grp.write('32/1/3', current.humidity)
-- wind speed in kilometers per hour
grp.write('32/1/4', current.wind_speed)
-- uv index
grp.write('32/1/5', current.uv_index)
-- weather condition text
grp.write('32/1/6', current.weather_descriptions[1])
-- pressure
grp.write('32/1/7', current.pressure)
-- precipitation amount
grp.write('32/1/8', current.precip)
30.07.2020, 15:35
Maybe the location is incorrect? You can use latitude, longitude format to get a more precise results. Try logging JSON data, maybe it will provide some useful information.
23.03.2022, 12:15
Hi Admin , Didn't understand how to use your script ? Could you please give me some instructions about it .
23.03.2022, 12:16
Which script exactly? There are many examples that use data from different services.
23.03.2022, 12:25
Code: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 require('json')
https = require('ssl.https')
escape = require('socket.url').escape
key = 'my_api_key'
location = 'my location name'
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) |
« Next Oldest | Next Newest »
|