Page 1 of 1

dynamically dimming without burning my eyes at night

Posted: Tuesday 23 July 2019 12:11
by markjgabb
appologies if this has been asked before, i got back 4 pages and couldnt find anything relating to this


im wanting to alter my current DZvents script to allow for a slight alteration

if hall sensor is activated after midnight, i want it to only turn the lights on at a certain level, say 10%
no i know i can do this, but previously i have to set the light back to 100% before i turn it off so it will be back at 100 % the next morning....

is there a way to set the light level while the light is off?
so that way i could say light.switchon.level(20)
and when im done 2 min later light.switchoff.level100

below is my current script

Code: Select all

return {
    on = 
    {
        devices = {
            'Hall Motion'
        },
        
     timer = {
         
         'at nighttime'
         }
    },
    execute = function(domoticz, device)
        if 
            ( device.state == 'On')
            
        then
            if (domoticz.devices('Mood Light').state == 'Off')
            then
            domoticz.devices('Mood Light').switchOn().forMin(1)
            domoticz.log('Hall Montion Sensor Detected Turn light on')
            end
        end
    end
}

Re: dynamically dimming without burning my eyes at night

Posted: Tuesday 23 July 2019 13:22
by waaren
markjgabb wrote: Tuesday 23 July 2019 12:11 if hall sensor is activated after midnight, i want it to only turn the lights on at a certain level, say 10%
no i know i can do this, but previously i have to set the light back to 100% before i turn it off so it will be back at 100 % the next morning....

Is there a way to set the light level while the light is off?
Not that I know off but this script should get you close.

Script is only tested with recent domoticz version !

Code: Select all

return {
    on = { devices = { 'Hall Motion' }},
    
    execute = function(dz, item)
        local moodLight = dz.devices('Mood Light')
        local delay = 120

        if item.active then
            if dz.time.matchesRule('at nighttime') then
                moodLight.cancelQueuedCommands()
                moodLight.dimTo(20)
                moodLight.dimTo(100).afterSec(delay)
                moodLight.switchOff().afterSec(delay+0.1)
            else
                moodLight.dimTo(100) 
            end
        end
    end
}

Re: dynamically dimming without burning my eyes at night  [Solved]

Posted: Tuesday 23 July 2019 13:54
by markjgabb
awesome thanks

ive added another line to make sure that it only happens at night and thats great


thank you so much

Code: Select all

return {
    on = { 
        devices = { ['Hall Motion']  =  {'at nighttime'}}
        },
    
    execute = function(dz, item)
        local moodLight = dz.devices('Mood Light')
        local delay = 120

        if item.active then
            if dz.time.matchesRule('between 21:00 and sunrise') then
                moodLight.cancelQueuedCommands()
                moodLight.dimTo(5)
                moodLight.dimTo(100).afterSec(delay)
                moodLight.switchOff().afterSec(delay+0.1)
            else
                moodLight.dimTo(100)
                moodLight.switchOff().afterSec(delay+0.1)
            end
        end
    end
}