On the Weather tab I have all the usual items including UV levels.
I have several DzV scripts running to control and monitor lights, blinds/shutters, radio etc based on time of day and sunrise/sunset.
I want to add to the shutter control that when the UV level is >= x between certain hours then particular shutters should drop until time y.
But I can't seem to work out how to do it.
Can someone give me a clue please.
Get UV values.
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Get UV values.
I use the dzVents script below to control my sunscreen. One of the conditions I check is uv. Please have a look. Happy to help if something is not clear.paul402 wrote: Monday 24 June 2019 12:26 On the Weather tab I have all the usual items including UV levels. Can someone give me a clue please.
Code: Select all
-- sunScreen.lua
return
{
on = { timer = { 'every 12 minutes between 11:25 and 23:59 on 15/4-15/9' }},
logging = { level = domoticz.LOG_ERROR, marker = 'Sunscreen' },
execute = function(dz)
local round = dz.utils.round
-- devices
local mySunscreen = dz.devices('Zonwering')
local myWind = dz.devices('wind Rotterdam')
local myTemperature = dz.devices('temperatuur Rotterdam')
local myRain = dz.devices('neerslag Rotterdam')
local myRainExpected = dz.devices('60 minute rain forecast')
local myRadiation = dz.devices('Max.UV Rotterdam')
local myMotion = dz.devices('Beweging buiten')
local myLux = dz.devices('YoulessLux')
local dumpConditions = true
local function logWrite( msg, logLevel )
dz.log( tostring(msg), logLevel or dz.LOG_FORCE)
end
local function logConditions(calledBy)
logWrite("called by: " .. calledBy)
logWrite("myTemperature.temperature " .. round(myTemperature.temperature,1 ))
logWrite("myWind.speed " .. round(myWind.speed,1 ))
logWrite("myWind.gust " .. round(myWind.gust,1 ))
logWrite("myRain.rainRate " .. tostring(myRain.rainRate))
logWrite("myRainExpected.state " .. tostring(myRainExpected.state))
logWrite("myRadiation.uv " .. round(myRadiation.uv,1 ))
logWrite("dz.time.matchesRule('at 12:00-19:00') " .. tostring(dz.time.matchesRule('at 12:00-19:00') ))
logWrite("dz.time.matchesRule('at 23:00-01:00') " .. tostring(dz.time.matchesRule('at 23:00-01:00')))
logWrite("dz.time.matchesRule('at nighttime') " .. tostring(dz.time.matchesRule('at nighttime')))
logWrite("mySunscreen.lastUpdate.minutesAgo " .. tostring(mySunscreen.lastUpdate.minutesAgo ))
logWrite("myMotion.lastUpdate.minutesAgo " .. tostring(myMotion.lastUpdate.minutesAgo))
logWrite("myLux.lux " .. round(myLux.lux,1 ))
end
if
( myTemperature.temperature > 18 and
myWind.speed < 6 and
myWind.gust < 17 and
tonumber(myRain.rainRate) < 0.2 and
tonumber(myRainExpected.state) < 1 and
myRadiation.uv > 4 and
dz.time.matchesRule('at 12:00-19:00') and
mySunscreen.lastUpdate.minutesAgo > 30 and
myMotion.lastUpdate.minutesAgo > 5 and
myLux.lux > 2200
) then
mySunscreen.switchOn()
if dumpConditions then logConditions('open') end
elseif
( dz.time.matchesRule('at 23:00-01:00') or
myWind.speed > 5 or
myWind.gust > 16 or
tonumber(myRain.rainRate) > 0.1 or
dz.time.matchesRule('at nighttime') or
tonumber(myRainExpected.state) >1 or
myLux.lux < 400 or
myTemperature.temperature < 16
) then
mySunscreen.switchOff()
if dumpConditions then logConditions('close') end
else
if dumpConditions then logConditions('neither') end
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
paul402
- Posts: 105
- Joined: Monday 23 May 2016 23:07
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Get UV values.
Thanks! I see now that I had just used my "Label Name" rather than "local uv_value=outside_sensor.uv".
I had used it correctly for the other sensors!
The leg up is much appreciated. Sometimes you miss the little things.
I had used it correctly for the other sensors!
The leg up is much appreciated. Sometimes you miss the little things.
Who is online
Users browsing this forum: No registered users and 1 guest