Add struct-based NVS storage for ESPHome compatibility#684
Draft
Add struct-based NVS storage for ESPHome compatibility#684
Conversation
- Created NVS partition builder module with ESP32 NVS format support - Extended Manifest interface with customFields and nvsPartition properties - Added CONFIGURATION state to install dialog - Implemented configuration form rendering with text, password, number, and checkbox fields - Integrated NVS partition generation into flash process - Configuration values are collected from form and used to build NVS partition - NVS partition is flashed alongside firmware at specified offset Co-authored-by: jesserockz <3060199+jesserockz@users.noreply.github.com>
- Created comprehensive NVS_CONFIGURATION.md documentation - Added example manifest with configuration fields - Updated README with feature overview Co-authored-by: jesserockz <3060199+jesserockz@users.noreply.github.com>
- Fix NVS key length handling to support full 15-character keys - Remove unnecessary blank line in install-dialog.ts - Update test file to use relative path for manifest - Improve test documentation Co-authored-by: jesserockz <3060199+jesserockz@users.noreply.github.com>
Co-authored-by: jesserockz <3060199+jesserockz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add a way to define form structure for NVS configuration
Add browser-based NVS partition builder with configuration forms
Feb 19, 2026
- Add blob type support to NVS partition builder - Implement packStruct() function for binary struct packing - Update manifest schema to support struct-based storage with numeric keys - Add struct configuration option alongside individual fields - Update buildESPHomeWiFiNVS() to use correct struct format - Add example-esphome-wifi.json with proper ESPHome configuration - Update documentation to explain struct vs individual field storage - Handle boolean to number conversion for struct fields Co-authored-by: jesserockz <3060199+jesserockz@users.noreply.github.com>
- Fix incomplete JSON in documentation - Improve boolean-to-number conversion to explicitly check numeric types - Add test functions for struct packing - Add ESPHome WiFi struct test - Add packStruct() export to test page Co-authored-by: jesserockz <3060199+jesserockz@users.noreply.github.com>
- Document blob type and struct packing features - Update manifest schema examples with both modes - Add ESPHome WiFi struct example with firmware integration - Document version changes and ESPHome compatibility fix - Update testing section with struct tests Co-authored-by: jesserockz <3060199+jesserockz@users.noreply.github.com>
Copilot
AI
changed the title
Add browser-based NVS partition builder with configuration forms
Add struct-based NVS storage for ESPHome compatibility
Feb 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ESPHome stores preferences using numeric hash keys with binary structs, not individual string-keyed entries. The initial implementation stored WiFi credentials as separate
"ssid"and"password"keys, which doesn't match ESPHome'sglobal_preferences->make_preference<T>(hash)API.Changes
NVS Builder (
src/nvs-partition-builder.ts)BLOBtype support for binary data storagepackStruct()to pack multiple fields into C struct layoutpackStruct()for reuseManifest Schema (
src/const.ts)Extended
NVSPartitionConfigwith two storage modes:Install Flow (
src/install-dialog.ts)nvsPartition.structis definedUsage
ESPHome WiFi credentials (correct format):
{ "customFields": [ { "name": "wifi_ssid", "label": "WiFi SSID", "type": "text", "required": true }, { "name": "wifi_password", "label": "WiFi Password", "type": "password", "required": true } ], "nvsPartition": { "offset": 36864, "namespace": "esphome", "struct": { "key": 88491487, "fields": [ { "name": "wifi_ssid", "type": "string", "maxLength": 33 }, { "name": "wifi_password", "type": "string", "maxLength": 65 } ] } } }Matches ESPHome's
SavedWifiSettingsstruct:The
fieldsmode remains available for non-ESPHome use cases requiring individual NVS entries.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.