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

tuya-cli wizard should output valid JSON for better usability and interoperability #82

Closed
SidShetye opened this issue Jul 25, 2020 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@SidShetye
Copy link

At present tuya-cli wizard outputs an object like

[
  {
    name: 'Kitchen 1',
    id: '00000000000000000000',
    key: 'aaaaaaaaaaaaaaaa'
  },
  {
    name: 'Kitchen 2',
    id: '00000000000000000000',
    key: 'aaaaaaaaaaaaaaaa'
  }
]

but it would be far more useful to have it print out valid JSON instead (e.g. homebridge wants this JSON, tedious for >5 devices) like

[
  {
    "name": "Kitchen 1",
    "id": "00000000000000000000",
    "key": "aaaaaaaaaaaaaaaa"
  },
  {
    "name": "Kitchen 2",
    "id": "00000000000000000000",
    "key": "aaaaaaaaaaaaaaaa"
  }
]

The fix is simple, at wizard.js ~ line 93

from

console.log(devices.map(device => ({name: device.name, id: device.id, key: device.local_key})));

to

let devs = devices.map(device => ({name: device.name, id: device.id, key: device.local_key}))
console.log(JSON.stringify(devs, null, 2));

or something similar

@codetheweb
Copy link
Member

Great idea, happy to accept a PR for this. 👍

@codetheweb codetheweb added enhancement New feature or request good first issue Good for newcomers labels Nov 3, 2020
@milo526
Copy link

milo526 commented Jan 8, 2021

I believe this was already fixed in a recent commit right?

2bdd195

Specifically with the new -s option.

@codetheweb
Copy link
Member

Yep, forgot to link this issue to codetheweb/tuyapi#390.

Thanks for the reminder.

Included in v1.15.0 of @tuyapi/cli.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants