node-openzwave icon indicating copy to clipboard operation
node-openzwave copied to clipboard

Changed values for Decimals

Open abalam666 opened this issue 10 years ago • 1 comments
trafficstars

I noticed that the decimal values have a cast to Interger, then the exact value is lost here :

        case OpenZWave::ValueID::ValueType_Decimal:
        {
            float val;
            OpenZWave::Manager::Get()->GetValueAsFloat(value, &val);
            valobj->Set(String::NewSymbol("value"), Integer::New(val));
            break;
        }

I had to remove those lines, and add a new line above the String case to use the same procedure a keep the exact value (in string) :

        case OpenZWave::ValueID::ValueType_Decimal:
        case OpenZWave::ValueID::ValueType_String:
        {
            std::string val;
            OpenZWave::Manager::Get()->GetValueAsString(value, &val);
            valobj->Set(String::NewSymbol("value"), String::New(val.c_str()));
            break;
        }

I'm not an expert, then maybe there's a better way to keep the Float type too ? What do you think, folks ?

abalam666 avatar Dec 10 '14 07:12 abalam666

I had to do the same thing for my power meter.

simianhacker avatar Jan 18 '15 19:01 simianhacker