DzEvent script for dimmer control
Posted: Saturday 17 October 2020 13:11
Hi,
I'm trying to write (cope/paste) my first script, but unfortunately need some help.
My plan is to swith on the dimmer (lamp) with a wall switch.
Button pressed is on at level 20%
Button pressed (again) is on at level 70%
My difficulty is to read out the dimValue of the dimmer together with the switch press
Another question is how do is can add a log message per section.
the dz.log is nog working somehow for me.....
I'm trying to write (cope/paste) my first script, but unfortunately need some help.
My plan is to swith on the dimmer (lamp) with a wall switch.
Button pressed is on at level 20%
Button pressed (again) is on at level 70%
My difficulty is to read out the dimValue of the dimmer together with the switch press
Code: Select all
device.name == 'Hal-ES2' and device.dimValue >= 20Code: Select all
device.name == 'Hal-ES2' and dz.devices('Hal - Lamp').dimValue >= 20Code: Select all
return
{
on =
{
devices = {
'Hal-ES2', -- Switch Enkel/Short
'Hal-ES4', -- Switch Enkel/Short onder
'Hal-EL2-1', -- Switch Enkel/Long press
'Hal-DS1', -- Switch Dubbel/Short press
'Hal-DS3', -- Switch Dubbel/Short press
'Hal-DL1-1' -- Switch Dubbel/Long press
}
},
execute = function(dz, device)
--dz.log('Contact ' .. item.name .. ' state is ' .. item.state, dz.LOG_DEBUG)
if ((device.name == 'Hal-ES2') or
(device.name == 'Hal-DS1')) then
dz.devices('Hal - Lamp').dimTo(20)
elseif
((device.name == 'Hal-ES4') or
(device.name == 'Hal-DS3')) then
dz.devices('Hal - Lamp').switchOff()
elseif
((device.name == 'Hal-ES2' and device.dimValue >= 20) or
(device.name == 'Hal-DL1-1' and device.dimValue >= 20)) then
dz.devices('Hal - Lamp').dimTo(70)
end
end
}
the dz.log is nog working somehow for me.....