when i measure a windgust >6m/s(cpnj wind) it puts on a dummyswitch ('windvlaag >6m/s 15 min').
when it is not updated to on for more than 15 minutes....then it should go to off.
Code: Select all
t1 = os.time()
s = otherdevices_lastupdate['windvlaag >6m/s 15 min']
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
commandArray = {}
if devicechanged['cpnj wind'] then
--Windmeter data:
sWindDirectionDegrees, sWindDirection, sWindSpeed, sWindGust, sWindTemperature, sWindFeel = otherdevices_svalues['cpnj wind']:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
sWindDirectionDegrees = tonumber(sWindDirectionDegrees);
sWindDirection = (sWindDirection);
sWindSpeed = tonumber(sWindSpeed);
sWindGust = tonumber(sWindGust);
sWindTemperature = tonumber(sWindTemperature);
sWindFeel = tonumber(sWindFeel);
print("Windmeter: Winddirection (in degrees) is: " .. sWindDirectionDegrees .. " ");
print("Windmeter: Winddirection is: " .. sWindDirection .. " ");
print("Windmeter: Windspeed is: " .. sWindSpeed .. " ");
print("Windmeter: Windgust is: " .. sWindGust .. " ");
print("Windmeter: Windtemperature is: " .. sWindTemperature .. " ");
print("Windmeter: Windfeel is: " .. sWindFeel .. " ");
end
if sWindGust > 60 then
commandArray['windvlaag >6m/s 15 min']='On'
end
if (otherdevices['windvlaag >6m/s 15 min'] == 'On' and difference > 900) then
commandArray['windvlaag >6m/s 15 min']='Off'
end
return commandArray
Code: Select all
2017-10-25 22:01:46.949 Error: EventSystem: in >15m/s_test: [string "t1 = os.time()..."]:38: attempt to compare number with nil
i run this script in the 'all' mode