Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toString causing issues, please use toString() #28

Closed
drumfreak opened this issue Mar 18, 2018 · 2 comments
Closed

toString causing issues, please use toString() #28

drumfreak opened this issue Mar 18, 2018 · 2 comments

Comments

@drumfreak
Copy link

drumfreak commented Mar 18, 2018

thisRequest.dps[options.dps.toString] = options.set;

Seems to be missing the () behind toString. This caused issues setting dps values with using this package from homebridge.

For example:

tuya.set({id: 'xxxxxxxxxxxxxxxxxxxx', 'dps': 2, set: true}).then(() => console.log('device was changed'))

Would fail because toString is not a function in prototype.

Proposed change:

thisRequest.dps[options.dps.toString()] = options.set;

or even:

if (options.dps === undefined) {
thisRequest.dps = {1: options.set};
} else {
thisRequest.dps = {};
thisRequest.dps[options.dps] = options.set;
}

tuyapi/index.js

Line 233 in 290d6e9

thisRequest.dps[options.dps.toString] = options.set;

@codetheweb
Copy link
Owner

Oops, thanks for the heads up. (I should really get around to adding test cases.) Should be fixed now.

@drumfreak
Copy link
Author

Thank you @codetheweb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants