Guest User

Untitled

a guest
Apr 6th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.03 KB | None | 0 0
  1. commandArray = {}
  2.  
  3. --Weatherstation data:
  4. sWeatherTemp, sWeatherHumidity, sWeatherUV, sWeatherPressure, sWeatherUV2 = otherdevices_svalues['Barometer']:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
  5. sWeatherTemp = tonumber(sWeatherTemp);
  6. sWeatherHumidity = tonumber(sWeatherHumidity);
  7. sWeatherUV = tonumber(sWeatherUV);
  8. sWeatherPressure = tonumber(sWeatherPressure);
  9. sWeatherUV2 = tonumber(sWeatherUV2);
  10.  
  11. print("______________________________________________________________________________________")
  12. print("Weather station: Temperature is " .. sWeatherTemp .. " ");
  13. print("Weather station: Humidity is " .. sWeatherHumidity .. " ");
  14. print("Weather station: UV is " .. sWeatherUV .. " ");
  15. print("Weather station: Pressure is " .. sWeatherPressure .. " ");
  16. print("Weather station: UV2 is " .. sWeatherUV2 .. " ");
  17.  
  18. ------------------------------------------------------------------------
  19.  
  20. --Windmeter data:
  21. sWindDirectionDegrees, sWindDirection, sWindSpeed, sWindGust, sWindTemperature, sWindFeel = otherdevices_svalues['Wind']:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
  22.  
  23. sWindDirectionDegrees = tonumber(sWindDirectionDegrees);
  24. sWindDirection = (sWindDirection);
  25. sWindSpeed = tonumber(sWindSpeed);
  26. sWindGust = tonumber(sWindGust);
  27. sWindTemperature = tonumber(sWindTemperature);
  28. sWindFeel = tonumber(sWindFeel);
  29.  
  30. print("Windmeter: Winddirection (in degrees) is: " .. sWindDirectionDegrees .. " ");
  31. print("Windmeter: Winddirection is: " .. sWindDirection .. " ");
  32. print("Windmeter: Windspeed is: " .. sWindSpeed .. " ");
  33. print("Windmeter: Windgust is: " .. sWindGust .. " ");
  34. print("Windmeter: Windtemperature is: " .. sWindTemperature .. " ");
  35. print("Windmeter: Windfeel is: " .. sWindFeel .. " ");
  36.  
  37. ------------------------------------------------------------------------
  38.  
  39. --Rainmeter data:
  40. sRainmeterCurrent, sRainmeterTotal = otherdevices_svalues['Regen']:match("([^;]+);([^;]+)")
  41.  
  42. sRainmeterCurrent = tonumber(sRainmeterCurrent);
  43. sRainmeterTotal = tonumber(sRainmeterTotal);
  44.  
  45. print("Rainmeter: Actual rain is: " .. sRainmeterCurrent .. " ");
  46. print("Rainmeter: Total rain is: " .. sRainmeterTotal .. " ");
  47. print("______________________________________________________________________________________")
  48. ------------------------------------------------------------------------
  49.  
  50. --UV data:
  51. --sUV, sSolar = otherdevices_svalues['UV']:match("([^;]+);([^;]+)")
  52.  
  53. --sUV = tonumber(sUV);
  54. --sSolar = tonumber(sSolar);
  55.  
  56. --print("UV: UV Strength is: " .. sUV .." ");
  57. --print("UV: Solar radiation is: " .. sSolar .." ");
  58.  
  59. ------------------------------------------------------------------------
  60.  
  61. --Sunscreen thresholds:
  62.         -- Windspeed            = 100.0 (value is multiplied by 100)
  63.         -- Rain                 =  0.0
  64.         -- UV                   =  2.0
  65.         -- Temperature          = 10.0
  66.         -- Closed       = Down  = On
  67.         -- Open         = Up    = Off
  68.  
  69. ------------------------------------------------------------------------
  70.  
  71. if (timeofday['Daytime'])
  72.         then
  73.                 print('It is past sunrise, monitoring variables for sunscreen')
  74.         if (otherdevices['Zonnescherm'] == 'Open' )
  75.         then
  76.                 print ('Sunscreen is up')
  77.         else
  78.                 print ('Sunscreen is down')
  79.  
  80. end
  81.  
  82. if (otherdevices['Zonnescherm manual override']  == 'Off')
  83.         then
  84.                 print('Manual override is turned off, follow the rest of the script')
  85.         else
  86.                 print('Manual override is turned on, goto the end of the script and do nothing')
  87.                 goto done
  88. end
  89.  
  90. if (otherdevices['Zonnescherm']   == 'Open'
  91.         and sRainmeterCurrent   == 0
  92.         and sWeatherTemp        > 10.0
  93.         and sWeatherUV2         > 2
  94.         and sWindSpeed          < 50
  95.         and sWindGust           < 150)
  96.  
  97. then
  98.  
  99.         print ('Sun is shining, all thresholds OK, lowering sunscreen')
  100.         print('______________________________________________________________________________________')
  101.         commandArray['SendNotification']='Sunscreen#Sunscreen down --> Sun is shining'
  102.         commandArray['Zonnescherm']='On'
  103.  
  104.                 elseif (otherdevices['Zonnescherm'] == 'Closed' and sRainmeterCurrent > 0)
  105.                 then
  106.                 print ('It is raining, raising sunscreen')
  107.                 print('______________________________________________________________________________________')
  108.                 commandArray['SendNotification']='Sunscreen#Sunscreen up --> It is raining'
  109.                 commandArray['Zonnescherm']='Off'
  110.  
  111.         elseif (otherdevices['Zonnescherm'] == 'Closed' and sWeatherTemp <10.0 and otherdevices['Zonnescherm manual override'] == 'Off')
  112.                 then
  113.                 print ('Temperature too low, raising sunscreen')
  114.                 print('______________________________________________________________________________________')
  115.                 commandArray['SendNotification']='Sunscreen#Sunscreen up --> It is too cold'
  116.                 commandArray['Zonnescherm']='Off'
  117.  
  118.        elseif (otherdevices['Zonnescherm'] == 'Closed' and sWeatherUV2 < 2 and otherdevices['Zonnescherm manual override'] == 'Off')
  119.                 then
  120.                 print ('Sun not shining too bright, raising sunscreen')
  121.                 print('______________________________________________________________________________________')
  122.                 commandArray['SendNotification']='Sunscreen#Sunscreen up --> Sunshine not too bright'
  123.                 commandArray['Zonnescherm']='Off'
  124.  
  125.         elseif (otherdevices['Zonnescherm'] == 'Closed' and sWindSpeed > 50)
  126.                 then
  127.                 print ('Windspeed too high, raising sunscreen')
  128.                 print('______________________________________________________________________________________')
  129.                 commandArray['SendNotification']='Sunscreen#Sunscreen up --> Windspeed too high'
  130.                 commandArray['Zonnescherm']='Off'
  131.  
  132.         elseif (otherdevices['Zonnescherm'] == 'Closed' and sWindGust > 150)
  133.                 then
  134.                 print ('Windgust too high, raising sunscreen')
  135.                 print('______________________________________________________________________________________')
  136.                 commandArray['SendNotification']='Sunscreen#Sunscreen up --> Windgust too high'
  137.                 commandArray['Zonnescherm']='Off'
  138.  
  139. else
  140.         print('Sunscreen status OK --> No action')
  141.         print('______________________________________________________________________________________')
  142. end
  143.  
  144. ::done::
  145.         print("______________________________________________________________________________________")
  146.        
  147. elseif (timeofday['Nighttime']
  148.         and otherdevices['Zonnescherm'] == 'Closed')
  149.         then
  150.                 print('It is night, raising sunscreen')
  151.                 print('______________________________________________________________________________________')
  152.                 commandArray['SendNotification']='Sunscreen#Sunscreen up --> It is night'
  153.                 commandArray['Zonnescherm']='Off'
  154.         else
  155.                 print('Sunscreen already up --> No action')
  156.         print('______________________________________________________________________________________')
  157. end
  158.  
  159. return commandArray
Advertisement
Add Comment
Please, Sign In to add comment