Open
Description
Is your feature request related to a problem? Please describe.
util/endpoint-context.js
includes several "config value" retrieval methods, which are very handy, but they only pull out the first value in the array. For arrays larger than 1, you are out of luck.
Describe the solution you'd like
I have thought of several use cases that these needs to support:
1. Raw data
- you are building a config page and you want a list of the raw values in an array
- e.g., deviceId, or modeId, etc.
2. Building strings with label/name
- you are building a config page and you want to use the device Ids as a template
- e.g., setting the description as
Light Bulb 1, Light Bulb 2, Rear door lock
- e.g., setting the description as
- this cannot be done because you have no API access token to look up the labels, so Strongman can replace values
- Strongman sees the literal string
{{deviceId:81e3bbf5-b63e-4c18-af21-51f72520fe40}}
and it will transform it intoLight Bulb 1
IMHO, the responsibility of the function should be to:
- Return a singular string value, or to return an array of strings
- Not assume the user wants to do anything in particular with those strings
- Take flexible arguments:
- you pass in a string argument, it finds that value and returns the un-templated value
- you pass in an object like
{ name: 'modes', templated: true }
, then it returns the templated value (it would also respect if you sentfalse
)
Proposed usage
context.configStringValue('modes')
// returns
// [
// '81e3bbf5-b63e-4c18-af21-51f72520fe40',
// '26c972d5-40f5-413c-82d9-46da38f01a47'
// ]
context.configStringValue({name: 'modes', templated: true})
// returns
// [
// '{{modeId:81e3bbf5-b63e-4c18-af21-51f72520fe40}}',
// '{{modeId:26c972d5-40f5-413c-82d9-46da38f01a47}}'
// ]
Describe alternatives you've considered
n/a
Additional context
n/a