Page 1 of 1

Pause DZVents script [Solved]

Posted: Monday 25 February 2019 20:16
by alarm_guy1
Hi guys,

I have a DZvents script, that runs well.

Basically my bathroom lights come on @ 90%when the detector picks you up, If the time is after 22:00 and before 06:00 the light comes on @20% so it is not too bright at night. and all the while it detects movement the lights stay on

However the issue I have is when the good lady in my life has a bath she asks Alexa, bathroom 20% all good however If she moves the lights then go back to 90%.
I need something that can pause the script for say an hour and the light will just stay at the level set

i.e. Alexa Bathtime on, script stops lights come on @20% and stay on until Alexa bathime off.

any help appreciated

cheers

Re: Pause DZVents script

Posted: Monday 25 February 2019 22:02
by heggink
How about you only change the level if the light was off to begin with? So rather than reset on every movement, do it only if the light is off?

Verstuurd vanaf mijn SM-G955F met Tapatalk


Re: Pause DZVents script

Posted: Tuesday 26 February 2019 18:39
by alarm_guy1
Thankyou for you reply, it is a difficult situation that cannot easily be rectified.
as we could go for a bath or shower at anytime or just go to wash and clean our teeth toilet etc. and there is no easy way for a system to know what we want to do, without extra sensors.

but I really require to just disable the DZvents

Re: Pause DZVents script

Posted: Wednesday 27 February 2019 2:52
by waaren
alarm_guy1 wrote: Monday 25 February 2019 20:16 Basically my bathroom lights come on @ 90%when the detector picks you up, If the time is after 22:00 and before 06:00 the light comes on @20% so it is not too bright at night. and all the while it detects movement the lights stay on
However the issue I have is when the good lady in my life has a bath she asks Alexa, bathroom 20% all good however If she moves the lights then go back to 90%.
I need something that can pause the script for say an hour and the light will just stay at the level set
i.e. Alexa Bathtime on, script stops lights come on @20% and stay on until Alexa bathime off.
any help appreciated
Probably easiest to create a dummy device in domoticz and change the Alexa action to this device. The dzVents script below will ensure that the lights will not change dimLevel when triggered by PIR while this dummy device is active.

Code: Select all

local alexaDummyDevice = xxx -- <<<----- replace xxx by IDX of your alexaDummyDevice

return  {
            on          =   {
                                devices           =        {
                                                            "Bathroom MD Sensor",
                                                            alexaDummyDevice,
                                                        },
                            },

            logging     =   {
                                level           =   domoticz.LOG_DEBUG,
                                marker          =   "Bathroom Motion"
                            },

    execute = function(dz, item)

        local dimmed         = 20                 -- dimlevel 
        local bright         = 90                 -- dimlevel
        local shortVisit    = 300                -- seconds
        local longStay        = 3600               -- seconds
        
        local function logWrite(str,level)
            dz.log(str,level or dz.LOG_DEBUG)
        end

        local LuxDevice          = dz.devices(450)                 -- <<<--- replace xxx by IDX of your Lux device
        local Lux                = LuxDevice.lux
        local Lights             = dz.devices(440)                       -- <<<--- replace xxx by IDX of your Bathroom lights
        local alexaActivated     = dz.devices(alexaDummyDevice).active

        logWrite(LuxDevice.name .. " ==>> Lux:   " .. Lux )
        logWrite(Lights.name ..    " ==>> State: " .. Lights.state)
        logWrite(item.name ..      " ==>> State: " .. item.state)

        if item.id == alexaDummyDevice then
            Lights.cancelQueuedCommands()
            if item.active then
                Lights.dimTo(dimmed)
                item.switchOff().afterSec(longStay)
            else
                Lights.switchOff()
            end
        elseif Lux < 100 and item.state == "On" and not ( alexaActivated ) then
            Lights.cancelQueuedCommands()

            if dz.time.matchesRule("at 23:00-06:00") then
                Lights.dimTo(dimmed)
            else
                Lights.dimTo(bright)
            end
        elseif item.state == "Off" and Lights.state == "On" and not ( alexaActivated ) then
            Lights.switchOff().afterSec(shortVisit)
        end
    end
}

Re: Pause DZVents script

Posted: Wednesday 27 February 2019 3:55
by alarm_guy1
Excellant, I will give this a try.

Many many thanks