mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 23:18:10 +01:00
[internal_temperature] ESP32-S3 needs ESP IDF V4.4.3 or higher (#4873)
Co-authored-by: Your Name <you@example.com>
This commit is contained in:
parent
28b5c535ec
commit
ffa5e29dab
2 changed files with 32 additions and 0 deletions
|
@ -33,6 +33,10 @@ void InternalTemperatureSensor::update() {
|
||||||
temp_sensor_config_t tsens = TSENS_CONFIG_DEFAULT();
|
temp_sensor_config_t tsens = TSENS_CONFIG_DEFAULT();
|
||||||
temp_sensor_set_config(tsens);
|
temp_sensor_set_config(tsens);
|
||||||
temp_sensor_start();
|
temp_sensor_start();
|
||||||
|
#if defined(USE_ESP32_VARIANT_ESP32S3) && (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(4, 4, 3))
|
||||||
|
#error \
|
||||||
|
"ESP32-S3 internal temperature sensor requires ESP IDF V4.4.3 or higher. See https://github.com/esphome/issues/issues/4271"
|
||||||
|
#endif
|
||||||
esp_err_t result = temp_sensor_read_celsius(&temperature);
|
esp_err_t result = temp_sensor_read_celsius(&temperature);
|
||||||
temp_sensor_stop();
|
temp_sensor_stop();
|
||||||
success = (result == ESP_OK);
|
success = (result == ESP_OK);
|
||||||
|
|
|
@ -1,18 +1,45 @@
|
||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.components import sensor
|
from esphome.components import sensor
|
||||||
|
from esphome.components.esp32 import get_esp32_variant
|
||||||
|
from esphome.components.esp32.const import (
|
||||||
|
VARIANT_ESP32S3,
|
||||||
|
)
|
||||||
from esphome.const import (
|
from esphome.const import (
|
||||||
STATE_CLASS_MEASUREMENT,
|
STATE_CLASS_MEASUREMENT,
|
||||||
UNIT_CELSIUS,
|
UNIT_CELSIUS,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
|
KEY_CORE,
|
||||||
|
KEY_FRAMEWORK_VERSION,
|
||||||
)
|
)
|
||||||
|
from esphome.core import CORE
|
||||||
|
|
||||||
internal_temperature_ns = cg.esphome_ns.namespace("internal_temperature")
|
internal_temperature_ns = cg.esphome_ns.namespace("internal_temperature")
|
||||||
InternalTemperatureSensor = internal_temperature_ns.class_(
|
InternalTemperatureSensor = internal_temperature_ns.class_(
|
||||||
"InternalTemperatureSensor", sensor.Sensor, cg.PollingComponent
|
"InternalTemperatureSensor", sensor.Sensor, cg.PollingComponent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def validate_config(config):
|
||||||
|
if CORE.is_esp32:
|
||||||
|
variant = get_esp32_variant()
|
||||||
|
if variant == VARIANT_ESP32S3:
|
||||||
|
if CORE.using_arduino and CORE.data[KEY_CORE][
|
||||||
|
KEY_FRAMEWORK_VERSION
|
||||||
|
] < cv.Version(2, 0, 6):
|
||||||
|
raise cv.Invalid(
|
||||||
|
"ESP32-S3 Internal Temperature Sensor requires framework version 2.0.6 or higher. See <https://github.com/esphome/issues/issues/4271>."
|
||||||
|
)
|
||||||
|
if CORE.using_esp_idf and CORE.data[KEY_CORE][
|
||||||
|
KEY_FRAMEWORK_VERSION
|
||||||
|
] < cv.Version(4, 4, 3):
|
||||||
|
raise cv.Invalid(
|
||||||
|
"ESP32-S3 Internal Temperature Sensor requires framework version 4.4.3 or higher. See <https://github.com/esphome/issues/issues/4271>."
|
||||||
|
)
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
CONFIG_SCHEMA = cv.All(
|
CONFIG_SCHEMA = cv.All(
|
||||||
sensor.sensor_schema(
|
sensor.sensor_schema(
|
||||||
InternalTemperatureSensor,
|
InternalTemperatureSensor,
|
||||||
|
@ -23,6 +50,7 @@ CONFIG_SCHEMA = cv.All(
|
||||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
).extend(cv.polling_component_schema("60s")),
|
).extend(cv.polling_component_schema("60s")),
|
||||||
cv.only_on(["esp32", "rp2040"]),
|
cv.only_on(["esp32", "rp2040"]),
|
||||||
|
validate_config,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue