mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 09:01:49 +00:00 
			
		
		
		
	Compare commits
	
		
			14 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					b8c27bc17d | ||
| 
						 | 
					1057ac4db7 | ||
| 
						 | 
					69f5674d9e | ||
| 
						 | 
					b723728177 | ||
| 
						 | 
					316171491f | ||
| 
						 | 
					91ff502872 | ||
| 
						 | 
					6e414180e0 | ||
| 
						 | 
					7d2ae4e252 | ||
| 
						 | 
					fb4cb07c6f | ||
| 
						 | 
					19f91a7deb | ||
| 
						 | 
					3807350c61 | ||
| 
						 | 
					9d2467cf62 | ||
| 
						 | 
					d2480d3194 | ||
| 
						 | 
					148eb03d13 | 
@@ -932,6 +932,8 @@ def run_esphome(argv):
 | 
				
			|||||||
            _LOGGER.error(e, exc_info=args.verbose)
 | 
					            _LOGGER.error(e, exc_info=args.verbose)
 | 
				
			||||||
            return 1
 | 
					            return 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _LOGGER.info("ESPHome %s", const.__version__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for conf_path in args.configuration:
 | 
					    for conf_path in args.configuration:
 | 
				
			||||||
        if any(os.path.basename(conf_path) == x for x in SECRETS_FILES):
 | 
					        if any(os.path.basename(conf_path) == x for x in SECRETS_FILES):
 | 
				
			||||||
            _LOGGER.warning("Skipping secrets file %s", conf_path)
 | 
					            _LOGGER.warning("Skipping secrets file %s", conf_path)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -140,8 +140,9 @@ class Cover : public EntityBase, public EntityBase_DeviceClass {
 | 
				
			|||||||
  /** Stop the cover.
 | 
					  /** Stop the cover.
 | 
				
			||||||
   *
 | 
					   *
 | 
				
			||||||
   * This is a legacy method and may be removed later, please use `.make_call()` instead.
 | 
					   * This is a legacy method and may be removed later, please use `.make_call()` instead.
 | 
				
			||||||
 | 
					   * As per solution from issue #2885 the call should include perform()
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  ESPDEPRECATED("stop() is deprecated, use make_call().set_command_stop() instead.", "2021.9")
 | 
					  ESPDEPRECATED("stop() is deprecated, use make_call().set_command_stop().perform() instead.", "2021.9")
 | 
				
			||||||
  void stop();
 | 
					  void stop();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void add_on_state_callback(std::function<void()> &&f);
 | 
					  void add_on_state_callback(std::function<void()> &&f);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,7 +34,7 @@ class ESP32RMTLEDStripLightOutput : public light::AddressableLight {
 | 
				
			|||||||
  light::LightTraits get_traits() override {
 | 
					  light::LightTraits get_traits() override {
 | 
				
			||||||
    auto traits = light::LightTraits();
 | 
					    auto traits = light::LightTraits();
 | 
				
			||||||
    if (this->is_rgbw_) {
 | 
					    if (this->is_rgbw_) {
 | 
				
			||||||
      traits.set_supported_color_modes({light::ColorMode::RGB, light::ColorMode::RGB_WHITE});
 | 
					      traits.set_supported_color_modes({light::ColorMode::RGB_WHITE, light::ColorMode::WHITE});
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      traits.set_supported_color_modes({light::ColorMode::RGB});
 | 
					      traits.set_supported_color_modes({light::ColorMode::RGB});
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@ import esphome.config_validation as cv
 | 
				
			|||||||
import esphome.codegen as cg
 | 
					import esphome.codegen as cg
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from esphome import pins
 | 
					from esphome import pins
 | 
				
			||||||
from esphome.const import CONF_ID, CONF_NUMBER
 | 
					from esphome.const import CONF_CHANNEL, CONF_ID, CONF_NUMBER
 | 
				
			||||||
from esphome.components import microphone, esp32
 | 
					from esphome.components import microphone, esp32
 | 
				
			||||||
from esphome.components.adc import ESP32_VARIANT_ADC1_PIN_TO_CHANNEL, validate_adc_pin
 | 
					from esphome.components.adc import ESP32_VARIANT_ADC1_PIN_TO_CHANNEL, validate_adc_pin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -25,6 +25,12 @@ I2SAudioMicrophone = i2s_audio_ns.class_(
 | 
				
			|||||||
    "I2SAudioMicrophone", I2SAudioIn, microphone.Microphone, cg.Component
 | 
					    "I2SAudioMicrophone", I2SAudioIn, microphone.Microphone, cg.Component
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					i2s_channel_fmt_t = cg.global_ns.enum("i2s_channel_fmt_t")
 | 
				
			||||||
 | 
					CHANNELS = {
 | 
				
			||||||
 | 
					    "left": i2s_channel_fmt_t.I2S_CHANNEL_FMT_ONLY_LEFT,
 | 
				
			||||||
 | 
					    "right": i2s_channel_fmt_t.I2S_CHANNEL_FMT_ONLY_RIGHT,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
INTERNAL_ADC_VARIANTS = [esp32.const.VARIANT_ESP32]
 | 
					INTERNAL_ADC_VARIANTS = [esp32.const.VARIANT_ESP32]
 | 
				
			||||||
PDM_VARIANTS = [esp32.const.VARIANT_ESP32, esp32.const.VARIANT_ESP32S3]
 | 
					PDM_VARIANTS = [esp32.const.VARIANT_ESP32, esp32.const.VARIANT_ESP32S3]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -47,6 +53,7 @@ BASE_SCHEMA = microphone.MICROPHONE_SCHEMA.extend(
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        cv.GenerateID(): cv.declare_id(I2SAudioMicrophone),
 | 
					        cv.GenerateID(): cv.declare_id(I2SAudioMicrophone),
 | 
				
			||||||
        cv.GenerateID(CONF_I2S_AUDIO_ID): cv.use_id(I2SAudioComponent),
 | 
					        cv.GenerateID(CONF_I2S_AUDIO_ID): cv.use_id(I2SAudioComponent),
 | 
				
			||||||
 | 
					        cv.Optional(CONF_CHANNEL, default="right"): cv.enum(CHANNELS),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
).extend(cv.COMPONENT_SCHEMA)
 | 
					).extend(cv.COMPONENT_SCHEMA)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -86,4 +93,6 @@ async def to_code(config):
 | 
				
			|||||||
        cg.add(var.set_din_pin(config[CONF_I2S_DIN_PIN]))
 | 
					        cg.add(var.set_din_pin(config[CONF_I2S_DIN_PIN]))
 | 
				
			||||||
        cg.add(var.set_pdm(config[CONF_PDM]))
 | 
					        cg.add(var.set_pdm(config[CONF_PDM]))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    cg.add(var.set_channel(CHANNELS[config[CONF_CHANNEL]]))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    await microphone.register_microphone(var, config)
 | 
					    await microphone.register_microphone(var, config)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,7 +49,7 @@ void I2SAudioMicrophone::start_() {
 | 
				
			|||||||
      .mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_RX),
 | 
					      .mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_RX),
 | 
				
			||||||
      .sample_rate = 16000,
 | 
					      .sample_rate = 16000,
 | 
				
			||||||
      .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
 | 
					      .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
 | 
				
			||||||
      .channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT,
 | 
					      .channel_format = this->channel_,
 | 
				
			||||||
      .communication_format = I2S_COMM_FORMAT_STAND_I2S,
 | 
					      .communication_format = I2S_COMM_FORMAT_STAND_I2S,
 | 
				
			||||||
      .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
 | 
					      .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
 | 
				
			||||||
      .dma_buf_count = 4,
 | 
					      .dma_buf_count = 4,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,8 @@ class I2SAudioMicrophone : public I2SAudioIn, public microphone::Microphone, pub
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void set_channel(i2s_channel_fmt_t channel) { this->channel_ = channel; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 protected:
 | 
					 protected:
 | 
				
			||||||
  void start_();
 | 
					  void start_();
 | 
				
			||||||
  void stop_();
 | 
					  void stop_();
 | 
				
			||||||
@@ -40,6 +42,7 @@ class I2SAudioMicrophone : public I2SAudioIn, public microphone::Microphone, pub
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
  bool pdm_{false};
 | 
					  bool pdm_{false};
 | 
				
			||||||
  std::vector<uint8_t> buffer_;
 | 
					  std::vector<uint8_t> buffer_;
 | 
				
			||||||
 | 
					  i2s_channel_fmt_t channel_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  HighFrequencyLoopRequester high_freq_;
 | 
					  HighFrequencyLoopRequester high_freq_;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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,
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -506,12 +506,12 @@ void number_to_payload(std::vector<uint16_t> &data, int64_t value, SensorValueTy
 | 
				
			|||||||
    case SensorValueType::U_DWORD:
 | 
					    case SensorValueType::U_DWORD:
 | 
				
			||||||
    case SensorValueType::S_DWORD:
 | 
					    case SensorValueType::S_DWORD:
 | 
				
			||||||
    case SensorValueType::FP32:
 | 
					    case SensorValueType::FP32:
 | 
				
			||||||
    case SensorValueType::FP32_R:
 | 
					 | 
				
			||||||
      data.push_back((value & 0xFFFF0000) >> 16);
 | 
					      data.push_back((value & 0xFFFF0000) >> 16);
 | 
				
			||||||
      data.push_back(value & 0xFFFF);
 | 
					      data.push_back(value & 0xFFFF);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
    case SensorValueType::U_DWORD_R:
 | 
					    case SensorValueType::U_DWORD_R:
 | 
				
			||||||
    case SensorValueType::S_DWORD_R:
 | 
					    case SensorValueType::S_DWORD_R:
 | 
				
			||||||
 | 
					    case SensorValueType::FP32_R:
 | 
				
			||||||
      data.push_back(value & 0xFFFF);
 | 
					      data.push_back(value & 0xFFFF);
 | 
				
			||||||
      data.push_back((value & 0xFFFF0000) >> 16);
 | 
					      data.push_back((value & 0xFFFF0000) >> 16);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,7 +21,7 @@ void PsramComponent::dump_config() {
 | 
				
			|||||||
  ESP_LOGCONFIG(TAG, "  Available: %s", YESNO(available));
 | 
					  ESP_LOGCONFIG(TAG, "  Available: %s", YESNO(available));
 | 
				
			||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 1, 0)
 | 
					#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 1, 0)
 | 
				
			||||||
  if (available) {
 | 
					  if (available) {
 | 
				
			||||||
    ESP_LOGCONFIG(TAG, "  Size: %d MB", heap_caps_get_total_size(MALLOC_CAP_SPIRAM) / 1024 / 1024);
 | 
					    ESP_LOGCONFIG(TAG, "  Size: %d KB", heap_caps_get_total_size(MALLOC_CAP_SPIRAM) / 1024);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
"""Constants used by esphome."""
 | 
					"""Constants used by esphome."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__version__ = "2023.5.2"
 | 
					__version__ = "2023.5.5"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
 | 
					ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user