Guest User

Untitled

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