Page 1 of 1

help with dimming script

Posted: Wednesday 18 December 2019 19:06
by snellejellep
hi all,

i have a zigbee switch with 6 buttons and i want to control 2 dimmers with it.
this is the situation i want:
- button 1 > turn on/off dimmer 1
- button 2 > turn on/off dimmer 2
- button 3 > subtract 10% of the dimming value of dimmer 1 and dim to that level
- button 4 > add 10% to the dimming value of dimmer 1 and dim to that level
- button 5 > subtract 10% of the dimming value of dimmer 2 and dim to that level
- button 6 > add 10% to the dimming value of dimmer 2 and dim to that level

this is how far i have come:

Code: Select all

return {
	on = {
		devices = {
			'multibutton'
		}
	},
	execute = function(dz, device)
		local button              = dz.devices("multibutton") -- has states 1, 2, 3, 4, 5, 6
		local lamp1               = dz.devices("dimmer 1") -- is a simple dimmer just on/off and 1-100%
		local lamp2               = dz.devices("dimmer 2") -- is a simple dimmer just on/off and 1-100%
		
		if button.state == "1" and lamp1.state == "Off" then
		    lamp1.switchOn()
		elseif button.state == "1" and lamp1.state == "On" then
		    lamp1.switchOff()
		elseif button.state == "2" and lamp2.state == "Off" then
		    lamp2.switchOn()
		elseif button.state == "2" and lamp2.state == "On" then
		    lamp2.switchOff()
		elseif button.state == "3" then
		    -- dim lamp 1 10% less
		elseif button.state == "4" then
		    -- dim lamp 1 10% more
		elseif button.state == "5" then
		    -- dim lamp 2 10% less
		elseif button.state == "6" then
		    -- dim lamp 2 10% more
		end
		
	end
}
i have no clue on how to do the add or subtract dimming level.
any help would be appreciated.

Re: help with dimming script  [Solved]

Posted: Wednesday 18 December 2019 19:35
by ronaldbro
Lamp1.dimTo(lamp1.level + 10)

Re: help with dimming script

Posted: Wednesday 18 December 2019 19:49
by snellejellep
ronaldbro wrote: Wednesday 18 December 2019 19:35 Lamp1.dimTo(lamp1.level + 10)
thank you, this works!

Re: help with dimming script

Posted: Wednesday 18 December 2019 20:31
by ronaldbro
You’re welcome