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

Function chooseValue

src/lib/command/util/virtualdevices.ts:202–223  ·  view source on GitHub ↗
(
		command: APICommand,
		attribute: CapabilityAttribute,
		name: string,
)

Source from the content-addressed store, hash-verified

200}
201
202export const chooseValue = async (
203 command: APICommand,
204 attribute: CapabilityAttribute,
205 name: string,
206): Promise<string> => {
207 const values = attribute.schema.properties.value.enum
208 if (values) {
209 const config: SelectFromListConfig<CapabilityValueItem> = {
210 itemName: 'value',
211 primaryKeyName: 'value',
212 sortKeyName: 'value',
213 listTableFieldDefinitions: ['value'],
214 }
215
216 const listItems = async (): Promise<CapabilityValueItem[]> => Promise.resolve(values.map(value => {
217 return { value }
218 }))
219
220 return selectFromList(command, config, { listItems })
221 }
222 return stringInput(`Enter '${name}' attribute value:`)
223}

Callers 2

getInputFromUserFunction · 0.85

Calls 2

selectFromListFunction · 0.85
stringInputFunction · 0.85

Tested by

no test coverage detected