How to report negative values?

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
ondrej_bajer
Posts: 33
Joined: 17 May 2018 09:55

How to report negative values?

Post by ondrej_bajer » 22 Jun 2018 15:25

Hi guys,

I need to report the temperature in Celsius, that can be bellow zero, to the HC2.
I tried to define getter as word, int, signed int, but only positive values were shown in HC2. The values bellow zero were not transferred at all.
Also, I found this older thread on the similar topic, but I was not able to understand what's the solution: https://forum.z-wave.me/viewtopic.php?f ... =10#p65177

.....

UPDATE:
Ahhh, just got it. It looks like to define getter as a signed long helped:

Code: Select all

...
ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE, SENSOR_MULTILEVEL_SCALE_CELSIUS, SENSOR_MULTILEVEL_SIZE_FOUR_BYTES, SENSOR_MULTILEVEL_PRECISION_ONE_DECIMAL, getter8)
...
signed long getter8(){
    signed long getter_out;
    getter_out = atoi(CoolantTemperature); //converts char array to integer
    Serial.print("CoolantTemperature is: "); //debug
    Serial.print(getter_out);
    Serial.println;
    return getter_out;
    }

coolant.JPG
coolant.JPG (11.27 KiB) Viewed 264 times
Not sure whether it's a right way, but it works at least. If any of you knows how to do it right, correct me please.

Thanks,
Ondrej

User avatar
PoltoS
Posts: 4224
Joined: 26 Jan 2011 19:36

Re: How to report negative values?

Post by PoltoS » 24 Jun 2018 09:07

This is correct. You define FOUR_BYTES in your channel, means DWORD or long.

If you change to TWO_BYTES, singed into will be enough

Post Reply