Save custom card config from card


I am working on a custom card that displays a zigbee network using vis-network.

vis-network allows for dragging of the node elements to change the layout and will provide x,y coordinates of each node.

In order to allow the saving of this layout, I need to be able to do this from a button on the bottom of the card.

However, I am trying to then save this layout info (json string) in the card config and for the life of me can’t work out how I might do this.

The card has an editor card (which is fine and does save correctly) by firing the config-changed event but this does not work on the actual card itself (as preume no listener if not in edit mode).

Does anyone know a way to then update the card config through code within the actual custom card itself?

For info in case anyone else is trying this. The basic answer is you cannot save the config from the card itself. What i ended up doing is detecting if the card is being displayed in the edit window and adding additional functionality to it to allow to drag the vis-network nodes and a button to save layout. This uses an event to pass the layout info back to the edit pane where it is saved to the card config when the card is saved.