Visible condition with Embedded Configs

Trying to use visibleCondition along with embedded configs. These are the configs you can add directly into the device profile. Is visible condition allowed for embedded defintions:

components:
  - id: main
    capabilities:
      - id: switch
        version: 1
      - id: switchLevel
        version: 1
        config:
          visibleCondition:
            component: main
            capability: switch
            version: 1
            value: switch.value
            valueType: string
            operator: EQUALS
            operand: 'on'

In the example above, just tried to show/hide the switchLevel based on the status of the switch.

Hi, @blueyetisoftware!
Someone asked about these configurations and here I put the feedback from the team:

Basically, not all embedded configurations will take effect because it’s a work in progress, that’s why it isn’t documented yet.

1 Like

Thanks. I actually did see documentation for it, which is why I started messing with it. Just not sure if visibleCondition is allowed. All of the examples change values and that its all I have seen work so far.

Docs

Aah right, this was the update from last week. I’ll ask the team again to see if there’s an update or visibleCondition is still not supported.

1 Like

Hi, @blueyetisoftware
Following up, I confirmed with the team that visibleCondition isn’t supported yet in the embedded configurations.

2 Likes

Hi, @nayelyz Is visibleCondition now supported for embedded configurations?

Hi, @aqua2024
Sorry for the delay, I was making some tests and validating them with the engineering team.
Turns out this is not supported. This property in particular requires us to create a separate device configuration to be able to use it. Here’s an example in case it’s helpful:

{
  "type": "profile",
  "dashboard": {
      "states": [
          {
              "component": "main",
              "capability": "switch",
              "version": 1,
              "idx": 0,
              "group": "main",
              "values": [
                  {
                      "label":"{{switch.value}}",
                      "alternatives":[
                          {
                              "key": "on",
                              "value": "power: ",
                              "type": "active"
                          }
                      ]
                  }
              ],
              "composite": true
          },
          {
              "component": "main",
              "capability": "powerMeter",
              "version": 1,
              "idx": 0,
              "group": "main",
              "values": [
                  {
                      "label": "{{power.value}}{{power.unit}}"
                  }
              ],
              "composite": true,
              "visibleCondition": {
                  "capability": "switch",
                  "component": "main",
                  "version": 1,
                  "value": "switch.value",
                  "operator": "EQUALS",
                  "operand": "on"
              }
          }
      ],
      "actions": [
          {
              "component": "main",
              "capability": "switch",
              "version": 1,
              "idx": 0,
              "group": "main",
              "inline": null
          }
      ],
      "basicPlus": []
  },
  "detailView": [
      {
          "component": "main",
          "capability": "switch",
          "version": 1,
          "values": [],
          "patch": []
      },
      {
          "component": "main",
          "capability": "powerMeter",
          "version": 1,
          "values": [],
          "patch": []
      }
  ],
  "automation": {
      "conditions": [
          {
              "component": "main",
              "capability": "switch",
              "version": 1,
              "values": [],
              "patch": [],
              "exclusion": []
          },
          {
              "component": "main",
              "capability": "powerMeter",
              "version": 1,
              "values": [],
              "patch": [],
              "exclusion": []
          }
      ],
      "actions": [
          {
              "component": "main",
              "capability": "switch",
              "version": 1,
              "values": [],
              "patch": [],
              "exclusion": []
          },
          {
              "component": "main",
              "capability": "powerMeter",
              "version": 1,
              "values": [],
              "patch": [],
              "exclusion": []
          }
      ]
  }
}

//--------------------------------Another sample:
//822a802f-2ead-356a-a3bf-166ddb61c57a
{
    "dashboard": {
        "states": [
            {
                "component": "main",
                "capability": "temperatureMeasurement",
                "version": 1,
                "idx": 0,
                "group": "main",
                "values": [],
                "composite": false
            }
        ],
        "actions": [],
        "basicPlus": []
    },
    "detailView": [
        {
            "component": "main",
            "capability": "temperatureMeasurement",
            "version": 1,
            "visibleCondition": {
                "component": "main",
                "capability": "thermostatMode",
                "version": 1,
                "value": "thermostatMode.value",
                "operator": "ONE_OF",
                "operand": "[\"auto\", \"manual\"]"
            },
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "switchLevel",
            "version": 1,
            "visibleCondition": {
                "component": "main",
                "capability": "thermostatMode",
                "version": 1,
                "value": "thermostatMode.value",
                "operator": "ONE_OF",
                "operand": "[\"fanonly\", \"cool\"]"
            },
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "thermostatMode",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "refresh",
            "version": 1,
            "values": [],
            "patch": []
        }
    ],
    "automation": {
        "conditions": [
            {
                "component": "main",
                "capability": "temperatureMeasurement",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "switchLevel",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "thermostatMode",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "switchLevel",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "thermostatMode",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            }
        ]
    },
    "type": "profile"
}

Please, let me know if you have questions regarding its creation and usage in a profile.

Hi @nayelyz , I assume the example above on Device Configuration is not applicable for Edge Driver development. I am developing zigbee edge driver which needs to change UI elements (hide/visible) depending on attributes received. As an example capabilities.button.numberOfButtons seems to have no effect on UI. The edge driver only looks at static components of deviceProfileName defined in fingerprints.yml. I am able to change the displayed values (capabilities.button.supportedButtonValues), but not number of buttons. Any method to dynamically adjust UI behavior defined in edge driver is helpful.

It can be used, when we use a Device Configuration to create a Device Presentation, it can be used in any profile (see here).
Just to provide some light into this, a Device Configuration is basically the file where we define all the changes we want to apply in the default capability presentation, for example, define the enums available, change the range accepted, etc.
A Device Presentation is the result of the configurations we defined. This means, that when you query the Device Presentation, you’ll see the enums filtered, the new range applied, etc.
Once you have the Device Configuration file ready, you need to make a request to the API to create the presentation:

In the case of an Edge profile, using it would look like this example:

Just to clarify, in the Detail View, the property “visibleCondition” doesn’t hide/display the element, it becomes enabled/disabled. When disabled (which means it doesn’t meet the condition defined in “visibleCondition”), you cannot control the capability and it’s greyed out.
In the Automation view, the capability is hidden if it doesn’t meet the condition.

Yes, I believe that attribute was used only as a reference and not to show that number of buttons in the UI. Is that what you’re looking for?
If so, you need to create a component in your profile for each button (not dynamic) or use the parent/child method which means you create a new device instance but type “EDGE_CHILD”. Here’s an example:SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/zigbee-dual-metering-switch/init.lua at main · SmartThingsCommunity/SmartThingsEdgeDrivers · GitHub

Hi @nayelyz , thanks for your detailed response. Can you share an example of creating a device configuration using CLI? Does execution of CLI command generate vid? Should the device configuration you described above be saved as a JSON file and used with input switch on CLI?
smartthings presentation:device-config:create -i <device-config.json> -p <fancy-switch.yml>

Yes, you’ll see the VID and presentationId properties in the output of the CLI, they’re both the same value.

yes, that JSON file is the input of this command. There’s a command that helps you generate the Device Configuration based on an existing presentation ID so you don’t have to start from scratch.

So, here’s an example:

  1. When we install a device to our driver, the presentation of its profile is generated by default if we don’t define one explicitly on its metadata.
  2. So, we can get it by querying the device’s details with the command:
smartthings devices deviceID -j
  1. Copy the value in the property “presentationId” and use it in the command below:
smartthings presentation:device-config presentationId -j -o=deviceConfig.json

The file will be created in the same folder where your CLI is or you can set a specific path.
4. Once you finish changing the file, you need to use:

smartthings presentation:device-config:create -i deviceConfig.json

You don’t need to specify the profile here

  1. In the output, you’ll see the properties VID and MNMN at the top, which you’ll include in your Edge profile as this sample:
name: fancy-switch
components:
  - id: main
    capabilities:
      - id: "your_namespace.fancySwitch"
        version: 1
      - id: refresh
        version: 1
    categories:
      - name: Switch
metadata:
  mnmn: SmartThingsCommunity
  vid: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Then, when you install the device again, it should use this presentation instead. You need to verify this by querying the device’s details again.

Hi @nayelyz . Thanks for the detailed steps. I was able to get visibleCondition to work!!
The only issue was with step 2
smartthings devices deviceID -j.
This statement generated an error for “deviceID”. So omitted this keyword and used
smartthings devices -j.

Oh, sorry for the confusion, you had to replace the word “deviceID” with the real device ID, so you can see the details of a single device instead of the complete list.
You can get the device ID if you use smartthings devices which will show you the result in a table.
Or, you can also use the Advanced Users app to see certain details of the device.

Hi @nayelyz , how do we share an edge driver once the device config/presentation has been changed. I used

smartthings edge:channels:invites:create

to share edge drive, but this does not work anymore once the device config was changed using above steps

What do you mean by “it doesn’t work anymore”? Do you get an error?
If you created an invitation in the past and added your driver there, you can update it and the new version will be published there. For example:

  1. If the first version of the driver didn’t have a custom device config, then you add a custom VID and MNMN on the profile’s metadata. You just need to package the driver and assign it to the channel again so the profile is updated. It can take a while for the device to get the new presentation. You need to confirm it’s using the last presentationId. (please let me know if you need help with this)
  2. If the custom VID was already assigned to the profile, but you made minimum changes to the device presentation, the VID won’t change, and you just need to wait for the change to take effect, which can take up to 12 hours

You can force the update by deleting the device, change the name assigned in the driver and install everything again.

  1. The update to presentation is working for me once I package it again. No issue with this. When I share this invite to a test user, they can install it but the presentation updates are not seen. They verified the driver installed is latest since the package name and key is the latest.

Can they check if the presentation ID of their device is the same as yours?
On the Advanced Users App - Devices, please ask them to take a screenshot of the device’s details to see the presentation ID and profile ID to check their config and see which one isn’t updated please.

The issue has been traced. There was an error in the invite creation. It defaulted to an older channel. The key is to explicitly specify the channel id during creation
smartthings edge:channels:invites:create -C

I made a test and when we use this command without the flag -C, the CLI asked me to select the channel.
If it didn’t for you, it might have used the defaults selected in the CLI’s config. I suggest you use this command to see the defaults selected:

smartthings config default

If you want to reset that config, you can use:

smartthings config:reset

Thanks for this command. Indeed the default hub and channel was set in the config.

1 Like