Skip to content

Commit 221029d

Browse files
authored
Merge pull request #148 from shogun160/fix-esphome-breaking-changes
Fix compatibility with ESPHome >= 2025.11 (NUMBER_SCHEMA / BINARY_SENSOR_SCHEMA removal)
2 parents 9f7c2d2 + 5099144 commit 221029d

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

components/persisted_number/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212
"PersistedNumber", number.Number, cg.Component
1313
)
1414

15-
PERSISTED_NUMBER_SCHEMA = number.NUMBER_SCHEMA.extend(
15+
BASE_SCHEMA = (
16+
number.number_schema(PersistedNumber)
17+
if hasattr(number, "number_schema")
18+
else number._NUMBER_SCHEMA
19+
)
20+
21+
PERSISTED_NUMBER_SCHEMA = BASE_SCHEMA.extend(
1622
{
1723
cv.GenerateID(): cv.declare_id(PersistedNumber),
1824
cv.Optional(CONF_RESTORE_VALUE, default=True): cv.boolean,

components/roode/binary_sensor.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,24 @@
1414
CONF_PRESENCE = "presence_sensor"
1515
TYPES = [CONF_PRESENCE]
1616

17+
# ESPHome: BINARY_SENSOR_SCHEMA removed -> use binary_sensor.binary_sensor_schema(...)
18+
BASE_SCHEMA = (
19+
binary_sensor.binary_sensor_schema(binary_sensor.BinarySensor)
20+
if hasattr(binary_sensor, "binary_sensor_schema")
21+
else binary_sensor._BINARY_SENSOR_SCHEMA
22+
)
23+
1724
CONFIG_SCHEMA = cv.Schema(
1825
{
1926
cv.GenerateID(CONF_ROODE_ID): cv.use_id(Roode),
20-
cv.Optional(CONF_PRESENCE): binary_sensor.BINARY_SENSOR_SCHEMA.extend(
27+
cv.Optional(CONF_PRESENCE): BASE_SCHEMA.extend(
2128
{
2229
cv.GenerateID(): cv.declare_id(binary_sensor.BinarySensor),
2330
}
2431
),
2532
}
2633
)
2734

28-
2935
# def validate_can_use_presence(value):
3036
# main = fv.full_config.get()["roode"][0]
3137
# presence_sensor = main.get(CONF_USE_PRESENCE)
@@ -40,15 +46,13 @@
4046
# {cv.Optional(CONF_PRESENCE): validate_can_use_presence}, extra=cv.ALLOW_EXTRA
4147
# )
4248

43-
4449
async def setup_conf(config, key, hub):
4550
if key in config:
4651
conf = config[key]
4752
sens = cg.new_Pvariable(conf[CONF_ID])
4853
await binary_sensor.register_binary_sensor(sens, conf)
4954
cg.add(getattr(hub, f"set_{key}_binary_sensor")(sens))
5055

51-
5256
async def to_code(config):
5357
hub = await cg.get_variable(config[CONF_ROODE_ID])
5458
for key in TYPES:

components/roode/text_sensor.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,36 @@
2020
CONFIG_SCHEMA = cv.Schema(
2121
{
2222
cv.GenerateID(CONF_ROODE_ID): cv.use_id(Roode),
23+
2324
cv.Optional(VERSION): text_sensor.text_sensor_schema().extend(
2425
{
2526
cv.Optional(CONF_ICON, default="mdi:git"): cv.icon,
2627
cv.GenerateID(): cv.declare_id(text_sensor.TextSensor),
2728
cv.Optional(
28-
CONF_ENTITY_CATEGORY, default=ENTITY_CATEGORY_DIAGNOSTIC
29+
CONF_ENTITY_CATEGORY,
30+
default=ENTITY_CATEGORY_DIAGNOSTIC,
2931
): cv.entity_category,
3032
}
3133
),
34+
3235
cv.Optional(ENTRY_EXIT_EVENT): text_sensor.text_sensor_schema().extend(
3336
{
3437
cv.Optional(CONF_ICON, default="mdi:sign-direction"): cv.icon,
3538
cv.GenerateID(): cv.declare_id(text_sensor.TextSensor),
3639
cv.Optional(
37-
CONF_ENTITY_CATEGORY, default=ENTITY_CATEGORY_DIAGNOSTIC
40+
CONF_ENTITY_CATEGORY,
41+
default=ENTITY_CATEGORY_DIAGNOSTIC,
42+
): cv.entity_category,
43+
}
44+
),
45+
46+
cv.Optional(STATUS): text_sensor.text_sensor_schema().extend(
47+
{
48+
cv.Optional(CONF_ICON, default="mdi:check-circle"): cv.icon,
49+
cv.GenerateID(): cv.declare_id(text_sensor.TextSensor),
50+
cv.Optional(
51+
CONF_ENTITY_CATEGORY,
52+
default=ENTITY_CATEGORY_DIAGNOSTIC,
3853
): cv.entity_category,
3954
}
4055
),

0 commit comments

Comments
 (0)