roller shutter and protect light on  [Solved]

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

Moderator: leecollings

Post Reply
Hydci
Posts: 35
Joined: Tuesday 04 June 2019 21:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

roller shutter and protect light on

Post by Hydci »

Bonjour,

Je chercher a écrire mon dzvent pour l'ouverture et fermeture des volet selon le coucher ou lever du soleil mais je bloque sur la partie du script avec la lumière on

Code: Select all

return {
        on = { timer = { '30 minutes after sunset','30 minutes after sunrise' },
		 devices = {'Lightgarden'}
		},

    execute = function(dz, item )
      
   if dz.time.matchesRule('30 minutes after sunset') and  then
   if dz.devices == 'Off'
	domoticz.openURL('https://maker.ifttt.com/trigger/Volet_salon_fermeture/with/key/xxxx) --closeblind
	domoticz.openURL('https://maker.ifttt.com/trigger/Volet_cuisine_fermeture/with/key/xxxxx) --closeblind
	elseif dz.time.matchesRule('30 minutes after sunrise') then
		domoticz.openURL('https://maker.ifttt.com/trigger/Volet_salon_ouverture/with/key/xxxx') --Openblind
		domoticz.openURL('https://maker.ifttt.com/trigger/Volet_cuisine_ouverture/with/key/xxxxx') --Openblind
		
	If dz.device('Lifgtgarden'] == 'On' then
	wait light garden off and close blind nightime 
            end
        end
    end
}
Hydci
Posts: 35
Joined: Tuesday 04 June 2019 21:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: roller shutter and protect light on

Post by Hydci »

so i did this in the meantime but i would like to add an option with light if off shut the shutters if on the light wait for the off of the light

Code: Select all

return {
        on = { timer = { '30 minutes after sunset','30 minutes after sunrise' },
		},

    execute = function(dz, time )
      
   if dz.time.matchesRule('30 minutes after sunset') then
	domoticz.openURL('https://maker.ifttt.com/trigger/Volet_salon_fermeture/with/key/xxxx') --closeblind
	domoticz.openURL('https://maker.ifttt.com/trigger/Volet_cuisine_fermeture/with/key/xxxx') --closeblind
	elseif dz.time.matchesRule('59 minutes after sunrise') then
		domoticz.openURL('https://maker.ifttt.com/trigger/Volet_salon_ouverture/with/key/xxxx') --Openblind
		domoticz.openURL('https://maker.ifttt.com/trigger/Volet_cuisine_ouverture/with/key/xxxx') --Openblind
            end
        end
}

so i think something like that a help would be nice to corrected

Code: Select all

return {
        on = { timer = { '30 minutes after sunset','30 minutes after sunrise','NighTime' },
		 devices = {'Lightgarden'}
		},

    execute = function(dz, item )
      
        if dz.time.matchesRule('30 minutes after sunset') then
        if dz.devices == 'Off' then
	dz.openURL('https://maker.ifttt.com/trigger/Volet_salon_fermeture/with/key/xxxx') --closeblind
	dz.openURL('https://maker.ifttt.com/trigger/Volet_cuisine_fermeture/with/key/xxxxx') --closeblind
	elseif dz.time.matchesRule('30 minutes after sunrise') then
	dz.openURL('https://maker.ifttt.com/trigger/Volet_salon_ouverture/with/key/xxxx') --Openblind
    dz.openURL('https://maker.ifttt.com/trigger/Volet_cuisine_ouverture/with/key/xxxxx') --Openblind
		end
	if item.state('Lifgtgarden') == 'Off' then
	if (timeofday['Nighttime']) then
	dz.openURL('https://maker.ifttt.com/trigger/Volet_salon_fermeture/with/key/xxxx') --closeblind
	dz.openURL('https://maker.ifttt.com/trigger/Volet_cuisine_fermeture/with/key/xxxxx') --closeblind
            end
        end
    end
end
}
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: roller shutter and protect light on

Post by waaren »

Hydci wrote: Thursday 06 June 2019 15:34 so i did this in the meantime but i would like to add an option with light if off shut the shutters if on the light wait for the off of the light
Hope this can get you started. If something not clear do not hesitate to ask clarification

Code: Select all

return {
        on = 
        {
            timer     = { '30 minutes after sunset','30 minutes after sunrise' },
            devices = {'Lightgarden'},
        },

        logging = 
        {
            level = domoticz.LOG_DEBUG, 
            marker = 'Volets' 
        },

    execute = function( dz, item )

        local keyIFTTT = 'xxxxxxxx'
        local salon = 'salon'
        local cuisine = 'cuisine'
        local open = 'ouverture'
        local close = 'fermeture'

        -- domoticz.triggerIFTTT is a native dzVents method for version >= 2.4.18 
        local function triggerIFTTT( action, ... ) -- ... accepts 1 - many parms
            for _, room in ipairs({...}) do -- walk through all ... parms
                dz.openURL('https://maker.ifttt.com/trigger/Volet_' .. room .. '_' .. action .. '/with/key/' .. keyIFTTT ) -- call IFTTT webhook
            end
        end

        if item.isDevice and item.state == 'Off' and dz.time.isNightTime then
            triggerIFTTT(close, salon, cuisine )
        elseif dz.time.matchesRule('30 minutes after sunset') then
            triggerIFTTT(close, salon, cuisine )
        elseif dz.time.matchesRule('30 minutes after sunrise') then
            triggerIFTTT(open, salon, cuisine )
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Hydci
Posts: 35
Joined: Tuesday 04 June 2019 21:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: roller shutter and protect light on  [Solved]

Post by Hydci »

thanks for the answer actually script writing and very different from mine so I will have to learn to look at the script blocks to understand them
Hydci
Posts: 35
Joined: Tuesday 04 June 2019 21:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: roller shutter and protect light on

Post by Hydci »

So your script works as you wrote it to me

Code: Select all

return {
        on = 
        {
            timer     = { '20 minutes after sunset','59 minutes after sunrise' },
            devices = {'Jardin'},
        },

        logging = 
        {
            level = domoticz.LOG_DEBUG, 
            marker = 'Volets' 
        },

    execute = function( dz, item )

        local keyIFTTT = 'xxxxxxxx'
        local salon = 'salon'
        local cuisine = 'cuisine'
        local open = 'ouverture'
        local close = 'fermeture'

        -- domoticz.triggerIFTTT is a native dzVents method for version >= 2.4.18 
        local function triggerIFTTT( action, ... ) -- ... accepts 1 - many parms
            for _, room in ipairs({...}) do -- walk through all ... parms
                dz.openURL('https://maker.ifttt.com/trigger/Volet_' .. room .. '_' .. action .. '/with/key/' .. keyIFTTT ) -- call IFTTT webhook
            end
        end

        if item.isDevice and item.state == 'Off' and dz.time.matchesRule('at nighttime') then
            triggerIFTTT(close, salon, cuisine )
        elseif dz.time.matchesRule('20 minutes after sunset') then --coucher du soleil
            triggerIFTTT(close, salon, cuisine )
        elseif dz.time.matchesRule('59 minutes after sunrise') then -- lever du soleil
            triggerIFTTT(open, salon, cuisine )
        end
    end
}
so I change for school days and weekends and protect eat garden light on no close shutter after finish eat light off the shutter close Thank you again for your help

Code: Select all

return {
        on = 
        {
            timer     = { '20 minutes after sunset','at 7:30 on mon,tue,thu,fri','at 8:30 on wed,sat,sun'},
            devices = {'Jardin'},
        },

        logging = 
        {
            level = domoticz.LOG_DEBUG, 
            marker = 'Volets' 
        },

    execute = function( dz, item, devices )

        local keyIFTTT = 'xxxxx'
        local salon = 'salon'
        local cuisine = 'cuisine'
        local open = 'ouverture'
        local close = 'fermeture'

        -- domoticz.triggerIFTTT is a native dzVents method for version >= 2.4.18 
        local function triggerIFTTT( action, ... ) -- ... accepts 1 - many parms
            for _, room in ipairs({...}) do -- walk through all ... parms
                dz.openURL('https://maker.ifttt.com/trigger/Volet_' .. room .. '_' .. action .. '/with/key/' .. keyIFTTT ) -- call IFTTT webhook
            end
        end

        if item.isDevice and item.state == 'Off' and dz.time.matchesRule('at nighttime') then
            triggerIFTTT(close, salon, cuisine )
        elseif dz.time.matchesRule('20 minutes after sunset') and dz.devices('Jardin').state == 'Off' then
            triggerIFTTT(close, salon, cuisine )
        elseif dz.time.matchesRule('at 7:30 on mon,tue,thu,fri') then
            triggerIFTTT(open, salon, cuisine )
		elseif dz.time.matchesRule('at at 8:30 on wed,sat,sun') then
            triggerIFTTT(open, salon, cuisine )
        end
    end
}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest