Page 1 of 1

Master Dimmer/Dummy Dimmer

Posted: Thursday 21 November 2019 10:38
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
}

Re: Master Dimmer/Dummy Dimmer  [Solved]

Posted: Thursday 21 November 2019 11:25
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
}

Re: Master Dimmer/Dummy Dimmer

Posted: Thursday 21 November 2019 12:05
by markjgabb
perfect answer exactly what i was hoping for