Changing labels for existing production capability

Hi! Is it possible to update/change label/s for an existing production capability? For example, I want to change ‘Voltage’ to ‘Panel Voltage’ etc… Perhaps a new device-config?

Basically I’d really rather not create a custom capability for each “type” of stock capability I’m using. Please, some of the production capabilities have magical properties, like the graph with Temperature would would be cool to continue to use - all be it with a different label.

Cheers!

Hi!

Please, take a look at this post where another Community member showed how he changed the stock capabilities label and other properties like range or alternatives:

I made the following sample to show how to change only the label:

{
    "dashboard": {
        "states": [
            {
                "component": "main",
                "capability": "temperatureMeasurement",
                "version": 1,
                "values": []
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "temperatureMeasurement",
                "version": 1
            }
        ],
        "basicPlus": []
    },
    "detailView": [
        {
            "component": "main",
            "capability": "temperatureMeasurement",
            "version": 1,
            "values": [
                {
                    "key": "temperature",
                    "label":"Internal Thermostat"
                }
            ],
            "patch": []
        },
        {
            "component": "main",
            "capability": "switch",
            "version": 1,
            "values": [
                {
                    "key": "switch",
                    "label":"Main Power"
                }
            ],
            "patch": []
        },
        {
            "component": "main",
            "capability": "powerMeter",
            "version": 1,
            "values": [
                {
                    "key": "power",
                    "label":"Used Power"
                }
            ],
            "patch": []
        }
    ],
    "automation": {
        "conditions": [
            {
                "component": "main",
                "capability": "temperatureMeasurement",
                "version": 1,
                "values": [
                    {
                        "key": "temperature",
                        "label":"Internal Thermostat"
                    }
                ],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "switch",
                "version": 1,
                "values": [
                    {
                        "key": "switch",
                        "label":"Main Power"
                    }
                ],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "powerMeter",
                "version": 1,
                "values": [
                    {
                        "key": "power",
                        "label":"Used Power"
                    }
                ],
                "patch": [],
                "exclusion": []
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "temperatureMeasurement",
                "version": 1,
                "values": [
                    {
                        "key": "temperature",
                        "label":"Internal Thermostat"
                    }
                ],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "switch",
                "version": 1,
                "values": [
                    {
                        "key": "switch",
                        "label":"Main Power"
                    }
                ],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "powerMeter",
                "version": 1,
                "values": [
                    {
                        "key": "power",
                        "label":"Used Power"
                    }
                ],
                "patch": [],
                "exclusion": []
            }
        ]
    },
    "type": "profile" //or dth
}

That sample is in JSON but you can get the device-config used to create the device presentation (in the format you prefer: -j or -y) with the following command:

smartthings presentation:device-config 640367e6-70bd-36c9-9ccf-2852208635da -y -o=deviceConfig.yaml

Note: In this case, 640367e6-70bd-36c9-9ccf-2852208635da is the presentationID created using the config I shared above.

Let me know if this info helps :smiley:

I’ll give it a try - thanks so much!

1 Like

Anytime!
Let me know if you have any questions :smiley:

Not working… trying to change the label for “lock” and “battery” production capabilities
this is my device-config

{ 
... 
    "dashboard": {
        "states": [
            {
                "component": "main",
                "capability": "lock",
                "version": 1,
                "values": []
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "lock",
                "version": 1
            }
        ],
        "basicPlus": []
    },
    "detailView": [
        {
            "component": "main",
            "capability": "lock",
            "version": 1,
            "values": [
                {
                    "key": "lock",
                    "label": "Action"
                }
            ],
            "patch": []
        },
        {
            "component": "main",
            "capability": "battery",
            "version": 1,
            "values": [
                {
                    "key": "battery",
                    "label": "Battery Status"
                }
            ],
            "patch": []
        },
        {
            "component": "main",
            "capability": "contactSensor",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "refresh",
            "version": 1,
            "values": [],
            "patch": []
        }
    ],
    "automation": {
        "conditions": [
            {
                "component": "main",
                "capability": "lock",
                "version": 1,
                "values": [
                  {
                    "key": "lock",
                    "label": "Action"
                  }
                ],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "battery",
                "version": 1,
                "values": [
                  {
                    "key": "battery",
                    "label": "Battery Status"
                  }
                ],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "contactSensor",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "lock",
                "version": 1,
                "values": [
                  {
                    "key": "lock",
                    "label": "Action"
                  }
                ],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "refresh",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            }
        ]
    }
}

I haven’t personally tested device-config with those particular capabilities. Unfortunately, creating test scenarios can be tedious. That’s why I wait for @nayelyz to do the heavy lifting. Can you share the resulting vid/presentationId?

I assume that you added the vid to your device profile (my example is yaml syntax), repackaged, reassigned, and reinstalled? I would also try deleting and recreating the device.

metadata:
  mnmn: SmartThingsCommunity
  vid: <vid>

You can do a sanity check with: smartthings presentation <vid> -j

You should also verify that the vid is in fact associated with the device: smartthings devices <#> -j

If your modifications did not ‘take’, then there may be something wrong with your JSON. If you do see your changes, then it’s likely that the capability is just plain broken. The last time I checked, I couldn’t change the label on a custom list.

Remember that we’re still in beta. I don’t see many developers going off the beaten path. You may encounter some bugs.

I made some tests and I cannot change the label of those capabilities either. I will check with the engineering team mode details about that and let you know.
What I know so far is that even if you change the label, it won’t affect the other localizations (languages) available.

Hi!
Following up on this situation. The team mentioned this should work using this syntax: key: attributeName.value, for some it works without .value but the correct one is the first way.
The team made tests with lock and battery and it worked correctly.
Please, let me know your results.

1 Like

Hi all,

I tested with the .value syntax and it’s working! Thanks!

    "dashboard": {
        "states": [
            {
                "component": "main",
                "capability": "lock",
                "version": 1,
                "values": []
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "lock",
                "version": 1
            }
        ],
        "basicPlus": []
    },
    "detailView": [
        {
            "component": "main",
            "capability": "lock",
            "version": 1,
            "values": [
                {
                    "key": "lock.value",
                    "label": "Action"
                }
            ],
            "patch": []
        },
        {
            "component": "main",
            "capability": "battery",
            "version": 1,
            "values": [
                {
                    "key": "battery.value",
                    "label": "Battery Status"
                }
            ],
            "patch": []
        },
        {
            "component": "main",
            "capability": "contactSensor",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "refresh",
            "version": 1,
            "values": [],
            "patch": []
        }
    ],
    "automation": {
        "conditions": [
            {
                "component": "main",
                "capability": "lock",
                "version": 1,
                "values": [
                  {
                    "key": "lock.value",
                    "label": "Action"
                  }
                ],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "battery",
                "version": 1,
                "values": [
                  {
                    "key": "battery.value",
                    "label": "Battery Status"
                  }
                ],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "contactSensor",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "lock",
                "version": 1,
                "values": [
                  {
                    "key": "lock",
                    "label": "Action"
                  }
                ],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "refresh",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            }
        ]
    },
1 Like

Well, it seems you have all the secrets. Is it possible to change the label and state for mediaPresets using device-config?

id: mediaPresets
version: 1
detailView:
  - label: '{{i18n.label}}' <-- this (aka 'Play a favorite')
    displayType: state
    state:
      label: '{{presets.value}}' <-- and this (aka 'Tap to choose a favorite')

As it stands, neither custom list nor mediaPresets does what I want. The list presentation is configurable, but the list contents cannot be dynamically populated. mediaPresets can be dynamically populated, but I’ve been unable to modify the label and the status/state area is wasted with ‘instructions’ to the user.

1 Like

Looks like we have another issue here.

The history tab on detail view still uses the default label

This would be huge, but in my experience, the answer is currently no. I would love to be proven wrong. Having fully functional scenes or modes capabilities would also be a great alternative.

Even if the state could be changed, there’s no extra attribute to reference in the capability. The state would have to be static.

Bugs are expected in all the capabilities that have a “proposed” status. I can report it but it can take some time to be reviewed.
About setting the list dynamically (this means, adding/removing items that are not included in the capability presentation), it is not currently available. Do you have a screenshot of the UI of the mediaPresents capability?

Let me check this with the team, thank you for bringing this up.

While you’re at it, can you also check if translations work production capability?

I tried to create a translation for lock

 Error: Request failed with status code 422: {"requestId":"5B8939E3-C4FB-455B-BBB4-360C49064B7B","error":{"code":"ConstraintViolationError","message":"The request is malformed.","details":[{"code":"NotValidValue","message":"Can
     only upsert localizations for namespaced capabilities","details":[]}]}}

Does translation only work on namespaced capabilities?

Do you want to change the translation of a stock capability?
Please, share more details about this, I mean:

Yes, I want to change the translation of a stock capability. i.e. lock

Here’s the payload for en

{
  "tag": "en",
  "label": "Custom Lock Action",
  "attributes": {
    "lock": {
      "label": "Action",
      "i18n": {
        "value": {
          "unlocked": {
            "label": "Unlocked"
          },
          "locked": {
            "label": "Locked"
          },
          "unknown": {
            "label": "Unknown"
          },
          "unlocked with timeout": {
            "label": "Unlocked with timeout"
          }
        }
      }
    }
  }
}

The payload for simplified Chinese, zh-cn

{
  "tag": "zh-cn",
  "label": "解头命令",
  "attributes": {
    "lock": {
      "label": "命令",
      "i18n": {
        "value": {
          "unlocked": {
            "label": "解锁"
          },
          "locked": {
            "label": "锁"
          },
          "unknown": {
            "label": "未知"
          },
          "unlocked with timeout": {
            "label": "超时解锁"
          }
        }
      }
    }
  }
}

CLI

smartthings capabilities:translations:update lock 1 -j -i en.json --language=en
smartthings capabilities:translations:update lock 1 -j -i zh-cn.json --language=zh-cn

Response

Error: Request failed with status code 422: {"requestId":"E8F6E79D-DD3A-49AA-AD04-C9A98176546D","error":{"code":"ConstraintViolationError","message":"The request is malformed.","details":[{"code":"NotValidValue","message":"Can
     only upsert localizations for namespaced capabilities","details":[]}]}}

When you select “simplified Chinese” as your mobile device’s language, doesn’t it appear correctly? Or do you want to change the label as you made it in English?
Changing the localization (language) value is not possible, this is related to the issue of the device history.
The team mentioned that label customization in the presentation doesn’t affect the history because it takes the value from the localization.

I’ll explain my use case using stock capability: Contact Sensor

The default label on the Detail View is “Contact Sensor” and I changed it to “Door Status” using the key: attributeName.value as you mentioned above.

At this point, I want to know if we can change the label first going into translations. All good

Now on to translations, using Simplified Chinese as the mobile device’s language.

The label remains as “Door Status”, meaning the change above overwrites the translation too
The value is in Simplified Chinese: 已关闭 (closed) or 打开 (open), which are expected

Question: How do we modify a stock capability label with translations?. Thanks!