Page 1 of 1
dimming a group
Posted: Wednesday 27 November 2019 16:52
by snellejellep
Hi all,
i tried making a script which allows a dimmer switch control and dim a group.
simple on/off worked but i tried reading this script and use some things to let the group dim:
https://www.domoticz.com/forum/viewtopi ... 28&t=23568
but unfortunately i get this error and i have no clue:
Code: Select all
2019-11-27 16:51:02.266 Error: dzVents: Error: (2.5.0) An error occurred when calling event handler knop group tk
2019-11-27 16:51:02.266 Error: dzVents: Error: (2.5.0) ...ticz/scripts/dzVents/generated_scripts/knop group tk.lua:14: attempt to index a nil value (field 'data')
this is the script:
Code: Select all
return {
on = {
devices = {
'Tuinkamer licht'
}
},
execute = function(dz, device)
dz.log('Device ' .. device.name .. ' was changed', dz.LOG_INFO)
local switch = dz.devices("Tuinkamer licht")
local group = dz.groups("Tuinkamer licht")
if switch.state == "On" and switch.level > 0 then
dz.data.dimLevel = switch.level
group.switchOn()
group.dimTo(tonumber(dz.data.dimLevel))
elseif switch.state == "Off" then
group.switchOff()
end
end
}
i hope someone can help me
Re: dimming a group
Posted: Wednesday 27 November 2019 17:10
by zicht
As far as i know a group cannot be dimmed, lamps can be dimmed.
What you can do is read one switch (define that as somekind of a group master in your thoughts)
Then with a script like above change the dimming value based on that master switch value for every individual lamp

Maybe that way it will work.
Not sure how it works in dzevents
in lua it would be something like
a=otherdevices["lamp1"]
commandArray["lamp2"]=a
commandArray["lamp3"]=a
commandArray["lamp4"]=a
this way the value of lamp1 will be copied to the others

Re: dimming a group
Posted: Wednesday 27 November 2019 17:33
by snellejellep
zicht wrote: Wednesday 27 November 2019 17:10
As far as i know a group cannot be dimmed, lamps can be dimmed.
What you can do is read one switch (define that as somekind of a group master in your thoughts)
you can with a script, i tried before and it seems to work.
unfortunately i do not know lua, all my scripts are in dzvents
Re: dimming a group
Posted: Wednesday 27 November 2019 18:00
by zicht
"you can with a script, i tried before and it seems to work."
Maybe you can use same approach in DZ ? dimm all lamps upon value change ?
Re: dimming a group
Posted: Wednesday 27 November 2019 18:03
by snellejellep
zicht wrote: Wednesday 27 November 2019 18:00
"you can with a script, i tried before and it seems to work."
Maybe you can use same approach in DZ ? dimm all lamps upon value change ?
yes but i need to extract the current value of the switch and use that value to dim the group to that value
the only thing is i do not know how to do that... setting a static dimmed value i do know but this i don't ant that is exactly my question, how do i do that in dzvents
Re: dimming a group
Posted: Wednesday 27 November 2019 18:50
by waaren
snellejellep wrote: Wednesday 27 November 2019 18:03
yes but i need to extract the current value of the switch and use that value to dim the group to that value
the only thing is i do not know how to do that... setting a static dimmed value i do know but this i don't ant that is exactly my question, how do i do that in dzvents
Something like this ?
Code: Select all
return
{
on =
{
devices =
{
'Tuinkamer licht' -- device Trigger
},
},
logging =
{
level = domoticz.LOG_DEBUG
},
execute = function(dz, item)
_G.logMarker = _G.moduleLabel
local myGroup = dz.groups('Tuinkamer licht') -- Confusing ! Can you rename device or group ?
if item.state ~= 'Off' and item.level > 0 then
myGroup.devices().forEach(function(dv)
dz.log(dv.name ..' ==>> device-level: ' .. dv.level,dz.LOG_FORCE)
dv.dimTo(item.level)
end)
elseif item.state == 'Off' then
dz.log(item.name ..'; state: ' .. item.state,dz.LOG_FORCE)
myGroup.switchOff()
end
end
}
Re: dimming a group [Solved]
Posted: Wednesday 27 November 2019 19:32
by snellejellep
waaren wrote: Wednesday 27 November 2019 18:50
Something like this ?
great! that is exactly what i was looking for!
Re: dimming a group
Posted: Friday 15 May 2020 8:41
by dheuts
Thanks a lot for this script, great.
I'm looking for some script like this, to control the color temperature (Kelvin) of a group (RGBWW).
Can someone please help me with this? I think we have to do something in the script with:
getColor
SetKelvin
But I'm not sure how to get this running. Is it possible with the same device as the brightness slider? Or do we need another one?
UPDATE: Got it running with this script:
viewtopic.php?f=59&t=29498&p=247523#p224734
waaren wrote: Wednesday 27 November 2019 18:50
snellejellep wrote: Wednesday 27 November 2019 18:03
yes but i need to extract the current value of the switch and use that value to dim the group to that value
the only thing is i do not know how to do that... setting a static dimmed value i do know but this i don't ant that is exactly my question, how do i do that in dzvents
Something like this ?
Code: Select all
return
{
on =
{
devices =
{
'Tuinkamer licht' -- device Trigger
},
},
logging =
{
level = domoticz.LOG_DEBUG
},
execute = function(dz, item)
_G.logMarker = _G.moduleLabel
local myGroup = dz.groups('Tuinkamer licht') -- Confusing ! Can you rename device or group ?
if item.state ~= 'Off' and item.level > 0 then
myGroup.devices().forEach(function(dv)
dz.log(dv.name ..' ==>> device-level: ' .. dv.level,dz.LOG_FORCE)
dv.dimTo(item.level)
end)
elseif item.state == 'Off' then
dz.log(item.name ..'; state: ' .. item.state,dz.LOG_FORCE)
myGroup.switchOff()
end
end
}