Custom Command Bug?

I am having an issue creating a custom command for a Homeseer dimmer.

I created a command to set a status light setStatusLed(4,1,1) which accepts integers.

However, when I try to create a command to reset the status as in setStatusLed(4,0,0), the command does not create... Well actually it creates, but everything is blank. I have tried using a built-in driver using a virtual dimmer and have the same issue.

If I make the command a string and then change it to an integer in the function, it works.

For whatever reason, Custom Commands is not accepting the number 0 as a number or integer.

Am I doing something wrong here?

I saw this same thing. I ended up setting up button commands and it worked better. I got lots of nulls trying to do the other idk why.

I was trying to create custom commands for your FC200+ fan driver. Surely someone else has had the same issue. At least I would have thought so.

Ya that's here i hit as well. Download the custom button driver and make commands for the buttons only requires on parm vs three. I'd didnt get any nulls doing it this way

Did you try to add a string parameter of 0, 4, 4 or did you try to add 3 parameters of 0 and 4 and 4? What device driver are you trying to create the custom command for?

3 number values of 4 0 and 0. It is a driver for Homeseer FC200+ fan driver.

It takes 3 integer values. If I put in 4, 1 and 1 it works. The 0 makes it fail ooks like.

I set up a virtual dimmer with builtin Homeseer dimmer. Same issue.

Well there is no built in homeseer fan driver. So, can you link to the driver you are using for that?

Worked for me using the homeseer dimmer driver. You have to us 3 string parameters.
image

Look in the device edit page:

image

See, string, string and string....not number.

It's my driver the problem is not in string it's when you try and set 3 int and one is zero

Why are you setting it to integer? Use a string instead. That's what the built in driver uses. Of course you can't set an integer to zero....it's not an integer. LOL

Odd why would it take 3 strings and not 3 integers (nums)

But 0 isn't an integer.

Ah I define them as integers.
image

How is 0 not an integer java defines it as one

int : By default, the int data type is a 32-bit signed two's complement integer, which has a minimum value of -231 and a maximum value of 231-1. In Java SE 8 and later, you can use the int data type to represent an unsigned 32-bit integer, which has a minimum value of 0 and a maximum value of 232-1.Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)

Because of a bug you have revealed. It won't accept zero as a number parameter, as you discovered. That's a bug. It will accept a string with value "0". There was a critical test in the code to see if there has been a value set or not, and that test failed when the value is zero.

Found and fixed, and will be in the next release.

1 Like

Ah ok that makes sense thank you! Glad it wasn't me. Love this support on this forum

I thought that 0 always returned false as an integer?

It does, that's why it's not a good test that just looks at the value to see if it exists.

if(value) doSomething()

vs.

if(value != null) doSomething()

1 Like

Okay. It's slow going but I'm starting to get this groovy shi....stuff. :wink: Thanks Bruce.

Is there any real advantage in this case of using string vs number? I understand if you want to do math with it then it would have to be a number value but is there any other reason to pick one over the other? (And i apologize if that's a much bigger question than I realize it is. I'm just curious.)