How to deal with signed and unsigned values in the Z-Wave database?

Tags: #<Tag:0x00007fc8f83d62d8> #<Tag:0x00007fc8f83d6148>

Hi,I am actually in the process of correcting the Mold Detector database entry. In the process, I noticed one thing that I don’t know exactly how to deal with:

According to the documentation, parameter 4 is 2 bytes in size and has a value range of 0 - 65535. It is therefore unsigned. However, OpenHAB apparently makes a 2 byte signed value out of the value. The value is -22336.

The same applies to parameters 9, 10, 11 and 12. The size here is only 1 byte but the value range is 0-255. But the value in OpenHAB is -1

How can I take this into account in the database?

The ZWave protocol requires values to be signed, so this is how it is implemented. I know some devices don’t follow the protocol unfortunately, and you will need to adjust the values accordingly.

1 Like

Hm, that’s not so nice. Could it work to define the field size as 2 bytes instead of just 1 (for the paramer 9 as example) ?
Or do we have to expect to create overlaps with the previous or following parameter?

No - it won’t work at all this way as the protocol needs to know the size and if that’s wrong I’m pretty sure it will cause an error when sending the command to the device.

Ok. thanks

I don’t know what you mean by this?

1 Like

Well, by that I mean that maybe the additional 8 bits to prevent the overflow could then already be written into the neighbouring parameter.

Parameter 9 ( 8 bit):          11111111 (=255, but displayed as -1)
Parameter 9 (16 bit): 00000000 11111111 (=255 and also displayed as such)
                      ^^^^^^^^ 
                      |||||||| 
            what will happen with these bits (do they perhaps overwrite bits in neighbour parameter 8 or 10)

But if that’s not possible anyway, there’s no need to think about it any further.

Each parameter is completely separate - there is no link between them, so you can’t write information from one parameter into another parameter, and the configuration or settings etc of one parametr will not influence in any way another parameter.

In the example you seem to be extending the size of the parameter - as I mentioned earlier, size must be correct.