Slider Button Feedback

84 views
Skip to first unread message

Alexander S Argollo

unread,
May 7, 2017, 6:47:29 PM5/7/17
to CommandFusion Software
Hi Guys, 
I working in my JS parser to running with my gateway. I using Slider button to send a command to my gateway. 
A few days ago I fixed my doubts, Jarrod and Tulio helped me how to send a command using a Slider Button, and now is running very well. But I have a lot of doubts how can I do feedback function. 
I already have a feedback function working using a static button, I using CF.SetJoin and Digital joins as you can see attached. 

I have in my JS parser, always when I enter on the that I use to control my dimmer, one command to get the dimmer status, and I get the values from 0 to 254.  That represents the dimmer light intensity, 0 - 0% and 254 - 100%. 

I using and slider button with decimal value, from 0 to 254. I have in my mind that i need to get data variable and need to send it to my slider button. But I do not know how to do it!

Somebody can help me please?


BR
Alex

SetJoin.PNG

Jarrod Bell

unread,
May 7, 2017, 7:08:49 PM5/7/17
to comman...@googlegroups.com
You can use CF.setJoin for the analog join of the slider. Just make sure you first use some math to expand the range from 0-254 to 0-65535 because sliders need to be updated in the larger range.

Regards,

Jarrod Bell
CommandFusion
www.commandfusion.com

--
You received this message because you are subscribed to the Google Groups "CommandFusion Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commandfusio...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tulio

unread,
May 10, 2017, 8:07:56 AM5/10/17
to CommandFusion Software
Alex, I am answering here in the original thread, you made a comment in a "digest"


Using math in js is only possible if the variable is a number and not a string. Math expression in Wiki if for use inside systems (guidesigner), if I need to use math in js, I ask google how to :-)
Try use parseInt(xxx)
Something like this:

var aaa = parseInt(sval,10);
var bbb = (aaa/254)*100);
CF.setJoins([{join:"s1", value:bbb}]); // or CF.setJoin("s1",bbb); 

ps. js is always a problem to me, I can use it but has serious problems with ;,{( My heroes in this area are Jarrod, Barry and Clayton
ps2. try to explore feedback inside a system (in guiDesigner), it is powerful, quick and attends the most needs (In this area I can do miracles)

Túlio

Em quarta-feira, 10 de maio de 2017 08:05:54 UTC-3, Alexander S Argollo escreveu:
Hi Jarrod, I'm almost finishing my Slider button, I would like to say thanks a lot for your assistance!!!

I'm working on the Serial Join to present the Dimmer Level percentage. I got successes to using CF.SetJoin to do It, but I did not succeed to print out format as decimal in module. I read math expression in the Wiki.

My Dimmer Level is being presented as DD.ddd, for example : 30.123 and i would like to present the dimmer level value in module as 30 . I've already tried to use  "%", "::" and "f" in a several combinations and positions but I did not succeed. Would you can help me, please?

Part of My code is: CF.setJoins([{join:"s1", value:((sval/254)*100)}]);


Barry Gordon

unread,
May 10, 2017, 10:32:40 AM5/10/17
to comman...@googlegroups.com
An interesting trick I use in js to convert a known numeric string (digits and an optional period only) to a numeric value is to make use of the fact that js will auto convert as necessary. If a variable a contains a numeric string then the expression b=a-0 will convert a to a number so it can subtract the zero from it. You can not do this with b=a+0 as the plus operator in this context is taken as string concatenation and the zero is converted to a string and then appended to the contents of a to form b.



Sent from my iPad

Barry Gordon

unread,
May 10, 2017, 12:18:15 PM5/10/17
to comman...@googlegroups.com

To further elaborate by example let's start with Tulio's snippett (I am assuming sval is a string but is numeric in content):

 

var aaa = parseInt(sval,10);

var bbb = (aaa/254)*100);

CF.setJoins([{join:"s1", value:bbb}]); // or CF.setJoin("s1",bbb); 

 

Change 1:

var aaa = sval-0;

var bbb = (aaa/254)*100);

CF.setJoins([{join:"s1", value:bbb}]); // or CF.setJoin("s1",bbb); 

 

Change 2:

var bbb = ((sval-0)/254)*100;

CF.setJoins([{join:"s1", value:bbb}]); // or CF.setJoin("s1",bbb); 

 

Change 3:

CF.setJoins([{join:"s1", value:((sval-0)/254)*100}]);     //    or CF.setJoin("s1",((sval-0)/254)*100); 

 

Hopefully I did not screw up the typing

 

In fact since sval/254 should be properly evaluated  by js first converting sval to a number then:

 

Change 4:

CF.setJoins([{join:"s1", value:(sval/254)*100}]);     //    or CF.setJoin("s1",(sval/254)*100); 

 

if sval is not a true numeric then the result of the internal javascript conversion (sval/254) will produce the value NaN

Alexander S Argollo

unread,
May 10, 2017, 9:45:21 PM5/10/17
to CommandFusion Software

Tulio and Barry, thanks a lot for your assistance, high now my JS script is more robust. I made several functional tests and running very well!!!
I just have a last doubt: how to I submit to the my slider screen output (s1) the decimal integer values.

I tried to use dsval:0, dsval::%0f and is not working. Please would you can advise help me?

Jarrod Bell

unread,
May 10, 2017, 10:32:58 PM5/10/17
to comman...@googlegroups.com
Those methods of removing decimals only work in places where our math expressions are used, not within JavaScript.

Instead, you can use Math.round to round your numbers in JS.

CF.setJoins([{join: "a22", value: dsval * 258.011811}, {join: "s1", value: Math.round(fsval)}]);

There is Math.floor or Math.ceil as well if you want to always round up or down.


Regards,

Jarrod Bell
CommandFusion
www.commandfusion.com

Alexander S Argollo

unread,
May 11, 2017, 5:16:36 AM5/11/17
to CommandFusion Software
Hi Jarrod, thanks a lot. Right now my scripting is working well!!!

I would like to say thanks a lot Tulio and Barry also!

Best Regards
Alex

Barry Gordon

unread,
May 11, 2017, 1:11:59 PM5/11/17
to comman...@googlegroups.com

If you are serious about Home Automation the best advice I can give you is to learn Javascript. I do all my work for my home automation  systems in Javascript.  I use a Raspberry Pi coded in Javascript as the central controller, in wall iPads in every room coded in Command Fusion / Javascript; and Amazon Alexa for full voice control of everything in the house.  Because I write everything in Javascript I get a lot of reusability from code segments .

 

I addition there is lots of free code, information, and help if you are using Javascript.

 

Good luck, glad to be helpful

 

Barry

Alexander S Argollo

unread,
May 12, 2017, 4:17:13 AM5/12/17
to comman...@googlegroups.com
Thanks a lot Barry.

Best Regards
Alex


To unsubscribe from this group and stop receiving emails from it, send an email to commandfusion+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "CommandFusion Software" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/commandfusion/mLIcEeUptMg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to commandfusion+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
atenciosamente,
Alexander S Argollo
11-99468494
mailto: alexande...@gmail.com
Reply all
Reply to author
Forward
0 new messages