How to, create a cleaning-knob (or scene)?! Topic is solved

Moderator: leecollings

BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

How to, create a cleaning-knob (or scene)?!

Post by BarryT »

Hi all, i hope someone can help me out a bit..
I have a lot of zigbee motion sensors (in every room) that will turn on the light (when the sensor says its dark enough to turn them on..)
this is done by a simple lua script, if motion detected turn on the light :)
the motion sensor has its own lux sensor, and so does not send a motion when the lux is to high.
this is working great, but now i want some higher level automation:

once or twice a week we are cleaning the house.
then we want to disable the motion sensors and set all the lights to 100+ white instead of some colors/dimmed lights.

now the question, is there a lua script somewhere, or someone can help me out with this?

Thanks a lot!
Barry
Last edited by BarryT on Friday 26 January 2024 18:39, edited 1 time in total.
HvdW
Posts: 532
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by HvdW »

I'd make a new on/off switch named 'my new switch' or anything you like.
Knowing nothing about LUA I did it with dzvents

Code: Select all

return {
	on = {
		devices = {'my new switch'},
	},

	execute = function(domoticz, triggeredItem)
        if domoticz.devices('my new botton').state == 'On' then
        domoticz.devices('device one').setLevel(82)
        domoticz.devices('device one').switchOn()
        domoticz.devices('device two').setLevel(82)
        domoticz.devices('device two').switchOn()
        end
        if domoticz.devices('my new botton').state == 'Off' then
        domoticz.devices('device one').setLevel(oldlevel)
        domoticz.devices('device one').switchOff()
        domoticz.devices('device two').setLevel(oldlevel)
        domoticz.devices('device two').switchOff()
        end
	end
}
Last edited by HvdW on Friday 26 January 2024 19:03, edited 1 time in total.
Bugs bug me.
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by BarryT »

HvdW wrote: Friday 26 January 2024 18:26 I'd make a new on/off switch named 'my new switch' or anything you like.

Code: Select all

return {
	on = {
		devices = {'my new switch'},
	},

	execute = function(domoticz, triggeredItem)
        if domoticz.devices('my new botton').state == 'On' then
        domoticz.devices('device one').setLevel(82)
        domoticz.devices('device one').switchOn()
        domoticz.devices('device two').setLevel(82)
        domoticz.devices('device two').switchOn()
        end
        if domoticz.devices('my new botton').state == 'Off' then
        domoticz.devices('device one').setLevel(oldlevel)
        domoticz.devices('device one').switchOff()
        domoticz.devices('device two').setLevel(oldlevel)
        domoticz.devices('device two').switchOff()
        end
	end
}
Thanks for answering and the script..!
But what about the motion detections wich i already have in my lua scripts, when this script is getting activated, my motion detections are overrule this script and the lights goes back to normal mode?
example of a my simple motion lua script:

Code: Select all

commandArray = {}

if (devicechanged['Motion'] == 'On') then commandArray['Lamp'] = 'Set Level 50'
elseif (devicechanged['Motion'] == 'Off') then commandArray['Lamp'] = 'Off' 

end
return commandArray
i guess i have to include this in the new scipt?
HvdW
Posts: 532
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by HvdW »

Make a dump of the properties of the motion detection like

Code: Select all

domoticz.devices('motiondetection_1).dump()
or just a simple

Code: Select all

domoticz.devices('motiondetection_1).switchOff
whatever is the right command and place that before the switch and level command in the first script.

Code: Select all

return {
	on = {
		devices = {'my new switch'},
	},
	data = {},
	logging = {},
	execute = function(domoticz, triggeredItem)
        if domoticz.devices('my new botton').state == 'On' then
        domoticz.devices('motiondetection_1).switchOff()
        domoticz.devices('device one').setLevel(82)
        domoticz.devices('device one').switchOn()
        domoticz.devices('motiondetection_2).switchOff()
        domoticz.devices('device two').setLevel(82)
        domoticz.devices('device two').switchOn()
        end
        if domoticz.devices('my new botton').state == 'Off' then
        domoticz.devices('motiondetection_1).switchOn()
        domoticz.devices('device one').setLevel(oldlevel)
        domoticz.devices('device one').switchOff()
        domoticz.devices('motiondetection_2).switchOn()
        domoticz.devices('device two').setLevel(oldlevel)
        domoticz.devices('device two').switchOff()
        end
	end
}
Bugs bug me.
Kedi
Posts: 563
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by Kedi »

I don't think that Motion Sensors can be switched On or Off.
I would go for changing the motion lua scripts by adding a check if the 'Control' device is On of Off/
Logic will get you from A to B. Imagination will take you everywhere.
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by BarryT »

Okay guys, Thanks for answering so far!
But i just want to keep it simple as possible..
I know it is not that easy to do this in lua, same for blocky.

But, maybe i need to create dummy switches for every motion that i can turn off?
So when virtual switch is ON AND motion is ON, lamp ON.
Else if, virtual switch is OFF AND scène clean is ON lamp ON LEVEL 100

something like this?
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by BarryT »

Kedi wrote: Friday 26 January 2024 19:36 I don't think that Motion Sensors can be switched On or Off.
I would go for changing the motion lua scripts by adding a check if the 'Control' device is On of Off/
How can i create a control device?
User avatar
waltervl
Posts: 5387
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by waltervl »

Make a dummy switch called 'vacuum cleaner active'.
And in your Lua script first check if the state of the switch is on. If the switch is on ignore the motion sensor status and switch your lights to 100%.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by BarryT »

waltervl wrote: Friday 26 January 2024 21:15 Make a dummy switch called 'vacuum cleaner active'.
And in your Lua script first check if the state of the switch is on. If the switch is on ignore the motion sensor status and switch your lights to 100%.
Thats exactly what i need, but how to 'ignore' the motion? 😁
User avatar
gizmocuz
Posts: 2394
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by gizmocuz »

And to make it more easier, create two Scenes

- All Lights On
- All lights Off

In those scenes place all lights, in the 'ON' scene set them to 100% white
In the Off scene, set them to off

As activator of the scene use the above dummy switch (or a real switch)

No need for scripting this

Maybe you can a wall switch that you can also double press, and use this action as activator for the scene?
Quality outlives Quantity!
Kedi
Posts: 563
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by Kedi »

I had the same kind of problem when the window cleaner comes by and wants to clean all the windows.
So I created a Dummy switch that we can activate.
If activated (On) the current state of sunscreens and roller shutters are preserved.
Roller shutters and sunscreens are opened.
The state (On) of that switch is used in all my scripts concerning the sunscreens and roller shutters to prevent them from closing.
When the window cleaner is done, the Dummy switch is deactivated and every sunscreen and roller shutter is put back in the original state.
Next step might be to trigger this Dummy switch by presence of the window cleaners phone. ;)
Logic will get you from A to B. Imagination will take you everywhere.
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by BarryT »

Thanks all, but i was hoping it was a bit easier but its not 🤔
After activating that scène, lamps full on, they goes on for 5 minutes and goes off because motion detected no motion after 5 minutes ago thats not going to work.
Even after activating the scene 'full on" and walk near the motion, it goes back to 50% because my script told it todo after motion.
So i guess my (motion) lua scripts needs to be more smart and to know that we need no motion because we want to have all lamps to be full on and stay full on..
Kedi
Posts: 563
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by Kedi »

It is very easy. Put this at the beginning of every motion script.

Code: Select all

if domoticz.devices(<Dummy Switch>).state == "On" then
	return
end 
And create a script that switches "On" all the lights you want when the Dummy Switch is triggered and has state "On", and ofcourse "Off" when the state is "Off"
Last edited by Kedi on Saturday 27 January 2024 22:02, edited 2 times in total.
Logic will get you from A to B. Imagination will take you everywhere.
HvdW
Posts: 532
Joined: Sunday 01 November 2015 22:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2023.2
Location: Twente
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by HvdW »

Kedi wrote: Saturday 27 January 2024 20:47 It is very easy.
There is no 'like' button on this website, so I 'like' your post in this way @Kedi.
Bugs bug me.
Kedi
Posts: 563
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by Kedi »

Off topic, but TNX
Logic will get you from A to B. Imagination will take you everywhere.
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by BarryT »

Kedi wrote: Saturday 27 January 2024 20:47 It is very easy. Put this at the beginning of every motion script.

Code: Select all

if domoticz.devices(<Dummy Switch>).state == "On" then
	return
end 
And create a script that switches "On" all the lights you want when the Dummy Switch is triggered and has state "On", and ofcourse "Off" when the state is "Off"
Sounds great to do, but this is not working at all..

Code: Select all

commandArray = {}

if domoticz.devices(DummyTestFull).state == "On" then print('This is an test...')
    return

elseif (devicechanged['testmotion'] == 'On') then commandArray['testdimmer'] = 'Set Level 50'
elseif (devicechanged['testmotion'] == 'Off') then commandArray['testdimmer'] = 'Off'
    
end
return commandArray
does exactly nothing.

imo, this is working, but after motion detect the lamps goes back to 50% instead of staying on @100%:

Code: Select all

commandArray = {}

if (devicechanged['DummyTestFull'] == 'On') then 
    print('PoetsTest') 
    commandArray['testdimmer'] = 'Set Level 100'
    return

--domoticz.devices(DummyTestFull).state == "On" then print('this is a test')
--return

elseif (devicechanged['testmotion'] == 'On') then commandArray['testdimmer'] = 'Set Level 50'
elseif (devicechanged['testmotion'] == 'Off') then commandArray['testdimmer'] = 'Off'
    
end
return commandArray
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by BarryT »

So in simple words:

we have 19 (mqtt) motion sensors in our house, all of them are just switching on the lamp when its dark and when there is motion.
script:

Code: Select all

commandArray = {}
if (devicechanged['MotionHal'] == 'On') then commandArray['LampHal'] = 'Set Level 50'
elseif (devicechanged['MotionHal'] == 'Off') then commandArray['LampHal'] = 'Off' 
end
return commandArray
this works perfect.
now i just want to have an override setting that turn on ALL lights to 100% and with color white and the motion detection OFF.
i believe it isnt that simple in domoticz? :(
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by BarryT »

Well, nevermind.. I did some simple tricks in lua, i think i have it.
I have to do this for every lamp, but its better than none working script :P
I think this can be much easier, but for now its working.
Now i can change the brightness as well the color of the lamps, sometimes it can be simpler then i thought.
When "testpoets" is on, no motion needed, lamp is full bright 100% white, when "testpoets" is off, normal motion mode works again.

Thanks!

Code: Select all

commandArray = {}

if (devicechanged['testpoets'] == 'On') then 
    print('lampje was switched ON to 100% - cleaning mode!')
     commandArray['OpenURL']='/json.htm?type=command&param=setcolbrightnessvalue&idx=3376&hex=fffff&brightness=300&iswhite=false' 
    end

if otherdevices['testpoets'] == 'Off' and (devicechanged['testbeweging'] == 'On') then 
    commandArray['OpenURL']='/json.htm?type=command&param=setcolbrightnessvalue&idx=3376&hex=D19126&brightness=300&iswhite=false' 
    print('lampje was switched ON to 50% - normal mode') 
    end
    
if otherdevices['testpoets'] == 'Off' and (devicechanged['testbeweging'] == 'Off') and otherdevices['testdimmer'] == 'On' then
    commandArray['testdimmer']='Off' 
    print('lampje switched OFF') 
    end

return commandArray
Last edited by BarryT on Sunday 28 January 2024 18:57, edited 2 times in total.
Kedi
Posts: 563
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by Kedi »

BarryT wrote: Sunday 28 January 2024 15:23
Kedi wrote: Saturday 27 January 2024 20:47 It is very easy. Put this at the beginning of every motion script.

Code: Select all

if domoticz.devices(<Dummy Switch>).state == "On" then
	return
end 
And create a script that switches "On" all the lights you want when the Dummy Switch is triggered and has state "On", and ofcourse "Off" when the state is "Off"
Sounds great to do, but this is not working at all..

Code: Select all

commandArray = {}

if domoticz.devices(DummyTestFull).state == "On" then print('This is an test...')
    return

elseif (devicechanged['testmotion'] == 'On') then commandArray['testdimmer'] = 'Set Level 50'
elseif (devicechanged['testmotion'] == 'Off') then commandArray['testdimmer'] = 'Off'
    
end
return commandArray
does exactly nothing.
My code presumed that your code was dzVents code.
In lua it is a little bit different. Perhaps try this. But I am not sure what device is what, but you know.

Code: Select all

commandArray = {}

if domoticz.devices("DummyTestFull").state == "Off" then
	print('This is an test...')

	if (devicechanged['testmotion'] == 'On') then
		commandArray['testdimmer'] = 'Set Level 50'
	else
		commandArray['testdimmer'] = 'Off'
    	end
end
return commandArray
Logic will get you from A to B. Imagination will take you everywhere.
BarryT
Posts: 365
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: How to, create a cleaning-knob (or scene)?!

Post by BarryT »

Kedi wrote: Sunday 28 January 2024 18:56
BarryT wrote: Sunday 28 January 2024 15:23
Kedi wrote: Saturday 27 January 2024 20:47 It is very easy. Put this at the beginning of every motion script.

Code: Select all

if domoticz.devices(<Dummy Switch>).state == "On" then
	return
end 
And create a script that switches "On" all the lights you want when the Dummy Switch is triggered and has state "On", and ofcourse "Off" when the state is "Off"
Sounds great to do, but this is not working at all..

Code: Select all

commandArray = {}

if domoticz.devices(DummyTestFull).state == "On" then print('This is an test...')
    return

elseif (devicechanged['testmotion'] == 'On') then commandArray['testdimmer'] = 'Set Level 50'
elseif (devicechanged['testmotion'] == 'Off') then commandArray['testdimmer'] = 'Off'
    
end
return commandArray
does exactly nothing.
My code presumed that your code was dzVents code.
In lua it is a little bit different. Perhaps try this. But I am not sure what device is what, but you know.

Code: Select all

commandArray = {}

if domoticz.devices("DummyTestFull").state == "Off" then
	print('This is an test...')

	if (devicechanged['testmotion'] == 'On') then
		commandArray['testdimmer'] = 'Set Level 50'
	else
		commandArray['testdimmer'] = 'Off'
    	end
end
return commandArray
Thanks man!
But i miss the full bright "knob" in this script.
The job in the script has to do 2 things:

normal mode = motion activated > lamp on to 50% dim with color: very warm white after motion detected, and lamp goes OFF after 3 minutes no motion.
cleaning mode = motion disabled > lamp has to STAY ON with 100% brightness and with color: cool white until we do clean-knob (poets) OFF and the function has to goo back to normal mode with motion detection enabled
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests