Skip to content

fix: update deprecated NUMBER_SCHEMA and BUTTON_SCHEMA for ESPHome 2025.11+#13

Open
vekexasia wants to merge 1 commit into
Rocka84:masterfrom
vekexasia:fix/esphome-2025-schema-deprecations
Open

fix: update deprecated NUMBER_SCHEMA and BUTTON_SCHEMA for ESPHome 2025.11+#13
vekexasia wants to merge 1 commit into
Rocka84:masterfrom
vekexasia:fix/esphome-2025-schema-deprecations

Conversation

@vekexasia
Copy link
Copy Markdown

Problem

ESPHome 2025.11+ removed the deprecated class-attribute schemas (NUMBER_SCHEMA, BUTTON_SCHEMA), causing an AttributeError when trying to use this component:

AttributeError: module 'esphome.components.number' has no attribute 'NUMBER_SCHEMA'. Did you mean: '_NUMBER_SCHEMA'?

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.

…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/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant