mdottavio / ya-lifx

:bulb: - Yet Another LIFX JS client
MIT License
8 stars 1 forks source link

Invalid value error with setState #1

Open cydrobolt opened 8 years ago

cydrobolt commented 8 years ago

When performing a setState, I am getting some errors that are preventing me from setting the state of the bulb. Notably, this error occurs:

Object {error: "power does not have a valid value, brightness does not have a valid value", warnings: Object}

I am using the following code:


lifx.setState({
            'color': color_hex,
            'power': 'on',
            'brightness': '0.2'
        })
        .then(function (r) {
            console.log(r);
        })
        .fail(function(e) {
            console.log(e);
        });

color_hex is a hex string for the color to set. Is there a way to fix this error, and be able to set state without providing each argument (i.e leave brightness + power state intact)?

mdottavio commented 8 years ago

Based on the lifxAPI doc, the value of power is fine but brightness should be Double. Try sending the value a Double value: Also, currently ya-lifx set a default value on all the params but from the Documentation none of them are required (I'm working on fixing this).

lifx.setState({
            'color': color_hex,
            'brightness': 0.2
        })
        .then(function (r) {
            console.log(r);
        })
        .fail(function(e) {
            console.log(e);
        });
cydrobolt commented 8 years ago

@mdottavio thanks. No defaults would be great.

mdottavio commented 8 years ago

Hi @cydrobolt, sorry about the delay; I'm working to validate those values on the branch fixing_validations but I also want to include some unit tests to the project; so it may take some time until I can release a stable version; in the meantime you can consume the branch from NPM with:

npm install git://github.com/mdottavio/ya-lifx#fixing_validations --save

and see if this solution solve your problem.

Let me know if you find something else 👍

cydrobolt commented 8 years ago

Seems like aState.power is referenced elsewhere, throwing an error.

image

cydrobolt commented 8 years ago

@mdottavio any updates?

mdottavio commented 8 years ago

@cydrobolt I just release v2.0.0 which I think fixe the issue; If you find something else, please include as much details about the issue as you can so I can try to fix it; Thanks

cydrobolt commented 8 years ago

I'm getting the same error. Does it work on your end? @mdottavio

mdottavio commented 6 years ago

@cydrobolt are you still interested in using this lib? 😞 here is a new version. https://github.com/mdottavio/ya-lifx/tree/mdottavio_nodefetch do you mind verifying if the problem persists using this version?