Korrel wrote:I would to like to automate pomping water through my solar heating panel whenever the sun is clearly shining / heating so i tried the attached event ... (sun is on the solar panels between 11:00 and 16:00)
However, the UVI comparison never works, anyone a idea how to fix this ?
I guess this is due to the fact that the UV is coming from a string of numbers. In my case (don't know if you have the same setup) I don't actually own a weather station but I retrieve the data from Wunderground. Now, if I go to Setup --> Events --> Current States, I get the following from the UV:
21 UV 2014-06-04 10:20:01
5.0;0.0
Now, the first value is the UV value (in UVI) and the second value is Watts per m2. Because this is a string instead of a single number, your UVI comparison fails. What you can do is use a LUA script to extract the values and do stuff based on thresholds. I use the following script myself for my sunscreen.
A different solution would be not to build the complete logic in LUA, but only to derrive the values in LUA and posting them to Domoticz using JSON (using Virtual Sensors).
A third option (use with caution!) is to derrive the values in LUA and writing them directly into the Domoticz database (info available on this forum about that).
I hope this helps you!
Code: Select all
commandArray = {}
--Extract Wind Gust speed from SValue Wind
wind = otherdevices_svalues['Windmeter']
print("Wind: "..wind)
--Filter the third digitsequence from SValue
a = string.sub(wind,1,string.find(wind,';',1,true)-1)
--print("a: "..a)
b = string.sub(wind,string.find(wind,';',1,true)+1)
--print("b: "..b)
winddirection = string.sub(b,1,string.find(b,';',1,true)-1)
--print("Winddirection: "..winddirection)
d = string.sub(b,string.find(b,';',1,true)+1)
--print("d: "..d)
windspeed = string.sub(d,1,string.find(d,';',1,true)-1)
print("Windspeed: "..windspeed)
f = string.sub(d,string.find(d,';',1,true)+1)
--print("f: "..f)
windgust = string.sub(f,1,string.find(f,';',1,true)-1)
print("Windgust: "..windgust)
g = string.sub(f,string.find(f,';',1,true)+1)
--print("g: "..g)
temperature = string.sub(g,1,string.find(g,';',1,true)-1)
print("Temperature: "..temperature)
--Extract UV radiation from SValue Wind
solar = otherdevices_svalues['UV']
print("Solar Radiation: "..solar)
--Filter the first digit from SValue
uv = string.sub(solar,1,string.find(solar,';',1,true)-1)
print("UV: "..uv)
--Extract actual rainfall from Rain_SValue
rain = otherdevices_svalues['Rainmeter']
print("Rain: "..rain)
--Filter the first digit from SValue
currentrain = string.sub(rain,1,string.find(rain,';',1,true)-1)
print("Current rain: "..currentrain)
--Filter the last digit from SValue
totalrain = string.sub(rain,string.find(rain,';',1,true)+1)
print("Total rain: "..totalrain)
--Sunscreen thresholds:
-- Windspeed = 100.0 (value is multiplied by 100)
-- Rain = 0.0
-- UV = 4.0
-- Temperature = 15.0
-- Closed = Down = On
-- Open = Up = Off
if (timeofday['Daytime'])
then
print('It is past sunrise, monitoring variables for sunscreen')
if (otherdevices['Sunscreen'] == 'Open' ) then
print ('Sunscreen is up')
else
print ('Sunscreen is down')
end
if (otherdevices['Sunscreen'] == 'Open'
and currentrain == '0'
and temperature > '15.0'
and uv > '4.0')
-- and windspeed < '100')
then
print ('Sun is shining, all thresholds OK, lowering sunscreen')
commandArray['SendNotification']='Sunscreen#Sunscreen down --> Sun is shining'
commandArray['Sunscreen']='On'
elseif (otherdevices['Sunscreen'] == 'Closed' and currentrain > '0') then
print ('It is raining, raising sunscreen')
commandArray['SendNotification']='Sunscreen#Sunscreen up --> It is raining'
commandArray['Sunscreen']='Off'
elseif (otherdevices['Sunscreen'] == 'Closed' and temperature < '15.0') then
print ('Temperature too low, raising sunscreen')
commandArray['SendNotification']='Sunscreen#Sunscreen up --> It is too cold'
commandArray['Sunscreen']='Off'
elseif (otherdevices['Sunscreen'] == 'Closed' and uv < '4.0') then
print ('Sun not shining too bright, raising sunscreen')
commandArray['SendNotification']='Sunscreen#Sunscreen up --> Sunshine not too bright'
commandArray['Sunscreen']='Off'
-- elseif (otherdevices['Sunscreen'] == 'Closed' and windspeed > '100') then
-- print ('Windspeed too high, raising sunscreen')
-- commandArray['SendNotification']='Sunscreen#Sunscreen up --> Windspeed too high'
-- commandArray['Sunscreen']='Off'
else
print('Sunscreen status OK --> No action')
end
elseif (timeofday['Nighttime']
and otherdevices['Sunscreen'] == 'Closed')
then
print('It is night, raising sunscreen')
commandArray['SendNotification']='Sunscreen#Sunscreen up --> It is night'
commandArray['Sunscreen']='Off'
else
print('Sunscreen already up --> No action')
end
return CommandArray