Skip to content

Conversation

@bflorian
Copy link
Contributor

Changes to make it easier to work with device profiles, device configurations, and device presentation. Significant changes are:

  1. Added to create device profiles with prompt/response process much like capabilities
  2. Automatically create a device configuration (and presentations) for device profiles that do not specify a vid
  3. Added three device "view" commands to allow device profiles and device configs to be created from one aggregate data definition rather than requiring a series of separate commands.

Prompt/Response device profile creation

$ smartthings deviceprofiles:create
? Device Profile Name: Duplex Metering Outlet
? Primary capability ID:  switch
? Select an action... Add another capability to this component
? Capability ID:  powerMeter
? Select an action... Add another component
? ComponentId ID:  outlet1
? Capability ID:  switch
? Select an action... Add another component
? ComponentId ID:  outlet2
? Capability ID:  switch
? Select an action... Finish & Create
┌───────────────────┬──────────────────────────────────────┐
│ Name              │ Duplex Metering Outlet               │
│ main component    │ switch                               │
│                   │ powerMeter                           │
│ outlet1 component │ switch                               │
│ outlet2 component │ switch                               │
│ Id                │ 344f94a3-96d5-4db7-a1ce-7269e455a242 │
│ Device Type       │                                      │
│ OCF Device Type   │                                      │
│ mnmn              │ SmartThingsCommunity                 │
│ vid               │ e0be068c-589d-344c-b0be-07817fe4651a │
│ Status            │ DEVELOPMENT                          │
└───────────────────┴──────────────────────────────────────┘

Automatic device-config from above device profile creation

Default behavior is to use the first capability of the main component in the dashboard, include all capabilities in the detail view, include all capabilities with attributes in the automation conditions, and all capabilities with commands in automation actions.

$ smartthings deviceprofiles:device-config 8
Basic Information
┌──────┬──────────────────────────────────────┐
│ VID  │ e0be068c-589d-344c-b0be-07817fe4651a │
│ MNMN │ SmartThingsCommunity                 │
│ Type │ profile                              │
└──────┴──────────────────────────────────────┘

No DP info

Dashboard States
┌───────────┬────────────┬─────────┬────────┬───────────────────┐
│ Component │ Capability │ Version │ Values │ Visible Condition │
├───────────┼────────────┼─────────┼────────┼───────────────────┤
│ main      │ switch     │ 1       │ none   │ none              │
└───────────┴────────────┴─────────┴────────┴───────────────────┘

Dashboard Actions
┌───────────┬────────────┬─────────┬────────┬───────────────────┐
│ Component │ Capability │ Version │ Values │ Visible Condition │
├───────────┼────────────┼─────────┼────────┼───────────────────┤
│ main      │ switch     │ 1       │ none   │ none              │
└───────────┴────────────┴─────────┴────────┴───────────────────┘

Detail View Items
┌───────────┬────────────┬─────────┬────────┬───────────────────┐
│ Component │ Capability │ Version │ Values │ Visible Condition │
├───────────┼────────────┼─────────┼────────┼───────────────────┤
│ main      │ switch     │ 1       │ none   │ none              │
│ main      │ powerMeter │ 1       │ none   │ none              │
│ outlet1   │ switch     │ 1       │ none   │ none              │
│ outlet2   │ switch     │ 1       │ none   │ none              │
└───────────┴────────────┴─────────┴────────┴───────────────────┘

Automation Conditions
┌───────────┬────────────┬─────────┬────────┬───────────────────┐
│ Component │ Capability │ Version │ Values │ Visible Condition │
├───────────┼────────────┼─────────┼────────┼───────────────────┤
│ main      │ switch     │ 1       │ none   │ none              │
│ main      │ powerMeter │ 1       │ none   │ none              │
│ outlet1   │ switch     │ 1       │ none   │ none              │
│ outlet2   │ switch     │ 1       │ none   │ none              │
└───────────┴────────────┴─────────┴────────┴───────────────────┘

Automation Actions
┌───────────┬────────────┬─────────┬────────┬───────────────────┐
│ Component │ Capability │ Version │ Values │ Visible Condition │
├───────────┼────────────┼─────────┼────────┼───────────────────┤
│ main      │ switch     │ 1       │ none   │ none              │
│ outlet1   │ switch     │ 1       │ none   │ none              │
│ outlet2   │ switch     │ 1       │ none   │ none              │
└───────────┴────────────┴─────────┴────────┴───────────────────┘

Creating device profile and config with view property

The following example creates a switch that (intentionally) cannot be controlled by an automation since it defines no automation actions:

$ cat test-switch.yml 
name: Test Switch
components:
  - id: main
    capabilities:
      - id: switch
view:
  dashboard:
    states:
      - capability: switch
    actions:
      - capability: switch
  detailView:
    - capability: switch
  automation:
    conditions:
      - capability: switchst$ 
st$ 
st$ smartthings deviceprofiles:view:create -i test-switch.yml 
id: 58e73d0c-b5a5-4814-b344-44759cbd66c1
name: Test Switch
components:
  - label: main
    id: main
    capabilities:
      - id: switch
        version: 1
    categories: []
metadata:
  vid: ad98fb3e-9c0e-3bee-a6ea-5fae78e82bfa
  mnmn: SmartThingsCommunity
status: DEVELOPMENT
presentation:
  dashboard:
    states:
      - capability: switch
    actions:
      - capability: switch
  detailView:
    - capability: switch
  automation:
    conditions:
      - capability: switch
    actions: []

@bflorian bflorian requested review from john-u and rossiam August 25, 2020 18:31
}

// eslint-disable-next-line no-console
//console.log(`Creating presentation from ${JSON.stringify(presentationData, null, 2)}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is some test logging left here and above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

presentationData = augmentPresentationValues(presentationData)
} else {
// eslint-disable-next-line no-console
//console.log('Generating presentation')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last commented console left, otherwise looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants