Clearing mediaPresets Capability

How do you clear the mediaPresets capability? I am adding presets to a device, but once they are all removed, I need to clear the list back to its initial empty state. I have tried emitting nil as well as {}. Any ideas?

device:emit_event(capabilities.mediaPresets.presets({}))
device:emit_event(capabilities.mediaPresets.presets(nil))

Hi, @blueyetisoftware!

The capability is configured to require id and name in every event of the capability:

"attributes": {
    "presets": {
        "schema": {
            "type": "object",
            "properties": {
                "value": {
                    "type": "array",
                    "items": {
                        "title": "MediaPreset",
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {...},
                            "name": {...},
                            "mediaSource": {...},
                            "imageUrl": {...}
                        },
                        "required": [ //***HERE***//
                            "id",
                            "name"
                        ]
                    }
                }
            }
        }
    }
}

That’s why sending an empty array doesn’t change the status of the “presets” attribute, instead, you can use the following command:

device:emit_event(capabilities.mediaPresets.presets({{id="",name=""}}))

I tested it and sending that event disables the usage of the widget until it gets new data:
image

1 Like

Perfect. Thank you very much

1 Like