Need help with scripting a scene using Google weather and wind parameter

I installed the weather plugin successfully to my Vera and now I want to execute a scene using the following condition:

  1. If the time is between say 12:30 pm and 11:30 pm AND if the wind speed is less that 5 mph, I want to have my fountain pump turned on.

I am just started looking at LUA codes but I am not sure how to begin scripting for this simple need. Any help would be greatly appreciated and thanks for your time in advance!

Untested, may contain bugs, doesn’t work for MiOS < 1.5.250 (V2) / < 1.5.249 (V3):

local DEVICE_ID_WEATHER_PLUGIN = 123

local second_of_day = ( os.time() + 3600 * luup.timezone ) % 86400

local wind_speed = luup.variable_get( 'urn:upnp-micasaverde-com:serviceId:Weather1', 'WindSpeed', DEVICE_ID_WEATHER_PLUGIN )

if  ( second_of_day > 12 * 3600 + 30 * 60 ) 
   and 
    ( second_of_day < 11 * 3600 + 30 * 60 )
   and 
    ( tonumber( wind_speed ) or 999 < 5 )
 then
-- switch on
 else
-- switch off
 end

Setup a scene with an interval timer and put the code into the ‘Advanced’ tab - and don’t forget to add a scene that switches off the pump at 11:31 pm …

Further reading:
[tt]http://wiki.micasaverde.com/index.php/Luup_Scenes_Events#Lighting_and_Switch_Actions[/tt]

Thanks and I will give it try when I get home today. I am running firmware version 1.1.1245 and vera 2. A couple of questions:

  1. local DEVICE_ID_WEATHER_PLUGIN = 123 —> 123 refers to the device number for the google weather plug-in correct?

  2. When I create the scene, do I also set a timer to turn on the pump at 12:30 pm CT daily and have the code below in the “advanced tab” or just this code in the “advanced tab” and no timer enabled?

  3. Using this scripting, let assume that the day starts off nicely with wind speed less than 5 mph, but then pick-ups at about 3 pm to above 5 mph, would the pump turn off then at 3 pm?

Thanks agian for all your help.

  1. 1.1.1245 doesn’t support [tt]luup.timezone[/tt]. Please see [tt]http://wiki.micasaverde.com/index.php/Luup_Scenes_Events#Access_the_current_time[/tt] for a workaround.
  2. Yes.
  3. No need to explicitly switch on the pump (if it’s OK that the pump gets switched on within the interval [12:30 pm + timer interval for the scene] - if the wind speed allows. My code must be placed in the ‘Advanced’ tab of a scene with an interval timer (10 minutes? IIRC, the default update frequency of the weather plugin is 0.5 per hour.)
  4. The pump would turn off within within the interval [3 pm + timer interval for the scene] - plus the delay caused by the update frequency of the weather plugin.