The script below works in full if I set the 'time to run' to a few minutes ahead and watch it execute in the log.
When it runs for real at 07:45 and 15:00 it switches the fan on/off and writes to the log file but misses the e-mail element. Any thoughts??
Code: Select all
--~/domoticz/scripts/lua/script_time_loungedamp.lua
commandArray = {}
--Uservariables
Email1="[email protected]"
amHour=07
amMinute=45
pmHour=15
pmMinute=00
lounge_Humidity=50
file = io.open('/home/graeme/domoticz/scripts/lua/fanlog.txt' , "a")
lounge_Humidity = otherdevices_humidity['lounge Temperature']
Message = 'lounge is damp @ '.. lounge_Humidity .. '% - please open windows'
print('Running Damp Script')
-- Time to run?
time = os.date("*t")
if (time.hour == amHour and time.min == amMinute) or (time.hour == pmHour and time.min == pmMinute) then
if lounge_Humidity > 64 then --if the humidity is high turn on the loft fan
commandArray['Loft Fan']='On'
file:write(os.date("%x %X") .. " the humidity in the lounge is high @ " .. lounge_Humidity .. "\n")
file:close()
commandArray=['SendEmail']='lounge room report#'.. Message .. '#' .. Email1
else --if the humidity is low enough turn off the loft fan
commandArray['Loft Fan']='Off'
file:write(os.date("%x %X") .. " the humidity in the lounge is low @ " .. lounge_Humidity .. "\n")
file:close()
end
end
--LUA default
return commandArray