Page 1 of 1

use Wind from Buienradar plugin in DzVents

Posted: Wednesday 22 July 2020 15:44
by AllesVanZelf
In this topic buienradar lua script I've found this code for LUA.

Code: Select all

commandArray = {}
-- only check windspeed when Wind info is updated
if devicechanged['Wind'] then
	sDirectionDegrees, sDirection, sSpeed, sGust, sTemperature, sFeel = otherdevices_svalues['Wind']:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
	-- check whether the sunscreen is "out"
	if (otherdevices['Sunscreen'] == 'Open') then
		-- send warning when speed is over 60km
		if sSpeed < 60 then
			print('Windsnelheid hoger dan 60 km en Sunscreen is open.')
		end
	end
end
return commandArray
How can I convert this to DzVents? as an 'elseif'
The Buienradar device 'BR Wind' (in my case) gives the folowing data: 296.00;WNW;40;88;18.8;18.8
I want to use the 40 value (sSpeed) in this data-example, as is 4,0 m/s. If this value is 88 (=8,8m/s, 5bft) then ....

How can I do this?

Re: use Wind from Buienradar plugin in DzVents

Posted: Wednesday 22 July 2020 16:03
by waaren
AllesVanZelf wrote: Wednesday 22 July 2020 15:44 The Buienradar device 'BR Wind' (in my case) gives the folowing data: 296.00;WNW;40;88;18.8;18.8
I want to use the 40 value (sSpeed) in this data-example, as is 4,0 m/s. If this value is 88 (=8,8m/s, 5bft) then ....
Please have a look at the wiki for this device type It shows the attributes available in dzVents.

Re: use Wind from Buienradar plugin in DzVents

Posted: Wednesday 22 July 2020 17:04
by AllesVanZelf
I do this with a lot of trial and error :D
This is my code now:

Code: Select all

return
{
     on =
     {
        timer = 
        {
            'every 5 minutes',
        },
        devices =
        {
            'BR Mogelijk Regen',
            'BR Regent het?',
            'BR Regen komend uur',
            'BR Zonnekracht',
            'BR Wind',
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
    },
    
    execute = function(dz)
        local shutter = dz.devices('Zonwering Qubino Shutter')
        local possibleRain = dz.devices('BR Mogelijk Regen').state
        local raining = dz.devices('BR Regent het?').state
        local nextHourRain = tonumber(dz.devices('BR Regen komend uur').sValue)
        local sunPower = tonumber(dz.devices('BR Zonnekracht').sValue)
        local automaat = dz.devices('Zonwerking automatisch').state
        local wind = dz.devices('BR Wind').speedMs

        dz.log(shutter.name .. ',    state: ' .. tostring(shutter.state) , dz.LOG_DEBUG)
        dz.log('BR Mogelijk Regen,   state: ' .. tostring(possibleRain) , dz.LOG_DEBUG)
        dz.log('BR Regent het?,      state: ' .. tostring(raining) , dz.LOG_DEBUG)
        dz.log('BR Regen komend uur, value: ' .. tostring(nextHourRain) , dz.LOG_DEBUG)
        dz.log('BR Zonnekracht,      value: ' .. tostring(sunPower) , dz.LOG_DEBUG)
        dz.log('Zonwering automatisch,   state: ' .. tostring(automaat) , dz.LOG_DEBUG)
        dz.log('BW Wind,             value: ' .. tostring(wind) , dz.LOG_DEBUG)

        -- Zonwering open
        if shutter.state == 'Closed' and automaat == 'On' and dz.time.matchesRule('at 9:30-15:20') and possibleRain == 'Off' and raining == 'Off' and nextHourRain == 0  and sunPower >= 700 and wind <= 7.4 then
            shutter.dimTo(50).silent()

        -- Zonwering dicht op tijd
        elseif shutter.state ~= 'Closed' and automaat == 'On' and dz.time.matchesRule('at 15:30-23:59') then
            shutter.dimTo(100).silent()
            dz.notify('Zonwering dicht','Het is 15:30, de zonwering gaat dicht', dz.PRIORITY_LOW, dz.SOUND_DEFAULT,nil, dz.NSS_TELEGRAM)

        -- Zonwering dicht vanwege mogelijke regen
        elseif shutter.state ~= 'Closed' and automaat == 'On' and possibleRain == 'On' then
            shutter.dimTo(100).silent()
            dz.notify('Zonwering dicht','Het regent volgens Buienradar, de zonwering gaat dicht', dz.PRIORITY_LOW, dz.SOUND_DEFAULT,nil, dz.NSS_TELEGRAM)

        -- Zonwering dicht vanwege komend uur regen
        elseif shutter.state ~= 'Closed' and automaat == 'On' and nextHourRain > 0  then
            shutter.dimTo(100).silent()
            dz.notify('Zonwering dicht','Het gaat komend uur regenen volgens Buienradar, de zonwering gaat dicht', dz.PRIORITY_LOW, dz.SOUND_DEFAULT,nil, dz.NSS_TELEGRAM)

        -- Zonwering dicht vanwege harde wind
        elseif shutter.state ~= 'Closed' and wind > 8.0 then
            shutter.dimTo(100).silent()
            dz.notify('Zonwering dicht','Het waait te hard volgens Buienradar, de zonwering gaat dicht', dz.PRIORITY_LOW, dz.SOUND_DEFAULT,nil, dz.NSS_TELEGRAM)

        end
    end
}
No error is the log this time.
I'm not sure about the tonumbers and tostrings. But I will have a look if it is working coming days.
any advice is appreciated! I learn a lot here! :D

Re: use Wind from Buienradar plugin in DzVents

Posted: Monday 10 August 2020 9:24
by EdwinK
Trying this myself now.

Is it possible to add 'UV' as well? (and maybe even 'lux'?)