Page 1 of 1

Ikea motion sensor - Off Delay

Posted: Monday 19 October 2020 20:46
by Varazir
Hello,

I have 2 Ikea sensors and one is set to 10 min and the second to 3 min.
I want to extend the second to 10 min so I changed the Off Delay but the lamps still turns off after 3 min even if I have set it to 1200 seconds.

Bug or is it something with zigbee ?

I use this script to control my lamps.

Code: Select all

return {
	on = 
	{
	   	devices =   
	   	{
	        'IKEA - Sensor sovrum'
		},
	},
	
	logging =   
	{ 
        level           = domoticz.LOG_FORCE, 
        marker          = "IKEASensorSovrum" 
    },
            
    execute = function(dz, device)
        local function logWrite(str,level)
                dz.log(tostring(str),level)
        end

        local dimLevel = 0

        logWrite('00...............Sensor triggerd')
        
        if dz.time.isNightTime or dz.devices(59).state == 'Closed' then
            if device.state ~= 'On' then 
                dimLevel = 0
                logWrite('10...............Turning off the light')
            else
                dimLevel = 60
                logWrite('20...............Night time')
            end
            logWrite('30...............Dim value is ' .. dimLevel ..'%')
                dz.devices('IKEA - Taklampa Sovrum').dimTo(dimLevel)
                dz.devices('IKEA - Taklampa Hall').dimTo(dimLevel)
        end
    end
}

Re: Ikea motion sensor - Off Delay

Posted: Tuesday 20 October 2020 0:36
by waaren
Varazir wrote: Monday 19 October 2020 20:46 Bug or is it something with zigbee ?
Neither.

By setting an off Delay you tell domoticz to switchOff() the device the amount of seconds after it has been switched On. It does not delay the switchOff() when the device receives a switchOff() command from a script-, hardware or API.

Re: Ikea motion sensor - Off Delay

Posted: Tuesday 20 October 2020 7:32
by Varazir
waaren wrote:
Varazir wrote: Monday 19 October 2020 20:46 Bug or is it something with zigbee ?
Neither.

By setting an off Delay you tell domoticz to switchOff() the device the amount of seconds after it has been switched On. It does not delay the switchOff() when the device receives a switchOff() command from a script-, hardware or API.
Oh okay, I guess it's good to post your own setup so you can find another way.

What I mean after reading my script and your post I realized that I can set the delay in the script.

I was hoping that the device settings would override all commands. Oh well.

Thanks
Daniel

Skickat från min EML-L29 via Tapatalk

Re: Ikea motion sensor - Off Delay

Posted: Tuesday 20 October 2020 10:19
by Varazir
Something like this should work right ?
It will extend the light with 5 min each time the sensor is triggered ( after the initial 5 min ) I hope :)

Code: Select all

return {
	on = 
	{
	   	devices =   
	   	{
	        'IKEA - Sensor sovrum'
		},
	},
	
	logging =   
	{ 
        level           = domoticz.LOG_FORCE, 
        marker          = "IKEASensorSovrum" 
    },
            
    execute = function(dz, device)
        local function logWrite(str,level)
                dz.log(tostring(str),level)
        end

        local dimLevel = 0
        local delayTime = 0

        logWrite('00...............Sensor triggerd')
        
        if dz.time.isNightTime or dz.devices(59).state == 'Closed' then
            if device.state ~= 'On' then 
                dimLevel = 0
                delayTime = 300
                logWrite('10...............Turning off the light')
            else
                dimLevel = 60
                delayTime = 0
                dz.devices('IKEA - Taklampa Sovrum').cancelQueuedCommands()
                dz.devices('IKEA - Taklampa Hall').cancelQueuedCommands()
                logWrite('20...............Night time')
            end
            logWrite('30...............Dim value is ' .. dimLevel ..'%')
                dz.devices('IKEA - Taklampa Sovrum').dimTo(dimLevel).afterSec(delayTime)
                dz.devices('IKEA - Taklampa Hall').dimTo(dimLevel).afterSec(delayTime)
        end
    end
}