This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

Button for short and long press operations
#1
Hello everyone,

Maybe there is a way or someone has a code for shutter/blinds control: I want to achieve that let's say if I press a button for a short time my blinds or shutters would start to move and if I press again they would stop and then if I press it again they would start moving again but this time in other direction. I know how to achieve this on individual objects seperately but maybe someone knows or has a universal way of doing this, so you could use one code for all buttons and etc...

Thank You.
Reply
#2
Hi,

What kinkd of devices are you using?
If using KNX,
Why don't you use available function for that? a 1 button blind/shutter will do the trick.

a script is possible but may depend a bit on the button.
Reply
#3
(11.07.2018, 17:21)mlaudren Wrote: Hi,

What kinkd of devices are you using?
If using KNX,
Why don't you use available function for that? a 1 button blind/shutter will do the trick.

a script is possible but may depend a bit on the button.

KNX, but my shutters/blinds at current time controls like this: if I press shortly they move a very short distance if I hold button down they start to move till end and stops only if button is pressed again and there are 2 buttons one for up/right direction other for down/left direction. I can't control them like I mentioned above and I need to create a script for that, plus I need it for my Iridium Studio project - for graphical buttons.
Reply
#4
(12.07.2018, 06:13)MantasJ Wrote:
(11.07.2018, 17:21)mlaudren Wrote: Hi,

What kinkd of devices are you using?
If using KNX,
Why don't you use available function for that? a 1 button blind/shutter will do the trick.

a script is possible but may depend a bit on the button.

KNX, but my shutters/blinds at current time controls like this: if I press shortly they move a very short distance if I hold button down they start to move till end and stops only if button is pressed again and there are 2 buttons one for up/right direction other for down/left direction. I can't control them like I mentioned above and I need to create a script for that, plus I need it for my Iridium Studio project - for graphical buttons.
Code:
LONG=grp.getvalue('1/1/3')
SHORT=grp.getvalue('1/1/4')
MOVINGFB=grp.getvalue('1/1/5')
value1=0
value2=1


if (LONG == true) then
 if(MOVINGFB == true) then
value=1
grp.write('1/1/4', value)
end
end


if(LONG == true) then
 if(MOVINGFB == false) then
   value=0
grp.write('1/1/3', value)
end
end
   
if(LONG == false)then
 if(MOVINGFB == true) then
     value=0
grp.write('1/1/4', value)
end
end
     
if(LONG == false) then
 if (MOVINGFB == false) then
       value=1
grp.write('1/1/3', value)
end
end
       

This is the code I have now. It works really well but since it is a prototype and not operating in real blinds I feel like whenever my "MovingFB" object, which is set in ETS5 actuator parameters changes its state from 0 to 1 or from 1 to 0 it will keep going in the cycle forever, how can I fix this?
Reply
#5
(16.07.2018, 07:49)MantasJ Wrote:
(12.07.2018, 06:13)MantasJ Wrote:
(11.07.2018, 17:21)mlaudren Wrote: Hi,

What kinkd of devices are you using?
If using KNX,
Why don't you use available function for that? a 1 button blind/shutter will do the trick.

a script is possible but may depend a bit on the button.

KNX, but my shutters/blinds at current time controls like this: if I press shortly they move a very short distance if I hold button down they start to move till end and stops only if button is pressed again and there are 2 buttons one for up/right direction other for down/left direction. I can't control them like I mentioned above and I need to create a script for that, plus I need it for my Iridium Studio project - for graphical buttons.
Code:
LONG=grp.getvalue('1/1/3')
SHORT=grp.getvalue('1/1/4')
MOVINGFB=grp.getvalue('1/1/5')
value1=0
value2=1


if (LONG == true) then
 if(MOVINGFB == true) then
value=1
grp.write('1/1/4', value)
end
end


if(LONG == true) then
 if(MOVINGFB == false) then
   value=0
grp.write('1/1/3', value)
end
end
   
if(LONG == false)then
 if(MOVINGFB == true) then
     value=0
grp.write('1/1/4', value)
end
end
     
if(LONG == false) then
 if (MOVINGFB == false) then
       value=1
grp.write('1/1/3', value)
end
end
       

This is the code I have now. It works really well but since it is a prototype and not operating in real blinds I feel like whenever my "MovingFB" object, which is set in ETS5 actuator parameters changes its state from 0 to 1 or from 1 to 0 it will keep going in the cycle forever, how can I fix this?

how do you trigger the script?
Reply
#6
(16.07.2018, 11:41)Daniel. Wrote:
(16.07.2018, 07:49)MantasJ Wrote:
(12.07.2018, 06:13)MantasJ Wrote:
(11.07.2018, 17:21)mlaudren Wrote: Hi,

What kinkd of devices are you using?
If using KNX,
Why don't you use available function for that? a 1 button blind/shutter will do the trick.

a script is possible but may depend a bit on the button.

KNX, but my shutters/blinds at current time controls like this: if I press shortly they move a very short distance if I hold button down they start to move till end and stops only if button is pressed again and there are 2 buttons one for up/right direction other for down/left direction. I can't control them like I mentioned above and I need to create a script for that, plus I need it for my Iridium Studio project - for graphical buttons.
Code:
LONG=grp.getvalue('1/1/3')
SHORT=grp.getvalue('1/1/4')
MOVINGFB=grp.getvalue('1/1/5')
value1=0
value2=1


if (LONG == true) then
 if(MOVINGFB == true) then
value=1
grp.write('1/1/4', value)
end
end


if(LONG == true) then
 if(MOVINGFB == false) then
   value=0
grp.write('1/1/3', value)
end
end
   
if(LONG == false)then
 if(MOVINGFB == true) then
     value=0
grp.write('1/1/4', value)
end
end
     
if(LONG == false) then
 if (MOVINGFB == false) then
       value=1
grp.write('1/1/3', value)
end
end
       

This is the code I have now. It works really well but since it is a prototype and not operating in real blinds I feel like whenever my "MovingFB" object, which is set in ETS5 actuator parameters changes its state from 0 to 1 or from 1 to 0 it will keep going in the cycle forever, how can I fix this?

how do you trigger the script?
It is an event based script grouped to a group adress which is assigned to my Iridium project button (On press). So when I press the button on visualization it will trigger the script inside.
Reply
#7
Then there is nothing which will keep this script in a cycle. It runs each time you press your button. Each time trigger group gets a telegram then it will run script.
Reply
#8
Well you see, imagine a situation like this: blinds are at moving position (LONG) 1 and moving fb is 1 so it means they are moving, so it will trigger the first part ( the first if) of the script and then in the script it sends 1 at 1/1/4 adress which will stop the blinds. Now movingfb is at 0 and long still at 1. Now it will trigger the second if where long == true and movingfb == false and so on and it will keep going forever. Or am I missing something?
Reply
#9
(16.07.2018, 13:39)MantasJ Wrote: Well you see, imagine a situation like this: blinds are at moving position (LONG) 1 and moving fb is 1 so it means they are moving, so it will trigger the first part ( the first if) of the script and then in the script it sends 1 at 1/1/4 adress which will stop the blinds. Now movingfb is at 0 and long still at 1. Now it will trigger the second if where long == true and movingfb == false and so on and it will keep going forever. Or am I missing something?

What is the trigger address ?
Reply
#10
All adresses: 1. long - adress for long bling operation (moves all way down or up if not stopped) 2. short - moves a tiny ammount if triggered also I use it to stop long time operation 3. movingfb - gives 1 when blinds move and 0 when stopped 4. trigger adress - empty adresses (nothing to do with ETS parameters) for each individual blinds/shutters and etc which is only assigned in iridium project and triggered via buttons in visualization. Trigger adresses also are inserted in event based scripts which triggers the script above.
Reply
#11
What do you mean by all? you have 1 script which is event and it is triggered by a group? Which one?
Of course you could use tag and attach it to all groups but you didn't mention that. As from theory: You can not write in a script to group which triggers the same script because you will then create infinite loop. If this is what you are doing then this is your mistake.
Reply
#12
If I understand well you should use such script which should be triggered event-based by this fourth GA:
Code:
shortGA = '1/1/1'
longGA = '1/1/2'
movingStatusGA = '1/1/3'

movingStatus = grp.getvalue(movingStatusGA)

if movingStatus then
  grp.write(shortGA)
else
  long = grp.getvalue(longGA)
  grp.write(longGA, not long)
end

If you have more such blinds then you can prepare universal and short version for all based on tags and structured GA names.

E.g. tag "blind-trigger" and the code could be:
Code:
alias = grp.alias(event.dst)
zone, mode = alias:match('(.*)_(.*)')

shortGA = zone .. '_short'
longGA = zone .. '_long'
movingStatusGA = zone .. '_movingStatus'

movingStatus = grp.getvalue(movingStatusGA)

if movingStatus then
 grp.write(shortGA)
else
 long = grp.getvalue(longGA)
 grp.write(longGA, not long)
end

Your objects should have then names:
Zone 1_short
Zone 1_long
Zone 1_movingStatus
Zone 1_trigger

Zone 2_short
Zone 2_long
etc...
Done is better than perfect
Reply
#13
(16.07.2018, 14:17)buuuudzik Wrote: If I understand well you should use such script which should be triggered event-based by this fourth GA:
Code:
shortGA = '1/1/1'
longGA = '1/1/2'
movingStatusGA = '1/1/3'

movingStatus = grp.getvalue(movingStatusGA)

if movingStatus then
 grp.write(shortGA)
else
 long = grp.getvalue(longGA)
 grp.write(longGA, not long)
end

If you have more such blinds then you can prepare universal and short version for all based on tags and structured GA names.

E.g. tag "blind-trigger" and the code could be:
Code:
alias = grp.alias(event.dst)
zone, mode = alias:match('(.*)_(.*)')

shortGA = zone .. '_short'
longGA = zone .. '_long'
movingStatusGA = zone .. '_movingStatus'

movingStatus = grp.getvalue(movingStatusGA)

if movingStatus then
 grp.write(shortGA)
else
 long = grp.getvalue(longGA)
 grp.write(longGA, not long)
end

Your objects should have then names:
Zone 1_short
Zone 1_long
Zone 1_movingStatus
Zone 1_trigger

Zone 2_short
Zone 2_long
etc...

Thank You buuuudzik and all guys who tryed to help me. If think the script above will work very well and it is exactly what I was looking for - a simple yet elegant solution, Thanks!  Smile
Reply
#14
Nice to hear such info. Good luck with your projectSmile
Done is better than perfect
Reply


Forum Jump: