Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commandArray = {}
- --Weatherstation data:
- sWeatherTemp, sWeatherHumidity, sWeatherUV, sWeatherPressure, sWeatherUV2 = otherdevices_svalues['Barometer']:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
- sWeatherTemp = tonumber(sWeatherTemp);
- sWeatherHumidity = tonumber(sWeatherHumidity);
- sWeatherPressure = tonumber(sWeatherPressure);
- sWeatherUV = tonumber(sWeatherUV);
- sWeatherUV2 = tonumber(sWeatherUV2);
- print("______________________________________________________________________________________")
- print("Weather station: Temperature is " .. sWeatherTemp .. " ");
- print("Weather station: Humidity is " .. sWeatherHumidity .. " ");
- print("Weather station: Pressure is " .. sWeatherPressure .. " ");
- print("Weather station: UV is " .. sWeatherUV .. " ");
- print("Weather station: UV2 is " .. sWeatherUV2 .. " ");
- print("______________________________________________________________________________________")
- ------------------------------------------------------------------------
- --Windmeter data:
- sWindDirectionDegrees, sWindDirection, sWindSpeed, sWindGust, sWindTemperature, sWindFeel = otherdevices_svalues['Wind']:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
- sWindDirectionDegrees = tonumber(sWindDirectionDegrees);
- sWindDirection = (sWindDirection);
- sWindSpeed = tonumber(sWindSpeed);
- sWindGust = tonumber(sWindGust);
- sWindTemperature = tonumber(sWindTemperature);
- sWindFeel = tonumber(sWindFeel);
- print("______________________________________________________________________________________")
- 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 .. " ");
- print("______________________________________________________________________________________")
- ------------------------------------------------------------------------
- --Rainmeter data:
- sRainmeterCurrent, sRainmeterTotal = otherdevices_svalues['Regen']:match("([^;]+);([^;]+)")
- sRainmeterCurrent = tonumber(sRainmeterCurrent);
- sRainmeterTotal = tonumber(sRainmeterTotal);
- print("______________________________________________________________________________________")
- print("Rainmeter: Actual rain is: " .. sRainmeterCurrent .. " ");
- print("Rainmeter: Total rain is: " .. sRainmeterTotal .. " ");
- print("______________________________________________________________________________________")
- ------------------------------------------------------------------------
- --UV data:
- sSolar = otherdevices_svalues['Solar']:match("([^;]+)")
- sSolar = tonumber(sSolar);
- print("UV: Solar radiation is: " .. sSolar .." ");
- ------------------------------------------------------------------------
- --Sunscreen thresholds:
- -- Windspeed = 100.0 (value is multiplied by 100)
- -- Rain = 0.0
- -- UV = 2.0
- -- Temperature = 12.0
- -- Closed = Down = On
- -- Open = Up = Off
- ------------------------------------------------------------------------
- if (timeofday['Daytime'])
- then
- print('It is past sunrise, monitoring variables for sunscreen')
- if (otherdevices['Zonnescherm'] == 'Open' )
- then
- print ('Sunscreen is up')
- else
- print ('Sunscreen is down')
- end
- if (otherdevices['Zonnescherm manual override'] == 'Off')
- then
- print('Manual override is turned off, follow the rest of the script')
- else
- print('Manual override is turned on, goto the end of the script and do nothing')
- goto done
- end
- if (otherdevices['Zonnescherm'] == 'Open'
- and otherdevices['BuienraddarScherm'] == 'On'
- and sRainmeterCurrent == 0
- and sWeatherTemp > 12.0
- and sSolar > 250
- and sWindSpeed < 65
- and sWindGust < 150)
- then
- print ('Sun is shining, all thresholds OK, lowering sunscreen')
- print('______________________________________________________________________________________')
- commandArray['SendNotification']='Sunscreen#Sunscreen down --> Sun is shining'
- commandArray['Zonnescherm']='On'
- elseif (otherdevices['Zonnescherm'] == 'Closed' and otherdevices['BuienraddarScherm'] == "On")
- then
- print ('Buienraddar says it is raining, raising sunscreen')
- print('______________________________________________________________________________________')
- commandArray['SendNotification']='Sunscreen#Sunscreen up --> It is raining'
- commandArray['Zonnescherm']='Off'
- elseif (otherdevices['Zonnescherm'] == 'Closed' and sRainmeterCurrent > 0)
- then
- print ('It is raining, raising sunscreen')
- print('______________________________________________________________________________________')
- commandArray['SendNotification']='Sunscreen#Sunscreen up --> It is raining'
- commandArray['Zonnescherm']='Off'
- elseif (otherdevices['Zonnescherm'] == 'Closed' and sWeatherTemp <11.0 and otherdevices['Zonnescherm manual override'] == 'Off')
- then
- print ('Temperature too low, below 11 degrees, raising sunscreen')
- print('______________________________________________________________________________________')
- commandArray['SendNotification']='Sunscreen#Sunscreen up --> It is too cold'
- commandArray['Zonnescherm']='Off'
- elseif (otherdevices['Zonnescherm'] == 'Closed' and sSolar < 100 and otherdevices['Zonnescherm manual override'] == 'Off')
- then
- print ('Sun not shining too bright,Solar is under a 100, raising sunscreen')
- print('______________________________________________________________________________________')
- commandArray['SendNotification']='Sunscreen#Sunscreen up --> Sunshine not too bright'
- commandArray['Zonnescherm']='Off'
- elseif (otherdevices['Zonnescherm'] == 'Closed' and sWindSpeed > 65)
- then
- print ('Windspeed too high, windspeed over 65, raising sunscreen')
- print('______________________________________________________________________________________')
- commandArray['SendNotification']='Sunscreen#Sunscreen up --> Windspeed too high'
- commandArray['Zonnescherm']='Off'
- elseif (otherdevices['Zonnescherm'] == 'Closed' and sWindGust > 150)
- then
- print ('Windgust too high, windgust over 150, raising sunscreen')
- print('______________________________________________________________________________________')
- commandArray['SendNotification']='Sunscreen#Sunscreen up --> Windgust too high'
- commandArray['Zonnescherm']='Off'
- else
- print('Sunscreen status OK --> No action')
- print('______________________________________________________________________________________')
- end
- ::done::
- print("At the end of the script")
- print("______________________________________________________________________________________")
- elseif (timeofday['Nighttime']
- and otherdevices['Zonnescherm'] == 'Closed')
- then
- print('It is night, raising sunscreen')
- print('______________________________________________________________________________________')
- commandArray['SendNotification']='Sunscreen#Sunscreen up --> It is night'
- commandArray['Zonnescherm']='Off'
- else
- print('Sunscreen already up --> No action')
- print('______________________________________________________________________________________')
- end
- return commandArray
Advertisement
Add Comment
Please, Sign In to add comment