dynamically dimming without burning my eyes at night  [Solved]

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

Moderator: leecollings

Post Reply
markjgabb
Posts: 142
Joined: Tuesday 24 January 2017 23:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Australia
Contact:

dynamically dimming without burning my eyes at night

Post 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
}
V 2020.2 RPI 3
RFlink 334 mhz
mysensors
broadlink
Mirabella Genio Globes
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: dynamically dimming without burning my eyes at night

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
markjgabb
Posts: 142
Joined: Tuesday 24 January 2017 23:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Australia
Contact:

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

Post 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
}
V 2020.2 RPI 3
RFlink 334 mhz
mysensors
broadlink
Mirabella Genio Globes
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest