help with dimming script  [Solved]

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

Moderator: leecollings

Post Reply
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

help with dimming script

Post 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.
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: help with dimming script  [Solved]

Post by ronaldbro »

Lamp1.dimTo(lamp1.level + 10)
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: help with dimming script

Post by snellejellep »

ronaldbro wrote: Wednesday 18 December 2019 19:35 Lamp1.dimTo(lamp1.level + 10)
thank you, this works!
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
ronaldbro
Posts: 327
Joined: Thursday 15 November 2018 21:38
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: help with dimming script

Post by ronaldbro »

You’re welcome
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest