[adc] Deprecate pin: TEMPERATURE in favour of internal_temperature (#18304)

This commit is contained in:
Jesse Hills
2026-08-12 14:20:41 +12:00
committed by GitHub
parent bab62b345b
commit 9605b34c69
5 changed files with 64 additions and 0 deletions
@@ -0,0 +1,32 @@
"""Tests for the ADC sensor component."""
from __future__ import annotations
from collections.abc import Callable
from pathlib import Path
import pytest
def test_adc_temperature_pin_is_deprecated(
generate_main: Callable[[str | Path], str],
caplog: pytest.LogCaptureFixture,
) -> None:
"""`pin: TEMPERATURE` still works, but warns and points at internal_temperature."""
main_cpp = generate_main("tests/component_tests/adc/test_adc_sensor.yaml")
assert "adc_temperature->set_is_temperature();" in main_cpp
assert "`pin: TEMPERATURE` is deprecated" in caplog.text
assert "internal_temperature" in caplog.text
assert "2027.2.0" in caplog.text
def test_adc_regular_pin_is_not_deprecated(
generate_main: Callable[[str | Path], str],
caplog: pytest.LogCaptureFixture,
) -> None:
"""A normal ADC pin does not emit the temperature deprecation warning."""
main_cpp = generate_main("tests/component_tests/adc/test_adc_sensor.yaml")
assert "adc_voltage->set_is_temperature();" not in main_cpp
assert caplog.text.count("`pin: TEMPERATURE` is deprecated") == 1
@@ -0,0 +1,16 @@
esphome:
name: test
rp2:
board: rpipicow
sensor:
- platform: adc
pin: TEMPERATURE
name: Deprecated ADC Temperature
id: adc_temperature
- platform: adc
pin: 26
name: ADC Voltage
id: adc_voltage
@@ -0,0 +1,7 @@
# Deprecated `pin: TEMPERATURE`, superseded by the `internal_temperature` platform.
# Remove before 2027.2.0
sensor:
- id: adc_temperature_sensor
platform: adc
pin: TEMPERATURE
name: ADC Test temperature