Small LUA Scripts Part 7: Checking the Weather Conditions

by boomx21. September 2016

You want to perform the proper actions at certain weather conditions? Do you want your RGBW-Modules to start the “storm” program when a thunderstorm is approaching? Or do you want your lights to shine yellow when the sky is clear? Then you definitely have to read this article.

Now you can certainly claim: “I thought this already works!”. Yes, it does work. But we kind of extended the possibilities a little. As you can see in the next picture, Fibaro is using the “Weather Conditions” to compare weather conditions and afterwards implement an action. The API by yahoo, resp. yr.to does not redeliver this kind of information, though. You merely receive a number, which will then be “translated” by Fibaro.

weather conditions

Weather conditions

And this is the exact point we assess at and do it like Fibaro: We translate the number into a weather condition. Though, slightly more detailed. The script gives you the possibility to check the following weather conditions:

  • Rain
  • Clear sky
  • Partly cloudy sky
  • Cloudy sky
  • Mostly cloudy sky
  • Fog
  • Thunderstorms
  • Possibly rain with snow/snow
  • Snow
  • Hail
  • Black ice
  • Storm

The script posted below is a small extension of the earlier presented OpenWeatherVDs with whom you can use your own weather data on the weather display of the Fibaro HomeCenter2. The script can also be used without the virtual device, though.


Debug window of the scene

When changing the ConditionCode, the scene will be performed. In case you installed the VD as shown in the article, the scene will be performed every 10 minutes. In order to for example a set up push-notification, which is to be send at certain weather conditions, to not be send every 10 minutes, the script checks, which weather condition was set before the new value. If this has not changed, nothing will happen.

And this is the “prepared” code:


By taking a look at the debug-expenses, you can tell by the code, which weather condition is predominating. At this point you can then add single or multiple actions.


Icon for the scene

Short info at the end: We unfortunately are no longer able to perform the script with the firmware 4.081 and the connected changes on the new weather service yr.to. A user might be able to do that for us and leave the result in the comments. Thanks a lot for your help and now have fun with the small scene.

About The Author

Leave a Response