jperkin / node-openzwave

node.js interface to libopenzwave
Other
110 stars 55 forks source link

Changed values for Decimals #41

Open abalam666 opened 9 years ago

abalam666 commented 9 years ago

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 ?

simianhacker commented 9 years ago

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