Wind speed close shutter - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Wind speed close shutter (/showthread.php?tid=2458) |
Wind speed close shutter - MantasJ - 08.02.2020 Hello, I have a task where I need to get current wind speed and if it is above certain number (in this case 12 meters/second), the shutter in outside would close. I wanted to do this from KNX weather station, but it seems it doesn't provide actual wind speed accurately, so my guess is I should propably use some API service. I have tried this script: Quote:require('socket.http') But it returns some odd numbers which doesn't really match the forecast from elsewhere, but then I thought maybe I just don't understand what it returns. So how data is returned? The table has 36 entries and I though maybe it is 35 from days starting from first entry (today) forecast, or no? Maybe it is some king of interval based? Thank You RE: Wind speed close shutter - admin - 08.02.2020 Try using hourly forecast xml: https://www.yr.no/place/Lithuania/Klaipeda/Klaip%C4%97da/forecast_hour_by_hour.xml Wind speed is specified in miles per hour for some reason so a bit of extra conversion is required. RE: Wind speed close shutter - Joep - 08.02.2020 There are better api's available using JSON. But first of all i would like to say that for this purpose it's better to meassure at the side where your shutter is installed. Specially if you use it for a professional installation side. Some weather API's can be found here. https://superdevresources.com/weather-forecast-api-for-developing-apps/ Below an example we use with a Dutch weather API in JSON. require('ssl.https') require('json') city = 'Amsterdam' data = ssl.https.request('http://weerlive.nl/api/json-10min.php?locatie=' ..city) datatable = json.pdecode(data) datatable = datatable['liveweer'][1] --log(datatable) temp = datatable.temp --actuele temperatuur --log('Actuele temperatuur: ' ..temp.. '°C') windms = datatable.windms --windsnelheid in meter per seconde --log('Windsnelheid: ' ..windms.. ' m/s') RE: Wind speed close shutter - Erwin van der Zwart - 08.02.2020 Hi, I would add a check to be sure that the values from the online service are received as expected, we do the same with a signal from a local weather station (alive signal). Make a resident / scheduled script at like this: Code: lastupdate = grp.find('1/1/1').updatetime Erwin |