I have written a custom capability that has a single text attribute (statustext) with a setter command. I also created a presentation where the attribute is a toggle switch in the detailView.
This almost works except for one thing: the “state” section of the presentation is not correctly mapping the switch on/off position based on the correlating attribute value. Even though the label shows the expected text value, the switch itself is always “on” no matter what. I have tried this with both Switch and ToggleSwitch, and the state section is broken for me on both.
@nayelyz Am I missing something in getting the switch position to map to the actual attribute value?
Capability
{
"version": 1,
"status": "proposed",
"name": "activestatus6",
"ephemeral": false,
"attributes": {
"statustext": {
"schema": {
"type": "object",
"properties": {
"value": {
"type": "string",
"enum": [
"enabled",
"disabled"
]
}
},
"additionalProperties": false,
"required": [
"value"
]
},
"setter": "setStatusText",
"enumCommands": []
}
},
"commands": {
"setStatusText": {
"name": "setStatusText",
"arguments": [
{
"name": "value",
"optional": false,
"schema": {
"type": "string"
}
}
]
}
}
}
Presentation
"dashboard": {
"states": [
{
"label": "Status: {{statustext.value}}"
}
],
"actions": []
},
"detailView": [
{
"label": "{{i18n.label}}",
"displayType": "toggleSwitch",
"toggleSwitch": {
"command": {
"name": "setStatusText",
"on": "enabled",
"off": "disabled"
},
"state": {
"value": "statustext.value",
"on": "enabled",
"off": "disabled",
"label": "{{statustext.value}}"
}
}
}
],
"automation": {
"conditions": [
{
"label": "Status",
"displayType": "enumSlider",
"enumslider": {
"value": "statustext.value",
"alternatives": [
{
"key": "enabled",
"value": "Enabled"
},
{
"key": "disabled",
"value": "Disabled"
}
]
}
}
],
"actions": [
{
"label": "Status",
"displayType": "list",
"list": {
"alternatives": [
{
"key": "enabled",
"value": "Enabled"
},
{
"key": "disabled",
"value": "Disabled"
}
]
}
}
]
},
"id": "towertalent27877.activestatus6",
"version": 1
}```