[dlms_meter] Remove deprecated provider option (#20385)

This commit is contained in:
J. Nick Koston
2026-10-09 09:20:17 -10:00
committed by GitHub
parent 588fde91b2
commit f7b80e6d44
4 changed files with 40 additions and 59 deletions
+17 -58
View File
@@ -1,4 +1,3 @@
import logging
import re
from typing import Any
@@ -18,8 +17,6 @@ from esphome.const import (
from esphome.core import CORE
from esphome.types import ConfigType
_LOGGER = logging.getLogger(__name__)
CODEOWNERS = ["@SimonFischer04", "@Tomer27cz", "@latonita", "@PolarGoose"]
DEPENDENCIES = ["uart"]
DOMAIN = "dlms_meter"
@@ -75,56 +72,6 @@ def validate_custom_pattern(value: ConfigType) -> ConfigType:
return value
def validate_provider_deprecation(config: ConfigType) -> ConfigType:
if CONF_PROVIDER in config:
provider = str(config[CONF_PROVIDER]).lower()
if provider == "netznoe":
_LOGGER.warning(
"The 'provider: netznoe' option is deprecated and will be removed in 2026.11.0. "
"The required custom patterns have been added automatically for this release, but you must update your configuration.\n"
"Please remove the 'provider' key and explicitly replace it with the following:\n\n"
"custom_patterns:\n"
' - pattern: "L, TSTR"\n'
' name: "MeterID"\n'
' default_obis: "0.0.96.1.0.255"\n'
' - pattern: "F, TDTM"\n'
' name: "DateTime"\n'
' default_obis: "0.0.1.0.0.255"\n'
)
patterns = config.get(CONF_CUSTOM_PATTERNS, [])
# Ensure "L, TSTR" for MeterID is present
if not any(p.get(CONF_PATTERN) == "L, TSTR" for p in patterns):
patterns.append(
{
CONF_PATTERN: "L, TSTR",
CONF_NAME: "MeterID",
CONF_DEFAULT_OBIS: [0, 0, 96, 1, 0, 255],
CONF_PRIORITY: 0,
}
)
# Ensure "F, TDTM" for DateTime is present
if not any(p.get(CONF_PATTERN) == "F, TDTM" for p in patterns):
patterns.append(
{
CONF_PATTERN: "F, TDTM",
CONF_NAME: "DateTime",
CONF_DEFAULT_OBIS: [0, 0, 1, 0, 0, 255],
CONF_PRIORITY: 0,
}
)
config[CONF_CUSTOM_PATTERNS] = patterns
else:
_LOGGER.warning(
"The 'provider' option is deprecated and will be removed in 2026.11.0. "
"The dlms_parser library now handles quirks dynamically. "
"Please remove this option from your configuration."
)
return config
CUSTOM_PATTERN_SCHEMA = cv.All(
custom_pattern_dict,
cv.Schema(
@@ -138,7 +85,7 @@ CUSTOM_PATTERN_SCHEMA = cv.All(
validate_custom_pattern,
)
CONFIG_SCHEMA = cv.All(
CONFIG_SCHEMA = (
cv.Schema(
{
cv.GenerateID(): cv.declare_id(DlmsMeterComponent),
@@ -146,15 +93,27 @@ CONFIG_SCHEMA = cv.All(
cv.Optional(CONF_AUTH_KEY): cv.bind_key(name="Authentication key"),
cv.Optional(CONF_CUSTOM_PATTERNS): cv.ensure_list(CUSTOM_PATTERN_SCHEMA),
cv.Optional(CONF_SKIP_CRC, default=False): cv.boolean,
cv.Optional(CONF_PROVIDER): cv.string,
# Removed in 2026.11.0 - kept to provide helpful error message
# Remove before 2027.5.0
cv.Optional(CONF_PROVIDER): cv.invalid(
"The 'provider' option has been removed in ESPHome 2026.11.0.\n"
"For 'provider: netznoe', replace it with:\n\n"
"custom_patterns:\n"
' - pattern: "L, TSTR"\n'
' name: "MeterID"\n'
' default_obis: "0.0.96.1.0.255"\n'
' - pattern: "F, TDTM"\n'
' name: "DateTime"\n'
' default_obis: "0.0.1.0.0.255"\n\n'
"For any other provider, remove the option"
),
cv.Optional(
CONF_RECEIVE_TIMEOUT, default="1000ms"
): cv.positive_time_period_milliseconds,
}
)
.extend(uart.UART_DEVICE_SCHEMA)
.extend(cv.COMPONENT_SCHEMA),
validate_provider_deprecation,
.extend(cv.COMPONENT_SCHEMA)
)
FINAL_VALIDATE_SCHEMA = uart.final_validate_device_schema("dlms_meter", require_rx=True)
@@ -193,7 +152,7 @@ async def to_code(config: ConfigType) -> None:
cg.ArrayInitializer(
p[CONF_PATTERN],
name_expr,
p.get(CONF_PRIORITY, 0),
p[CONF_PRIORITY],
obis_expr,
)
)
@@ -0,0 +1,17 @@
"""Tests for the dlms_meter provider option removed in 2026.11.0."""
import pytest
from voluptuous import Invalid, MultipleInvalid
from esphome.components.dlms_meter import CONFIG_SCHEMA
def test_removed_provider_shows_the_netznoe_patterns() -> None:
with pytest.raises(Invalid) as exc_info:
CONFIG_SCHEMA({"provider": "netznoe"})
errors = (
exc_info.value.errors
if isinstance(exc_info.value, MultipleInvalid)
else [exc_info.value]
)
assert any('pattern: "L, TSTR"' in str(error) for error in errors)
+6 -1
View File
@@ -4,10 +4,15 @@ dlms_meter:
decryption_key: "36C66639E48A8CA4D6BC8B282A793BBB"
auth_key: "11223344556677889900AABBCCDDEEFF"
skip_crc: true
provider: "netznoe"
custom_patterns:
- "custom_pattern_1"
- "custom_pattern_2"
- pattern: "L, TSTR"
name: "MeterID"
default_obis: "0.0.96.1.0.255"
- pattern: "F, TDTM"
name: "DateTime"
default_obis: "0.0.1.0.0.255"
sensor:
# Old Schema tests