Return to previous brightness value  [Solved]

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

Moderator: leecollings

Post Reply
eleutscher
Posts: 22
Joined: Thursday 15 November 2018 11:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Return to previous brightness value

Post by eleutscher »

Hello

Is it possible in Blocky (or scripting) to set the brightness of a lamp that is already on at 25% to 80% for x minutes and after this time to set it back to its previous value at 25%?
Is there a entry that saves the previous value so that you can use this again?

Thx, Erik
Zigbee, KAKU, Hue, Google, Honeywell, MotionEye, Telegram, Tasmota, Shelly, IFTTT, etc
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Return to previous brightness value

Post by waaren »

eleutscher wrote: Friday 25 September 2020 16:43 Is it possible in Blocky (or scripting) to set the brightness of a lamp that is already on at 25% to 80% for x minutes and after this time to set it back to its previous value at 25%?
Is there a entry that saves the previous value so that you can use this again?
I would not know how to do this in Blockly but it is possible to restore the brightness to a previous state using dzVents. What would trigger the Brightness increase and what is the condition for it to return to the previous state ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
eleutscher
Posts: 22
Joined: Thursday 15 November 2018 11:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Return to previous brightness value

Post by eleutscher »

Hai Waaren,

For example. I have my outside lights at 25% brightness and I would like them to go to 100% for 5 minutes after a PIR gets triggered or another event/button. After the 5 min they have to back to the 25%. But I do not want to think about what their previous value was. Just the value before the event. Hope you can help. Thx, Erik
Zigbee, KAKU, Hue, Google, Honeywell, MotionEye, Telegram, Tasmota, Shelly, IFTTT, etc
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Return to previous brightness value

Post by waaren »

eleutscher wrote: Monday 28 September 2020 19:44 I have my outside lights at 25% brightness and I would like them to go to 100% for 5 minutes after a PIR gets triggered or another event/button. After the 5 min they have to back to the 25%. But I do not want to think about what their previous value was.
Can you try with below dzVents script?

When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."

Code: Select all

return 
{
    on =
    {
        devices =
        {
            'PIR', -- change to name of PIR or other triggering device
        },
    },

    logging =
    {  
        level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all ok
        marker = 'restore brightness',
    },

    execute = function(dz, item)

        if item.active then
            local light = dz.devices('outside light') -- change to name of light
            
            local currentLevel = ( light.active and light.level ) or 0 
            
            light.cancelQueuedCommands()
            light.dimTo(100)
            light.dimTo(currentLevel).afterSec(300) 
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
eleutscher
Posts: 22
Joined: Thursday 15 November 2018 11:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Return to previous brightness value

Post by eleutscher »

Hai Waaren, Thanks for your reply and this seems to work.

But I have multiple outside light with corresponding values. Is it possible to extend this script for let's say 5 lights? With light 1 has an initial level of 25 and light 2 an level of 40 ad light 3 can only be on or off, etc.

I hope you understand this and can help me with this.
Zigbee, KAKU, Hue, Google, Honeywell, MotionEye, Telegram, Tasmota, Shelly, IFTTT, etc
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Return to previous brightness value

Post by waaren »

eleutscher wrote: Tuesday 10 November 2020 11:27 I have multiple outside light with corresponding values. Is it possible to extend this script for let's say 5 lights? With light 1 has an initial level of 25 and light 2 an level of 40 ad light 3 can only be on or off, etc.
Please try with below script

Code: Select all

return
{
    on =
    {
        devices =
        {
            'PIR', -- change to name of PIR or other triggering device
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all ok
        marker = 'restore brightness',
    },

    execute = function(dz, item)

        local DIMMER = 1
        local SWITCH = 2
        local delay = 300

        local lights =
        {    -- name, TYPE
            ['outside light'] = DIMMER,          -- Change to your device names and add the type of devices
            ['outside light2'] = DIMMER,
            ['outside light2'] = SWITCH,
        }

        if item.active then

            for name, type in pairs(lights) do
                local light = dz.devices(name)
                light.cancelQueuedCommands()
    
                if type == DIMMER then
                    local currentLevel = ( light.active and light.level ) or 0
                    light.dimTo(100)
                    light.dimTo(currentLevel).afterSec(delay)
                elseif type == SWITCH then
                    if light.state == 'Off' then
                        light.switchOn()
                        light.switchOff().afterSec(delay)
                    end
                else
                    dz.log(name .. ' Has an unknown type: ',dz.LOG_ERROR)
                end
            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
eleutscher
Posts: 22
Joined: Thursday 15 November 2018 11:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Return to previous brightness value  [Solved]

Post by eleutscher »

:D Yep, this is working! Thx @waaren
Zigbee, KAKU, Hue, Google, Honeywell, MotionEye, Telegram, Tasmota, Shelly, IFTTT, etc
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest