Ikea motion sensor - Off Delay Topic is solved

Xiaomi, Ikea TRÅDFRI, Philips Hue and more.

Moderator: leecollings

Post Reply
User avatar
Varazir
Posts: 406
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Ikea motion sensor - Off Delay

Post 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
}
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Ikea motion sensor - Off Delay

Post 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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
Varazir
Posts: 406
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Ikea motion sensor - Off Delay

Post 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
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
User avatar
Varazir
Posts: 406
Joined: Friday 20 February 2015 22:23
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Ikea motion sensor - Off Delay

Post 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
}
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest