Example: Fetch Yahoo weather forecast
KNX specific configuration in Logic Machine
- Connect to Logic Machine (Logic Machine) with default access parameters (IP: 192.168.0.10; login/password: admin/admin)

Create “Weather data Yahoo” resident script
- In scripting tab click on the Resident button, then Add new script. In this example the script will be run every minute

- After you have saved the script, click on the icon in Editor column to enter into scripting redactor. The script is fetching 5 variables from Yahoo for Riga city – current temperature, current condition, forecast condition for tomorrow, forecast min and max temperatures for tomorrow – and storing them into KNX group addresses.

- After first time the script is run the new group addresses are added (if not added before) into Objects menu. You can set the respective names for these objects.

- You can add these objects into your visualization map with respective icons. Or you can use these objects to preset HVAC system accordingly to weather.

- require('json')
-
- local city = 854823
- local cmd, data, forecast
-
- cmd = 'wget -q -O - "http://weather.yahooapis.com/forecastjson?w=' .. city .. '&u=c" 2>/dev/null'
- data = io.readproc(cmd)
- if not data then
- alert('Weather: cannot get data')
- return false
- end
-
- data = json.pdecode(data)
- if not data then
- alert('Weather: cannot parse data')
- return false
- end
-
- grp.write('5/1/1', data.condition.text, dt.string)
- grp.write('5/1/2', data.condition.temperature, dt.float16)
-
- forecast = data.forecast[2]
- grp.write('5/1/3', forecast.condition, dt.string)
- grp.write('5/1/4', forecast.low_temperature, dt.float16)
- grp.write('5/1/5', forecast.high_temperature, dt.float16)




