use Wind from Buienradar plugin in DzVents

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

use Wind from Buienradar plugin in DzVents

Post 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?
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: use Wind from Buienradar plugin in DzVents

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: use Wind from Buienradar plugin in DzVents

Post 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
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: use Wind from Buienradar plugin in DzVents

Post by EdwinK »

Trying this myself now.

Is it possible to add 'UV' as well? (and maybe even 'lux'?)
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest