The parameter size (2nd part) is always the manufacturer determined size (either 1, 2 or 4 bytes).
Even if the value is only 1 byte long (
range -128 - 127 decimal), if the parameter is determined by the manufacturer as a size 2 bytes parameter, it should be size of 2 in the expert parameters, homey’s core will convert the value to the appropriate hexadecimal value (the same goes for 2 byte size’d parameters).
Warning: below this is pretty technical! only if you want to know more about parameter values
Parameters are (officially) signed hexadecimal, homey uses decimal as that is more normal human friendly and coverts this just before sending it to the device, most of the time.
IE: value of 50 (decimal) with a parameter size 2 it will become
0x0032 (hexadecimal) (and thus not
0x32, the device will simply ignore this, or throw back an error you won’t see) as value that is being send.
Expert parameter (38) value:
Then i’ll see the next question popping up, wait -128 until 127?
Yes by default parameters are so called “signed” values making the range going from negative 128 until positive 127 (decimal) (for 1 byte parameters)
If you would like a value (positive) 128 until 255 and the parameter is only 1 byte long (Fibaro does this a lot) you’ll need to convert this manually to hexadecimal (for expert parameters only) or it will fail.
This is also the reason why you would see a lot of manufacturers use the range 0 - 127 when they have 1 byte parameters.
IE: value of 130 (decimal, parameter size 1 byte) =
makes for expert parameter (38):
38,1,0x1E and not
A small exception is made for 255 (decimal) as value 255 is always 0xFF in hexadecimal
This is only from decimal to hexadecimal, the other way around you get -1 (negative 1) as decimal value, so be careful.
/\ This changed in homey v2, 255 now also needs to be converted for 1 byte size (0xFF).
Most manufacturers that usually wants a 0 - 255 range just make the parameter size 2 (this parameter used here is a good example, one of the few Fibaro parameters that do this), but usually then also just make the range go from 0 - 32767, which is the max (positive) number range of size 2.
-128 - 127
0 - 255 => 0x00 - 0xFF
-32768 - 32767
0 - 65535 => 0x0000 - 0xFFFF
-2147483648 - 2147483647
0 - 4294967295 => 0x00000000 - 0xFFFFFFFF
Here is a good tool for converting decimal values to hexadecimal values, though the tool uses unsigned (0 - 255 for 1 byte) decimals, unlike parameters, conversion is only needed for the unsigned (0 - 255 for 1 byte) parameters anyway.