I'm trying to dim a RGB led strip using nothing but a button and logic machine. Basically what I need is to get 8-bit value from a button so that when I hold the button, value toggles between going up and down. Is this possible? If not, what is the best way to control dimming dali lights using a simple button (or two, one up one down), preferably without using any scripts.
Thank you very much for help, bear in mind I'm a beginner though. I tried what you posted about 3bit dimming object, got to a point where i'm supposed to set value after _ in longpresstime_xx. I can't seem to find longpresstime_xx anywhere in the javascript that I pasted in custom javascript. Could you help me please?
EDIT: Nevermind, I figured it out but now I'm having problems with linking the dim UP and DOWN buttons to a real physical buttons I have set up and to the RGB led strip.
10.04.2018, 10:50 (This post was last modified: 10.04.2018, 10:50 by Erwin van der Zwart.)
Hi,
You could try something like this:
Code:
addressbyteoutput = '32/1/1'
stepsize = 10
value = event.getvalue()
current = grp.getvalue(addressbyteoutput)
if value < 8 then
if current <= stepsize then
output = 0
if current ~= output then
grp.write(addressbyteoutput, output)
end
else
output = current - stepsize
if current ~= output then
grp.write(addressbyteoutput, output)
end
end
elseif value > 8 then
if current >= (100 - stepsize) then
output = 100
if current ~= output then
grp.write(addressbyteoutput, output)
end
else
output = current + stepsize
if current ~= output then
grp.write(addressbyteoutput, output)
end
end
end
10.04.2018, 11:05 (This post was last modified: 10.04.2018, 11:18 by Jayce.)
Hello,
Excuse me again, how do I try that? Where should I put the script and what should the addressbyteoutput address be? As I said I'm a beginner, if you have time, could you please walk me through this?
Right now I'm in a state where I have done all from the link you sent me, I have two buttons in my visualization, one UP and one DOWN, both have longpresstime set to 10 (1 second). Also, I have 1/1/199, which is my LED strip that I scanned from dali section in LM, I can control the strip with 1 byte unsigned integer.
10.04.2018, 18:17 (This post was last modified: 10.04.2018, 18:25 by Erwin van der Zwart.)
Hi,
Just create a 4 bit object that is connected to your physical KNX pushbutton (dimming object), add the script as event based to this object, create a byte SCALE object for your RGB DALI unit and set this object (1/1/199) as addressbyteoutput.
Then it should work..
But do i understand it correct from your last post that you use LM dali interface? If that is the case you should be able to use the commands from http://openrb.com/docs/dali.htm and then you should not be needing this script..
13.04.2018, 09:40 (This post was last modified: 13.04.2018, 09:56 by Jayce.)
Sorry to bother again but would you mind walking me through the method with dali commands you said? Also, what I mean by dimming the RGB strip with pushbutton is that when I hold the button the value goes gradually up. Not sure if I mention this either.
Is it possible to make a single switch:
1 short push , toggle on / off (remember last state if dimmed)
1 long push, dim up and for next long push, dim down and so on?
It doesn't have to be 4bit for me, is there any way to make it work so a pushbutton controls dimming of a dali light when using LMs dali gateway? All I'd like it to do is to dim up/down while I hold the button.
Hi
You can do it as fallow.
Create 4 bit dim object 3.007 and let all parameters as default.
Create event based script on this object and use this script.
res, err = dalicmd(gatewayID, 'queryactual', { addrtype = 'short', address = ballastAddress })
-- read ok
if res then
status = res:byte()
end
while( valuein==11 ) do
status = status + step
if (status >254) then
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress, value = 254})
else
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress, value = status})
end
valuein = grp.getvalue(event.dst)
os.sleep(stepTime)
end
while( valuein==3 ) do
status = status - step
if (status <0) then
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress, value = 0})
else
dalicmd(gatewayID, 'arc', { addrtype = 'short', address = ballastAddress, value = status})
end
valuein = grp.getvalue(event.dst)
os.sleep(stepTime)
end
Modify parameters
Add this object on to visu and test.
Should work :
Dalli arc is logarithmic curve so you will have slower dim on low values and fast on bigger.
addressbyteoutput = '32/1/1'
stepsize = 10
value = event.getvalue()
current = grp.getvalue(addressbyteoutput)
if value < 8 then
if current <= stepsize then
output = 0
if current ~= output then
grp.write(addressbyteoutput, output)
end
else
output = current - stepsize
if current ~= output then
grp.write(addressbyteoutput, output)
end
end
elseif value > 8 then
if current >= (100 - stepsize) then
output = 100
if current ~= output then
grp.write(addressbyteoutput, output)
end
else
output = current + stepsize
if current ~= output then
grp.write(addressbyteoutput, output)
end
end
end
BR,
Erwin
Hello. I'm trying this event script with a 4 bit object from KNX, but it only dimms with many "long-pressed" actions, and not mantaining the KNX button switch. Is it the problem on the KNX side or script's?
09.11.2021, 09:36 (This post was last modified: 09.11.2021, 10:15 by alexll.)
(09.11.2021, 09:09)admin Wrote: Why do you need a script if this switch supports "dimming steps" mode?
Is that the solution? I've never used that option. I'm going to try that. Thank you!
Edit: Confirmed. It works using "dimming steps" option + your 4 bit object dimming script. It has to be done like that because I needed to dim some Philips Hue LED strips from a KNX single button.