Window contact sensor icon

Hello,

I am writing an Edge driver for a Z-Wave window handle. I have combined window status (open, closed, tilted) with handle position (locked, unlocked, tilted) in a custom capability.

The generic zwave sensor driver gives me a simple open/closed contactSensor. I noticed that with the generic driver I can change the icon from contact sensor to window (how can I set this as default in the profile?) and it changes correctly to sensor state?

Is there any way to configure the same behavior for my custom function? My first intention was to add the contactSensor capability as well, but that doesn’t seem to be the way to go.

name: handle
components:
- id: main
  capabilities:
  - id: contactSensor
    version: 1
  - id: preparestream40760.windowState
    version: 1
  - id: battery
    version: 1
  - id: refresh
    version: 1
  categories:
  - name: ContactSensor
preferences:
  - preferenceId: preparestream40760.basicCmdSendByON
    explicit: true
  - preferenceId: preparestream40760.basicCmdSendByOFF
    explicit: true
  - preferenceId: preparestream40760.reportLastStateOnWakeUp
    explicit: true
metadata:
  vid: 27c4a42f-843e-3573-9362-b2b06bc421b0
  mnmn: SmartThingsCommunity

Thanks in advance.

Hi, @ronie_pilot
AFAIK, the icon is set based on the category assigned to the device profile. Only certain categories allow users to change the icon in the app.

As you already have the ContactSensor category assigned, I don’t know if you also need to add that in the profile’s metadata as OCF type, this is an example of a motion sensor

name: xxxxx
components:
- id: main
  capabilities:
  - id: motionSensor
    version: 1
  - id: illuminanceMeasurement
    version: 1
  - id: temperatureMeasurement
    version: 1
  - id: battery
    version: 1
  - id: healthCheck
    version: 1
  categories:
    - name: MotionSensor
metadata:
  deviceType: MotionSensor
  ocfDeviceType: x.com.st.d.sensor.motion
  deviceTypeId: MotionSensor

Could you see if that helps, please?

You cannot do the exact same within the driver’s code. I’ve seen other developers use the function try_update_metadata to change the profile assigned to the device, but you’ll need a profile for each icon you want to set.

This is my latest profile:

name: handle
components:
- id: main
  capabilities:
  - id: contactSensor
    version: 1
  - id: preparestream40760.windowState
    version: 1
  - id: preparestream40760.homeSecurity
    version: 1
  - id: battery
    version: 1
  - id: refresh
    version: 1
  categories:
  - name: ContactSensor
preferences:
  - preferenceId: preparestream40760.basicCmdSendByON
    explicit: true
  - preferenceId: preparestream40760.basicCmdSendByOFF
    explicit: true
  - preferenceId: preparestream40760.reportLastStateOnWakeUp
    explicit: true
metadata:
  vid: 7f9baf70-ff07-32d6-b1e1-a1c5f9253e00
  mnmn: SmartThingsCommunity
  deviceType: ContactSensor
  ocfDeviceType: x.com.st.d.sensor.contact
  deviceTypeId: ContactSensor

and my presentation:

{
    "dashboard": {
        "states": [
            {
                "component": "main",
                "capability": "preparestream40760.windowState",
                "version": 1,
                "idx": 0,
                "group": "main",
                "values": [{
                        "key": "preparestream40760.windowState.value",
                        "enabledValues": [
                            "window_handle_closed",
                            "window_handle_open",
                            "window_handle_tilt"
                        ],
                        "step": 1
                    }],
                "composite": false
            }
        ],
        "actions": [],
        "basicPlus": []
    },
    "detailView": [
        {
            "component": "main",
            "capability": "preparestream40760.windowState",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "preparestream40760.homeSecurity",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "contactSensor",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "battery",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "refresh",
            "version": 1,
            "values": [],
            "patch": []
        }
    ],
    "automation": {
        "conditions": [
            {
                "component": "main",
                "capability": "preparestream40760.windowState",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "preparestream40760.homeSecurity",
                "version": 1,
                "values": [],
                "patch": []
            },
            {
                "component": "main",
                "capability": "contactSensor",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "battery",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "refresh",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            }
        ]
    },
    "type": "profile"
}

not sure if custom caps are working in the dashboard, would be cool but it seems not.

In the below image are all available image types for the ContactSensor category:

I think I got you here, but this leads me to the following questions:

  • Which capability is triggering the image change (animation) like Sensor Open/Close or Window Open/Closed? As I can see in the zwave-sensor driver, there is no profile change. I guess this is also not necessary for my case.
  • Is there a way to set the window image for category ContactSensor as default?

aaah, you meant the animation! sorry about that, so, when you change to the “window” icon using your driver, it doesn’t change based on the open/close state, right?

This is because you have the capability preparestream40760.windowState in dashboard.states and it doesn’t have alternatives set with their corresponding type. (In fact, it doesn’t have any configuration in the dashboard section, which means you will only see “connected” in this view of the app).

This also means this section of the config you shared is not taking effect for two reasons:

  1. There’s no config for the dashboard view in this capability
  2. “key” should have “attributeName.value” instead of “capabilityId.value” (“windowState.value”)

For example, taking the capability presentation of “contactSensor” as a reference:


You can see it has the property “alternatives” with two possible values set (open/closed) and their alternative type is “active” and “inactive” respectively. So, as the driver from ST uses this capability in the dashboard view, once the current value becomes “open”, the icon will be colored and have the corresponding animation.

In this case, you need to add the alternatives config in the capability presentation of “preparestream40760.windowState”. For example:

"dashboard": {
        "states": [
            {
                "label": "{{windowState.value}}",
                "alternatives": [
                    {
                        "key": "window_handle_closed",
                        "value": "text visible for the user",
                        "type": "inactive"
                    },
                    ...
                    {
                        "key": "window_handle_open",
                        "value": "text visible for the user",
                        "type": "active"
                    }
                ]
            }
        ],
        "actions": []
}

Note: Alternatives also help you to show a human-readable text instead of the capability’s actual
value.

Remember you will need to re-create the VID so it takes the latest capability presentation after you update it.

1 Like

Indeed, the dashboard config was missing in it’s presentation :man_facepalming:t6:

Cool! I’ts working now! Thanks @nayelyz

And now for the topping:

My uploaded presentation:

{
    "dashboard": {
        "states": [
            {
                "component": "main",
                "capability": "preparestream40760.windowState",
                "version": 1,
                "idx": 0,
                "group": "main",
                "values": [{
                    "key":"windowState.value",
                    "enabledValue":[
                        "window_handle_closed",
                        "window_handle_open",
                        "window_handle_tilt"
                    ]
                }],
                "composite": false
            }
        ],
        "actions": [],
        "basicPlus": []
    },
    "detailView": [
        {
            "component": "main",
            "capability": "preparestream40760.windowState",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "preparestream40760.homeSecurity",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "battery",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "refresh",
            "version": 1,
            "values": [],
            "patch": []
        }
    ],
    "automation": {
        "conditions": [
            {
                "component": "main",
                "capability": "preparestream40760.windowState",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "preparestream40760.homeSecurity",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "battery",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "refresh",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            }
        ]
    },
    "type": "profile"
}

and that’s what I can see in the cli:

{
    "mnmn": "SmartThingsCommunity",
    "vid": "929ae76d-890d-38eb-abb1-7272b582fd20",
    "version": "0.0.1",
    "type": "profile",
    "dashboard": {
        "states": [
            {
                "component": "main",
                "capability": "preparestream40760.windowState",
                "version": 1,
                "idx": 0,
                "group": "main",
                "values": [
                    {}
                ],
                "composite": false
            }
        ],
        "actions": [],
        "basicPlus": []
    },
    "detailView": [
        {
            "component": "main",
            "capability": "preparestream40760.windowState",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "preparestream40760.homeSecurity",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "battery",
            "version": 1,
            "values": [],
            "patch": []
        },
        {
            "component": "main",
            "capability": "refresh",
            "version": 1,
            "values": [],
            "patch": []
        }
    ],
    "automation": {
        "conditions": [
            {
                "component": "main",
                "capability": "preparestream40760.windowState",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "preparestream40760.homeSecurity",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            },
            {
                "component": "main",
                "capability": "battery",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            }
        ],
        "actions": [
            {
                "component": "main",
                "capability": "refresh",
                "version": 1,
                "values": [],
                "patch": [],
                "exclusion": []
            }
        ]
    },
    "presentationId": "929ae76d-890d-38eb-abb1-7272b582fd20",
    "manufacturerName": "SmartThingsCommunity"
}

Is there a way to use enabledValues here?

  • And last but not least: How can I set the animation icon by default to the “window”?

Here’s a list shared by the Community of the icons available using the OCF values but I don’t see the window here: Editing DH - Where is the icons - #2 by orangebucket

So, there’s no info about other icons, sorry. I already created a report to get more details about the icons we can use but there has been no feedback there.

Sorry about this, I forgot something mentioned by the engineering team a while ago. The property of “enabledValues” cannot be used in the dashboard view. Actually, it isn’t included in the API reference:

They mentioned it isn’t necessary because users cannot select one of the possible options from there, instead, they can only see the current value of the capability, so it depends on the commands you accept.
I see you also use the state display type in the Detail View, so, it is a similar situation.

hi @nayelyz

I’m using the state on the dashboard now without reducing them which is also ok :+1:t6:

Any new information here?

I don’t know if it is any help, but when you select one of the two window icons the category is Window and the difference between the two is the icon which is either oneui/window_h or oneui/window_v.

What is the full list of categories that accepts changing icons?
I liked the way you listed these examples (name - quantity)

That’s the lastest info provided by the internal team on this. I don’t know if there are more categories added to this functionality, I’ll see if I can get more info, but for now, those are the only categories confirmed.

1 Like