Turn Switch back on if the humidity in room is too high

Hi all, new to vera, having difficulty understanding the syntax on the Lua scripting.

I have my bathroom fan turn on if the humidity is past a certain point and turn of when it get below a certain point. I would like to script in if the switch get turned off before it gets to the low set point, vera will turn the switch back on.

Here is what I have that is not working that I was going to trigger on the fan being turned off:

local HumSes = 36 -->Humidity Sensor ID
local Switch = 43 → Fan Switch to turn on if to high

HUM_SID = “urn:schemas-micasaverde-com:device:HumiditySensor:1”
local BathHumid = luup.variable_get( HUM_SID, “CurrentLevel”, HumSes)
Call =‘urn:upnp-org:serviceId:SwitchPower1’;Do =‘SetTarget’

if (BathHumid >= 43) then
luup.call_action(Call,Do,{newTargetValue=1},Switch)
end

Any help is appreciated…

Thanks

P.S. - i need help with the code. This code i have posted is not working.

Never Mind,

after a lot of goggling I found this post that pointed me to the Combination Switch app…

http://forum.micasaverde.com/index.php?topic=10995.0

So i set my conditions in there and set the trigger to turn on the fan if the conditions were met.
Great app, no coding, awesome vera

Thanks for not posting anything, gave me some time to wrestle with the problem and finding the answer myself.

I used (with help off Richard) the PLEG to switch my bathroom fan.
Maybe a solution for you as well…

[url=http://forum.micasaverde.com/index.php/topic,17422.0.html]http://forum.micasaverde.com/index.php/topic,17422.0.html[/url]