Delete plugin settings entry from config.yaml via save

Is there a way to remove a setting key from config.yaml via the plugins settings interface.

A few years ago (just before covid) I hit a "bug" with my plugin octohue where users could not delete the "states" that they added to configure lighting events.
These states (e.g Connected) are written to config.yaml when they are added via the settings page and saved.

        brightness: '255'
        colour: '#CCCCCC'
        delay: ''
        turnoff: ''
        brightness: '255'
        colour: '#FFFFFF'
        delay: ''
        turnoff: ''

Deleting the setting via the settings page seems to work on a js level, as the settings object being passed back (self.ownSettings.statusDict) now has one less element in it (would contain only "Boosh" after connected has been removed), however the corresponding element is not removed from config.yaml on save. One octoprints next restart "Connected" is once again present as it persists in config.yaml

I can probably work around this by treating statusDict as append only, and adding an enabled/disabled flag so users could set them to ignore, but I'd like to avoid the build up of statuses users no longer required.

Cheers for the help

In plugin manager on the right side of the row where the plugin is listed is a small eraser icon you can use to completely clear the settings of the plugin.

Unfortunately I'm not trying to clear all the settings, just remove a single configuration entry.

In my example above, I'm looking to remove only the Key "Connected" and all the values associated with it.
Writing settings the the config file seems to work for adding, updating, and appending, but I can't seem to update statusDict so that one of its keys has been removed.

those can be tricky sometimes from the plugin development side and it depends on how they are bound in knockout. might need to see all the code, but do you have anything in on_settings_save inside the plugin?

Just took a quick peak at your current code. I think it may be related to using a function for binding flatStatus to. observableArray is one of the hardest things to deal with updates from a ko perspective.

You beat me to it, I was just about to paste a link.. but for anyone else who might be interested..

regarding using the function for binding, there may be a sizable problem with me not knowing what I don't know. The current implementation was the result of me brute forcing ko and JS because I wasn't sure if there was a more appropriate way. IIRC i think the problem might have come from not being able to iterate through an the statusDict dict of dicts using ko. But it was a long time ago

If there is a more elegant way to do what I've done I'm happy to consider it.

If it's viable to switch from a dict of dicts to an array of dicts you may find it a little easier to deal with for adding/subtracting items reliably. I've done this approach in several of my plugins, for example the bundled event manager plugin has this approach with subscriptions.

the trick being using a modal pop-up to edit the entries, although I think you could just as easily embed the fields in the row itself the way you were doing.

Awesome, thank you. I'll take a closer look when i get home from work in a couple of hours.

Thanks @jneilliii that worked a treat,
There is now a large chunk of plagerised code in my JS and templates, as I wanted to get the bug fixed first and then optimise and customise in later releases.

The modal is in, tbh it was a fun new thing to learn even if i might have been able to achieve your suggestion without it.
IIRC, and its been a while, I originally started with a list of dicts, but moved on to a dict of dicts as it made the logic for getting/setting the light properties nice and elegant, but broke being able to save, and caused hell working with ko and JS (for my inexperienced js skills). I think I've reverted to the list of dicts and managed to maintain much of the elegance i liked before.

Thanks again