Custom Profile with Custom Capabilities (Cloud to Cloud Integration)

Hello,
I’m writing this post because i’m struggling with the Developer Workspace and the Smartthings CLI to develop a device profile that suits my needs.

At the moment my profile has this structure, using only smartthings production capabilities:
main:

  • refresh()
  • healtCheck()
  • energyMeter()
  • powerMeter()

component_A:

  • powerMeter()

component_B:

  • energyMeter()

component_C:

  • energyMeter()

The integration is working fine, but i have 2 problems:

  1. I have no control over the texts displayed in the smartthings app , excpet for changing the translation for components component_A, component_B, component_C. I could not change the translation for main.
  2. I’m not able to change the translation of the labels inside the energyMeter and powerMeter capabilities because they are smartthings production capabilities.

I tried to develop a new device profile using only custom capabilites so that i can change the labesl or eventually the translation , but i had several problems ending in nothing showing upp on the ST app. This because I think it’s not easy and straight forward to oerfor all the necessary steps.


I’m here to ask, if possible, to guide me through the process. I write down the schema I want to develop and would like to know which are the steps needed to make it work.

I need to use 2 custom capabiltiies: customEnergyMeter and customPowerMeter , which i need to have exactly the same properties and presentation of the smartthing production st.energyMeter and st.powerMeter.
These two capabilites should have custom labels or at least their labels should be editable through the translation file.

The device profile should have the following structure:
main:

  • refresh()
  • healthCheck()

component_A:

  • customEnergyMeter
  • customPowerMeter

component_B:

  • customPowerMeter

component_C:

  • customEnergyMeter

component_D:

  • customEnergyMeter

I know i’m asking much but i think that many developer as me could face this problem, so having a reference guide could be very helpful.

Thank you in advance

If you’d like to certify the connector, you cannot use custom capabilities as they’re not accepted for this process. Here’s a note about this: Required Capabilities | Developer Documentation | SmartThings
Also, do you want to change the translation for different languages or do you want to set a static label for them? Because you can do the last, however that doesn’t affect the history tab as it gets the values directly from the translation.

When working with custom capabilities you need to make sure you have the following:

  1. The definition of the custom capability. This is where you define the attributes and/or commands the capability will be able to use
  2. The presentation of the custom capability. This specifies how the capability will display in the app
  3. The device presentation in the profile’s metadata. This is where we specify all the capabilities that will show up on each view (Dashboard, Detail and Automation)

ok, the en translation is generated by default so you can work with that first.

If you are using the default translations in your presentation for the labels, then you have to update the translations to set the static labels. For example:

Presentation definition

{
    "dashboard": {
        "states": [
            {
                "label": "{{lockedCodeName.value}}"
            }
        ],
        "actions": []
    },
    "detailView": [
        {
            "label": "{{i18n.label}}",
            "displayType": "state",
            "state": {
                "label": "{{lockedCodeName.value}}"
            }
        }
    ],
    "automation": {
        "conditions": [
            {
                "label": "{{i18n.attributes.lockedCodeName.label}}",
                "displayType": "textField",
                "textField": {
                    "value": "lockedCodeName.value",
                    "valueType": "string"
                }
            }
        ],
        "actions": []
    },
    "id": "heartsample19211.lockedCodeName",
}

Setting the static label for the capability

POST https://api.smartthings.com/v1/capabilities/heartsample19211.lockedCodeName/1/i18n/en
{
    "tag": "en",
    "label": "Code name used to lock",
    "attributes": {},
    "commands": {}
}


You can also use the CLI to create/update the translations as well:
EXAMPLES
  $ smartthings deviceprofiles:translations:upsert 3acbf2fc-6be2-4be0-aeb5-44759cbd66c2 -i en.yaml

  tag: en

  components:

    main:

      label: Main Power

      description: Controls power to all outlets

    outlet1:

      label: Outlet One

      description: Switchable outlet 1 power

    outlet2:

      label: Outlet two

      description: Switchable outlet 1 power



  $ smartthings deviceprofiles:translations:upsert -i en.yaml

  ┌────┬─────────────────────┬─────────────┬──────────────────────────────────────┐

  │ #  │ Name                │ Status      │ Id                                   │

  ├────┼─────────────────────┼─────────────┼──────────────────────────────────────┤

  │  1 │ Test Switch         │ DEVELOPMENT │ 58e73d0c-b5a5-4814-b344-c10f4ff357bb │

  │  2 │ Two Channel Outlet  │ DEVELOPMENT │ 3acbf2fc-6be2-4be0-aeb5-44759cbd66c2 │

  └────┴─────────────────────┴─────────────┴──────────────────────────────────────┘

  ? Enter id or index 2

  tag: en

  components:

    main:

      label: Main Power

      description: Controls power to all outlets

    outlet1:

      label: Outlet One

      description: Switchable outlet 1 power

    outlet2:

      label: Outlet two

      description: Switchable outlet 1 power

@h0ckeysk8er Thank you for the explanation, is it possible to do the same to translate labels inside a SmartThings production capability?

@nayelyz Thank you too for the support.
Since I need to certify the connector I don’t need to use any custom capability, so when you say: " Also, do you want to change the translation for different languages or do you want to set a static label for them? Because you can do the last, however that doesn’t affect the history tab as it gets the values directly from the translation." are you referring to smartThings production capabilities? Because I need to translate them.

Yes, you can modify their label that is gotten automatically depending on the device’s language to use a static one.
This means that whatever language the user has configured on his mobile device, the label won’t change.
That can be done through the Device-Config, here’s an example of doing this in the detail view.

"detailView": [
        {
            "component": "main",
            "capability": "temperatureMeasurement",
            "version": 1,
            "values": [
                {
                    "key": "temperature.value",
                    "label":"Internal Thermostat"
                }
            ],
            "patch": []
        },
        {
            "component": "main",
            "capability": "switch",
            "version": 1,
            "values": [
                {
                    "key": "switch.value",
                    "label":"Main Power"
                }
            ],
            "patch": []
        },
        {
            "component": "main",
            "capability": "powerMeter",
            "version": 1,
            "values": [
                {
                    "key": "power.value",
                    "label":"Used Power"
                }
            ],
            "patch": []
        }
    ]

The reference is attributeName.value, in the case of automation.actions we also use the property values but in key we must use the command name, for example, setAirConditionerMode or if the capability uses enumCommands:

"actions": [
      {
          "component": "main",
          "capability": "switch",
          "version": 1,
          "values": [
              {
                  "key": "{{enumCommands}}",
                  "alternatives": [
                    {
                      "key": "on",
                      "value": "Set to Favorite",
                      "type": "active"
                    },
                    {
                      "key": "off",
                      "value": "[Does Nothing]",
                      "type": "inactive"
                    }
                  ]
              }
          ],
          "patch": [],
          "exclusion": []
      },
      ...
  ]
2 Likes

Thank you for the explanation @nayelyz .

I modified the config file like this and obtained the expected result:

image

This is the result i get when the mobile device language is set to it.

If I set the language to en, i don’t get these custom values but i get “Energy Meter” and “Power Meter” . So i don’t know if the labels are really “fixed” for every language

Hi, @emanuele.d1994
We asked for access to your account here:

We need this to be able to see all your configurations and try to replicate the same behavior. Is it the same device called “Ned”?

The device i’m using for development is Ned Test v3 so you can check on that, and Ned is instead the production device i will then request to certify.

Hi, @emanuele.d1994
Sorry for the delay. I saw you were going to work on the profile’s translation.
It could help you refresh the presentation if you create a new profile, maybe something is being cached in the profile or the app.
If you create the profile through the Developer Workspace it doesn’t always update the presentation correctly.
Also, if you’re editing the configuration without deleting and adding your device again, it could happen the app is not refreshed completely
I would suggest you change the external ID assigned to force the refresh of the configuration in the app every time you make a change in the configuration.

In my tests, I used your presentation ID directly, then changed to different languages and the labels never changed:

If this is an issue you can constantly replicate, it would be helpful for us to:

  1. Get a screen recording of you showing how in one language they display correctly and it goes back to the defaults when you change it to English.
  2. Then, get the app logs
  3. Go to Menu > Gear Icon > About SmartThings
  4. Tap the SmartThings logo 10 times.
  5. This will open the developer’s space > tap ‘report a problem’
  6. This will send you to the report page. Select a frequency and write a short description of the issue.
  7. Click on “Report” and a log file will be generated for you to send over email, please do this to build@smartthings.com
  8. Finally, share your timezone to have a better reference of the time shown in the recording