date + Hour no work (Resolved)  [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:

date + Hour no work (Resolved)

Post by Hydci »

Hello,

My dzvent no work i can not find the problem if anyone could help me

Ps: i'm french my english is no good

Code: Select all

return {
    on = { devices = { 'Capteur Toilette','Interrupteur Toilette','Toilette1'},
        timer = {'at 21:00-07:59','at 08:00-20:59'}
        },
	
	execute = function(domoticz, timer, item, device)
	   if item.state == "Open" or item.state == "Click" and domoticz.time.matchesRule('at 21:00-07:59') then
	       domoticz.devices("Toilette1").dimTo(15)
    end
    if item.state == "Open" or item.state == "Click" and domoticz.time.matchesRule('at 08:00-20:59') then
        domoticz.devices("Toilette1").dimTo(99)
        domoticz.devices("Toilette2").switchOn()
    end
    if item.state == "Open" or item.state == "Click" and domoticz.devices('Toilette1') == 'On' then
        domoticz.devices("Toilette1").switchOff()
        domoticz.devices("Toilette2").switchOff()
        end
end
}
Last edited by Hydci on Thursday 06 June 2019 12:37, edited 1 time in total.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: date + Hour no work

Post by waaren »

Hydci wrote: Thursday 06 June 2019 10:45 My dzVents no work i can not find the problem if anyone could help me
Not 100% sure if this is what you want but please try.

Code: Select all

return {
        on = 
        { 
            devices = { 'Capteur Toilette', 'Interrupteur Toilette', 'Toilette1' },
        },

        logging =
       {
            level   =   domoticz.LOG_DEBUG,
            marker  =   'Toilette control',
       },

    execute = function(dz, item )
        Toilette1 = dz.devices('Toilette1')
        Toilette2 = dz.devices('Toilette2')
      

        if item.state == 'Open' or item.state == 'Click' then
            if Toilette1.state == 'On' then
                Toilette1.switchOff().silent()
                Toilette2.switchOff().silent()
            elseif dz.time.matchesRule('at 21:00-07:59') then
                Toilette1.dimTo(15).silent()
            else
                Toilette1.dimTo(99).silent()
                Toilette2.switchOn().silent()
            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
Hydci
Posts: 35
Joined: Tuesday 04 June 2019 21:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: France
Contact:

Re: date + Hour no work  [Solved]

Post by Hydci »

the script works great thanks for your help i understand better how i should write my next script
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest