fix: update deprecated NUMBER_SCHEMA and BUTTON_SCHEMA for ESPHome 2025.11+#13
Open
vekexasia wants to merge 1 commit intoRocka84:masterfrom
Open
fix: update deprecated NUMBER_SCHEMA and BUTTON_SCHEMA for ESPHome 2025.11+#13vekexasia wants to merge 1 commit intoRocka84:masterfrom
vekexasia wants to merge 1 commit intoRocka84:masterfrom
Conversation
…25.11+ ESPHome 2025.11 removed the class-attribute schemas: - number.NUMBER_SCHEMA -> number.number_schema(class_) - button.BUTTON_SCHEMA -> button.button_schema(class_) The new factory functions accept the class directly, so the separate cv.GenerateID()/cv.declare_id() is no longer needed. Ref: https://developers.esphome.io/blog/2025/05/14/_schema-deprecations/
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.
Problem
ESPHome 2025.11+ removed the deprecated class-attribute schemas (
NUMBER_SCHEMA,BUTTON_SCHEMA), causing anAttributeErrorwhen trying to use this component:Fix
Migrated to the new factory-function API as per ESPHome deprecation guide:
number.NUMBER_SCHEMA.extend({cv.GenerateID(): cv.declare_id(Cls)})→number.number_schema(Cls)button.BUTTON_SCHEMA.extend({cv.GenerateID(): cv.declare_id(Cls)})→button.button_schema(Cls)The new functions accept the class directly, so the separate
cv.declare_id()boilerplate is no longer needed.Tested with ESPHome 2025.12.2 on ESP32-S3.