Master Dimmer/Dummy Dimmer  [Solved]

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

Moderator: leecollings

Post Reply
markjgabb
Posts: 142
Joined: Tuesday 24 January 2017 23:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Australia
Contact:

Master Dimmer/Dummy Dimmer

Post by markjgabb »

Hi all

i have my current script below which is designed to control two lights that are dimming capable, im trying to work out how i would word the logic so that if i dim the "Master "Fan Lights" Switch both of the other lights "Fan 1/Fan2" dim to match it as if working as the same light?


im sure i need to do something like, if dim state change, get dim level and then send that to the other two lights, but i cant think of how it would actually look



Code: Select all


return {
    on = { 
        devices = { 38 }
         },
    
    execute = function(dz, item)
            dz.log('fan lights switch activated')
            if item.state == 'On' then
                dz.log('fan lights master turned on')
	            dz.devices('Fan1').switchOn()
	            dz.devices('Fan2').switchOn()
	       elseif item.state == 'Off' then
	           dz.log('fan lights master turned off')
	            dz.devices('Fan1').switchOff()
	            dz.devices('Fan2').switchOff()
            end
    end
}
V 2020.2 RPI 3
RFlink 334 mhz
mysensors
broadlink
Mirabella Genio Globes
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Master Dimmer/Dummy Dimmer  [Solved]

Post by waaren »

markjgabb wrote: Thursday 21 November 2019 10:38 I am trying to work out how i would word the logic so that if i dim the "Master "Fan Lights" Switch both of the other lights "Fan 1/Fan2" dim to match it as if working as the same light?
Can you try this ?

Code: Select all

return {
    on = { 
        devices = { 38 } -- assume this is the master Fan Ligt ?
         },
    
    execute = function(dz, item)
		if item.state == 'Off' then
			dz.log('fan lights master turned off')
			dz.devices('Fan1').switchOff()
			dz.devices('Fan2').switchOff()
		else
			dz.log('fan lights master is on at dimlevel ' .. item.level)
			dz.devices('Fan1').dimTo(item.level) -- implicent switchOn
			dz.devices('Fan2').dimTo(item.level)
		end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
markjgabb
Posts: 142
Joined: Tuesday 24 January 2017 23:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Australia
Contact:

Re: Master Dimmer/Dummy Dimmer

Post by markjgabb »

perfect answer exactly what i was hoping for
V 2020.2 RPI 3
RFlink 334 mhz
mysensors
broadlink
Mirabella Genio Globes
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest