# Persistent Storage for Python Controller ###### tags: `CHIP` `Matter` `Firmware` `Engineer` I know it's dangerous to store such critical information in a file, but it's way much easier for development stage. ## Why I want to do this The original peresistent storage delegate in the python controller is implemented simply by a std::map. So, all the data would be gone whenever the python controller is closed. I would like to keep the data even after I close the controller for three reasons: 1. Don't want to repeat the entire commission process whenever I make some changes. 2. To observe the keys the CHIP/Matter stack creates. 3. I just want to do it. Here is my example on [github](https://github.com/xaiser/MatterPythonStorage/tree/master). Put the three files to this directory in your Matter project: connectedhomeip/src/controller/python ## Use ini file You could just show how good you are by using different techology here. But I will go with ini file. The idea is to save all the information in a ini file. In my example, I put the ini file here: /Users/x/CS/project/PersonalWeatherSensor/chip_ctrl_test.ini There is a third party ini library in Matter project I could use to manage the ini file. You could find it in the third party directory: >connectedhomeip/third_party/inipp Beside including the library in the cpp file, we have to add the dependence in the make file. :::info And I was using the efr32 lock-app example again. So the make file is actually BUILD file ::: ``` public_deps = [ "${chip_root}/src/app", .... "${chip_root}/third_party/inipp" ] ``` Also, make sure you initialize the storage before any of access to the storage. I put it here: ![](https://i.imgur.com/VzngCnS.png) And now you should be able to compile. ## What we get after this change ### Just need the resolve command In order to keep the keys/credentials in the ini file, you still need to repeat the entire commission process one more time. However, after that, you only need to start from the resolve command to find the device in the openthread network whenever you re-start the controller. ### Check the ini file Now we can see what exact information the Matter stack creates during the commission process. That would be something like this: >[Default] >CHIPAdmin0=..... >ExampleOpCredsCAKey=... >ExampleOpCredsICAKey=... >ListPairedDevices0=... >PairedDevice13=... >StartKeyID=...