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

Config value retrieval too naive #54

Open
erodewald opened this issue Mar 15, 2019 · 0 comments
Open

Config value retrieval too naive #54

erodewald opened this issue Mar 15, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request reviewed

Comments

@erodewald
Copy link
Member

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
  • 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 into Light Bulb 1

IMHO, the responsibility of the function should be to:

  1. Return a singular string value, or to return an array of strings
  2. Not assume the user wants to do anything in particular with those strings
  3. 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 sent false)

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

@erodewald erodewald added the enhancement New feature or request label Mar 15, 2019
@john-u john-u added the reviewed label Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request reviewed
Projects
None yet
Development

No branches or pull requests

3 participants