MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / builder

Function builder

src/commands/virtualdevices/create.ts:45–102  ·  view source on GitHub ↗
(yargs: Argv)

Source from the content-addressed store, hash-verified

43const describe = 'create a virtual device from a device profile id or definition'
44
45const builder = (yargs: Argv): Argv<CommandArgs> =>
46 inputAndOutputItemBuilder(apiOrganizationCommandBuilder(yargs))
47 .option('name', { alias: 'N', describe: 'name of the device to be created', type: 'string' })
48 .option('location', { alias: 'l', describe: 'location for the virtual device', type: 'string' })
49 .option('room', { alias: 'R', describe: 'room for the virtual device', type: 'string' })
50 .option('device-profile', { alias: 'P', describe: 'the device profile id', type: 'string' })
51 .option(
52 'local',
53 {
54 alias: 'L',
55 describe: 'run device locally on a SmartThings hub; requires a hub and driver',
56 type: 'boolean',
57 default: false,
58 },
59 )
60 .option('hub', { alias: 'H', describe: 'hub on which to run locally executing device', type: 'string' })
61 .option('driver', { alias: 'D', describe: 'driver used for locally executing device', type: 'string' })
62 .option(
63 'device-profile-file',
64 { alias: 'f', describe: 'a file containing the device profile definition', type: 'string' },
65 )
66 .example([
67 [
68 '$0 virtualdevices:create',
69 'create a virtual device by answering questions',
70 ],
71 [
72 '$0 virtualdevices:create -d',
73 'generate JSON for a virtual device by answering questions but do not actually create it',
74 ],
75 [
76 '$0 virtualdevices:create -i data.yaml',
77 'create a virtual device defined by the file data.yaml',
78 ],
79 [
80 '$0 virtualdevices:create -N "My Device" -i data.yaml',
81 'create a virtual device defined by the file data.yaml but with the name "My Device"',
82 ],
83 [
84 '$0 virtualdevices:create -f profile.yaml',
85 'create a virtual device with the specified profile, prompting for all remaining values',
86 ],
87 [
88 '$0 virtualdevices:create \\\n' +
89 ' --name="My Second Device" \\\n' +
90 ' --device-profile=7633ef68-6433-47ab-89c3-deb04b8b0d61 \\\n' +
91 ' --location=95bdd473-4498-42fc-b932-974d6e5c236e \\\n' +
92 ' --room=c7266cb7-7dcc-4958-8bc4-4288f5b50e1b',
93 'create a virtual device using command line parameters for all values',
94 ],
95 ])
96 .epilog(buildEpilog({
97 command,
98 notes: 'The command can be run interactively in question & answer mode, with command line parameters,' +
99 ' or with input from a file or standard in. You can also run this command multiple times with the same' +
100 ' input file but different command line arguments to create multiple devices with different names in' +
101 ' different locations and rooms.',
102 }))

Callers

nothing calls this directly

Calls 3

buildEpilogFunction · 0.85

Tested by

no test coverage detected