How to do this in dz vents?  [Solved]

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

Moderator: leecollings

Post Reply
edwin1234
Posts: 330
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

How to do this in dz vents?

Post by edwin1234 »

I tried in blocky but it doesnt work It keeps repeating the script
Is this possible in dzvents?
I have a switch “raam open” its have to go on for 1 minute if humidity sensor “temp/vocht” is 70% or higher
And if the humidity is lower then switch “raam dicht” must go on for 1 minute and then off

I will explain
Switch raam open switch a window opener that will take one minute to fully open and then needs the off signal
Switch raam dicht switch the window opener to close the window and that takes one minute to fully close and then needs an off signal.

Hope someone can help me
Thanks
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to do this in dz vents?

Post by waaren »

edwin1234 wrote: Monday 01 June 2020 12:05 Switch raam open switch a window opener that will take one minute to fully open and then needs the off signal
Switch raam dicht switch the window opener to close the window and that takes one minute to fully close and then needs an off signal.
Could look like below script.

Code: Select all

return 
{
    on = 
    {
        devices = 
        {
            'temp/vocht',
        },
    },
    
    logging = 
    {
        level = domoticz.LOG_DEBUG,  -- change to domoticz.LOG_ERROR when script works OK.
    },

    data =
    {
        currentState = 
        { 
            initial = '',
        },
    },

    execute = function(dz, item)
        local temperature = item.temperature
        local humidity = item.humidity
        local open = dz.devices('raam open')
        local close = dz.devices('raam dicht')

        dz.log('Device ' .. item.name .. '; temperature is '.. temperature .. '° C , humidity is ' ..humidity .. '% and window is ' .. dz.data.currentState ..'.', dz.LOG_DEBUG)
        if humidity > 70 and dz.data.currentState ~= 'Open' and open.lastUpdate.secondsAgo > 120 and close.lastUpdate.secondsAgo > 120 then -- don't want to toggle every couple of seconds
            open.switchOn()
            open.switchOff().afterSec(60)
            dz.data.currentState = 'Open'
        elseif humidity < 70 and dz.data.currentState ~= 'Closed' and open.lastUpdate.secondsAgo > 120 and close.lastUpdate.secondsAgo > 120 then -- don't want to toggle every couple of seconds
            close.switchOn()
            close.switchOff().afterSec(60)
            dz.data.currentState = 'Closed'
        end
    end
}


Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
edwin1234
Posts: 330
Joined: Sunday 09 October 2016 20:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Nederland
Contact:

Re: How to do this in dz vents?  [Solved]

Post by edwin1234 »

Thank you very much,
Your the best :P
I m gonna try it out

Regards
Edwin
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest