From 04dc0ed12952f71831c74b5c67c416156a0e2d51 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Wed, 12 Mar 2025 01:11:50 -0500 Subject: [PATCH 01/88] Bump version to 2025.4.0-dev --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 11494a0975..f3fda8f1d6 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.3.0-dev" +__version__ = "2025.4.0-dev" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = ( From 35199c9b96869213a2be8f2c11a4fe2f98d9c4cf Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 12 Mar 2025 09:18:21 -1000 Subject: [PATCH 02/88] Bump mdns library to 1.8.0 (#8378) Co-authored-by: Keith Burzinski --- esphome/components/mdns/__init__.py | 2 +- esphome/idf_component.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/mdns/__init__.py b/esphome/components/mdns/__init__.py index 1bc290b582..9a198280dd 100644 --- a/esphome/components/mdns/__init__.py +++ b/esphome/components/mdns/__init__.py @@ -91,7 +91,7 @@ async def to_code(config): add_idf_component( name="mdns", repo="https://github.com/espressif/esp-protocols.git", - ref="mdns-v1.5.1", + ref="mdns-v1.8.0", path="components/mdns", ) diff --git a/esphome/idf_component.yml b/esphome/idf_component.yml index bd5bcda2fe..32ba414ba3 100644 --- a/esphome/idf_component.yml +++ b/esphome/idf_component.yml @@ -7,7 +7,7 @@ dependencies: version: v2.0.9 mdns: git: https://github.com/espressif/esp-protocols.git - version: mdns-v1.5.1 + version: mdns-v1.8.0 path: components/mdns rules: - if: "idf_version >=5.0" From 266c2ef337fa5e683c6576180c6f162f743addac Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Wed, 12 Mar 2025 14:18:31 -0500 Subject: [PATCH 03/88] [audio, mixer] Memory and CPU performance improvements (#8387) --- esphome/components/audio/__init__.py | 2 +- esphome/components/audio/audio_decoder.cpp | 54 +++++++++++++++---- esphome/components/audio/audio_reader.cpp | 4 +- esphome/components/audio/audio_resampler.cpp | 6 ++- .../audio/audio_transfer_buffer.cpp | 28 ++++++---- .../components/audio/audio_transfer_buffer.h | 9 +++- .../mixer/speaker/mixer_speaker.cpp | 3 +- platformio.ini | 4 +- 8 files changed, 80 insertions(+), 30 deletions(-) diff --git a/esphome/components/audio/__init__.py b/esphome/components/audio/__init__.py index 31d3c39ffa..c5ef781060 100644 --- a/esphome/components/audio/__init__.py +++ b/esphome/components/audio/__init__.py @@ -118,4 +118,4 @@ def final_validate_audio_schema( async def to_code(config): - cg.add_library("esphome/esp-audio-libs", "1.1.1") + cg.add_library("esphome/esp-audio-libs", "1.1.2") diff --git a/esphome/components/audio/audio_decoder.cpp b/esphome/components/audio/audio_decoder.cpp index ab358ad805..60489d7d78 100644 --- a/esphome/components/audio/audio_decoder.cpp +++ b/esphome/components/audio/audio_decoder.cpp @@ -66,19 +66,30 @@ esp_err_t AudioDecoder::start(AudioFileType audio_file_type) { case AudioFileType::FLAC: this->flac_decoder_ = make_unique(); this->free_buffer_required_ = - this->output_transfer_buffer_->capacity(); // We'll revise this after reading the header + this->output_transfer_buffer_->capacity(); // Adjusted and reallocated after reading the header break; #endif #ifdef USE_AUDIO_MP3_SUPPORT case AudioFileType::MP3: this->mp3_decoder_ = esp_audio_libs::helix_decoder::MP3InitDecoder(); + + // MP3 always has 1152 samples per chunk this->free_buffer_required_ = 1152 * sizeof(int16_t) * 2; // samples * size per sample * channels + + // Always reallocate the output transfer buffer to the smallest necessary size + this->output_transfer_buffer_->reallocate(this->free_buffer_required_); break; #endif case AudioFileType::WAV: this->wav_decoder_ = make_unique(); this->wav_decoder_->reset(); + + // Processing WAVs doesn't actually require a specific amount of buffer size, as it is already in PCM format. + // Thus, we don't reallocate to a minimum size. this->free_buffer_required_ = 1024; + if (this->output_transfer_buffer_->capacity() < this->free_buffer_required_) { + this->output_transfer_buffer_->reallocate(this->free_buffer_required_); + } break; case AudioFileType::NONE: default: @@ -116,10 +127,18 @@ AudioDecoderState AudioDecoder::decode(bool stop_gracefully) { uint32_t decoding_start = millis(); + bool first_loop_iteration = true; + + size_t bytes_processed = 0; + size_t bytes_available_before_processing = 0; + while (state == FileDecoderState::MORE_TO_PROCESS) { // Transfer decoded out if (!this->pause_output_) { - size_t bytes_written = this->output_transfer_buffer_->transfer_data_to_sink(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS)); + // Never shift the data in the output transfer buffer to avoid unnecessary, slow data moves + size_t bytes_written = + this->output_transfer_buffer_->transfer_data_to_sink(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS), false); + if (this->audio_stream_info_.has_value()) { this->accumulated_frames_written_ += this->audio_stream_info_.value().bytes_to_frames(bytes_written); this->playback_ms_ += @@ -138,12 +157,24 @@ AudioDecoderState AudioDecoder::decode(bool stop_gracefully) { // Decode more audio - size_t bytes_read = this->input_transfer_buffer_->transfer_data_from_source(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS)); + // Only shift data on the first loop iteration to avoid unnecessary, slow moves + size_t bytes_read = this->input_transfer_buffer_->transfer_data_from_source(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS), + first_loop_iteration); - if ((this->potentially_failed_count_ > 0) && (bytes_read == 0)) { + if (!first_loop_iteration && (this->input_transfer_buffer_->available() < bytes_processed)) { + // Less data is available than what was processed in last iteration, so don't attempt to decode. + // This attempts to avoid the decoder from consistently trying to decode an incomplete frame. The transfer buffer + // will shift the remaining data to the start and copy more from the source the next time the decode function is + // called + break; + } + + bytes_available_before_processing = this->input_transfer_buffer_->available(); + + if ((this->potentially_failed_count_ > 10) && (bytes_read == 0)) { // Failed to decode in last attempt and there is no new data - if (this->input_transfer_buffer_->free() == 0) { + if ((this->input_transfer_buffer_->free() == 0) && first_loop_iteration) { // The input buffer is full. Since it previously failed on the exact same data, we can never recover state = FileDecoderState::FAILED; } else { @@ -175,6 +206,9 @@ AudioDecoderState AudioDecoder::decode(bool stop_gracefully) { } } + first_loop_iteration = false; + bytes_processed = bytes_available_before_processing - this->input_transfer_buffer_->available(); + if (state == FileDecoderState::POTENTIALLY_FAILED) { ++this->potentially_failed_count_; } else if (state == FileDecoderState::END_OF_FILE) { @@ -207,13 +241,11 @@ FileDecoderState AudioDecoder::decode_flac_() { size_t bytes_consumed = this->flac_decoder_->get_bytes_index(); this->input_transfer_buffer_->decrease_buffer_length(bytes_consumed); + // Reallocate the output transfer buffer to the smallest necessary size this->free_buffer_required_ = flac_decoder_->get_output_buffer_size_bytes(); - if (this->output_transfer_buffer_->capacity() < this->free_buffer_required_) { - // Output buffer is not big enough - if (!this->output_transfer_buffer_->reallocate(this->free_buffer_required_)) { - // Couldn't reallocate output buffer - return FileDecoderState::FAILED; - } + if (!this->output_transfer_buffer_->reallocate(this->free_buffer_required_)) { + // Couldn't reallocate output buffer + return FileDecoderState::FAILED; } this->audio_stream_info_ = diff --git a/esphome/components/audio/audio_reader.cpp b/esphome/components/audio/audio_reader.cpp index 90b73a1f46..b82c6db9ee 100644 --- a/esphome/components/audio/audio_reader.cpp +++ b/esphome/components/audio/audio_reader.cpp @@ -259,14 +259,14 @@ AudioReaderState AudioReader::file_read_() { } AudioReaderState AudioReader::http_read_() { - this->output_transfer_buffer_->transfer_data_to_sink(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS)); + this->output_transfer_buffer_->transfer_data_to_sink(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS), false); if (esp_http_client_is_complete_data_received(this->client_)) { if (this->output_transfer_buffer_->available() == 0) { this->cleanup_connection_(); return AudioReaderState::FINISHED; } - } else { + } else if (this->output_transfer_buffer_->free() > 0) { size_t bytes_to_read = this->output_transfer_buffer_->free(); int received_len = esp_http_client_read(this->client_, (char *) this->output_transfer_buffer_->get_buffer_end(), bytes_to_read); diff --git a/esphome/components/audio/audio_resampler.cpp b/esphome/components/audio/audio_resampler.cpp index 05e9ff6ca1..a7621225a1 100644 --- a/esphome/components/audio/audio_resampler.cpp +++ b/esphome/components/audio/audio_resampler.cpp @@ -93,8 +93,9 @@ AudioResamplerState AudioResampler::resample(bool stop_gracefully, int32_t *ms_d } if (!this->pause_output_) { - // Move audio data to the sink - this->output_transfer_buffer_->transfer_data_to_sink(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS)); + // Move audio data to the sink without shifting the data in the output transfer buffer to avoid unnecessary, slow + // data moves + this->output_transfer_buffer_->transfer_data_to_sink(pdMS_TO_TICKS(READ_WRITE_TIMEOUT_MS), false); } else { // If paused, block to avoid wasting CPU resources delay(READ_WRITE_TIMEOUT_MS); @@ -115,6 +116,7 @@ AudioResamplerState AudioResampler::resample(bool stop_gracefully, int32_t *ms_d if ((this->input_stream_info_.get_sample_rate() != this->output_stream_info_.get_sample_rate()) || (this->input_stream_info_.get_bits_per_sample() != this->output_stream_info_.get_bits_per_sample())) { + // Adjust gain by -3 dB to avoid clipping due to the resampling process esp_audio_libs::resampler::ResamplerResults results = this->resampler_->resample(this->input_transfer_buffer_->get_buffer_start(), this->output_transfer_buffer_->get_buffer_end(), frames_available, frames_free, -3); diff --git a/esphome/components/audio/audio_transfer_buffer.cpp b/esphome/components/audio/audio_transfer_buffer.cpp index 9b6067aac4..1566884c3d 100644 --- a/esphome/components/audio/audio_transfer_buffer.cpp +++ b/esphome/components/audio/audio_transfer_buffer.cpp @@ -33,12 +33,17 @@ size_t AudioTransferBuffer::free() const { if (this->buffer_size_ == 0) { return 0; } - return this->buffer_size_ - (this->buffer_length_ - (this->data_start_ - this->buffer_)); + return this->buffer_size_ - (this->buffer_length_ + (this->data_start_ - this->buffer_)); } void AudioTransferBuffer::decrease_buffer_length(size_t bytes) { this->buffer_length_ -= bytes; - this->data_start_ += bytes; + if (this->buffer_length_ > 0) { + this->data_start_ += bytes; + } else { + // All the data in the buffer has been consumed, reset the start pointer + this->data_start_ = this->buffer_; + } } void AudioTransferBuffer::increase_buffer_length(size_t bytes) { this->buffer_length_ += bytes; } @@ -71,7 +76,7 @@ bool AudioTransferBuffer::has_buffered_data() const { bool AudioTransferBuffer::reallocate(size_t new_buffer_size) { if (this->buffer_length_ > 0) { - // Already has data in the buffer, fail + // Buffer currently has data, so reallocation is impossible return false; } this->deallocate_buffer_(); @@ -106,12 +111,14 @@ void AudioTransferBuffer::deallocate_buffer_() { this->buffer_length_ = 0; } -size_t AudioSourceTransferBuffer::transfer_data_from_source(TickType_t ticks_to_wait) { - // Shift data in buffer to start - if (this->buffer_length_ > 0) { - memmove(this->buffer_, this->data_start_, this->buffer_length_); +size_t AudioSourceTransferBuffer::transfer_data_from_source(TickType_t ticks_to_wait, bool pre_shift) { + if (pre_shift) { + // Shift data in buffer to start + if (this->buffer_length_ > 0) { + memmove(this->buffer_, this->data_start_, this->buffer_length_); + } + this->data_start_ = this->buffer_; } - this->data_start_ = this->buffer_; size_t bytes_to_read = this->free(); size_t bytes_read = 0; @@ -125,7 +132,7 @@ size_t AudioSourceTransferBuffer::transfer_data_from_source(TickType_t ticks_to_ return bytes_read; } -size_t AudioSinkTransferBuffer::transfer_data_to_sink(TickType_t ticks_to_wait) { +size_t AudioSinkTransferBuffer::transfer_data_to_sink(TickType_t ticks_to_wait, bool post_shift) { size_t bytes_written = 0; if (this->available()) { #ifdef USE_SPEAKER @@ -139,11 +146,14 @@ size_t AudioSinkTransferBuffer::transfer_data_to_sink(TickType_t ticks_to_wait) } this->decrease_buffer_length(bytes_written); + } + if (post_shift) { // Shift unwritten data to the start of the buffer memmove(this->buffer_, this->data_start_, this->buffer_length_); this->data_start_ = this->buffer_; } + return bytes_written; } diff --git a/esphome/components/audio/audio_transfer_buffer.h b/esphome/components/audio/audio_transfer_buffer.h index 4e461db56d..edb484e7d2 100644 --- a/esphome/components/audio/audio_transfer_buffer.h +++ b/esphome/components/audio/audio_transfer_buffer.h @@ -60,6 +60,7 @@ class AudioTransferBuffer { protected: /// @brief Allocates the transfer buffer in external memory, if available. + /// @param buffer_size The number of bytes to allocate /// @return True is successful, false otherwise. bool allocate_buffer_(size_t buffer_size); @@ -89,8 +90,10 @@ class AudioSinkTransferBuffer : public AudioTransferBuffer { /// @brief Writes any available data in the transfer buffer to the sink. /// @param ticks_to_wait FreeRTOS ticks to block while waiting for the sink to have enough space + /// @param post_shift If true, all remaining data is moved to the start of the buffer after transferring to the sink. + /// Defaults to true. /// @return Number of bytes written - size_t transfer_data_to_sink(TickType_t ticks_to_wait); + size_t transfer_data_to_sink(TickType_t ticks_to_wait, bool post_shift = true); /// @brief Adds a ring buffer as the transfer buffer's sink. /// @param ring_buffer weak_ptr to the allocated ring buffer @@ -125,8 +128,10 @@ class AudioSourceTransferBuffer : public AudioTransferBuffer { /// @brief Reads any available data from the sink into the transfer buffer. /// @param ticks_to_wait FreeRTOS ticks to block while waiting for the source to have enough data + /// @param pre_shift If true, any unwritten data is moved to the start of the buffer before transferring from the + /// source. Defaults to true. /// @return Number of bytes read - size_t transfer_data_from_source(TickType_t ticks_to_wait); + size_t transfer_data_from_source(TickType_t ticks_to_wait, bool pre_shift = true); /// @brief Adds a ring buffer as the transfer buffer's source. /// @param ring_buffer weak_ptr to the allocated ring buffer diff --git a/esphome/components/mixer/speaker/mixer_speaker.cpp b/esphome/components/mixer/speaker/mixer_speaker.cpp index 60cff95eb2..d9231154a3 100644 --- a/esphome/components/mixer/speaker/mixer_speaker.cpp +++ b/esphome/components/mixer/speaker/mixer_speaker.cpp @@ -490,7 +490,8 @@ void MixerSpeaker::audio_mixer_task(void *params) { break; } - output_transfer_buffer->transfer_data_to_sink(pdMS_TO_TICKS(TASK_DELAY_MS)); + // Never shift the data in the output transfer buffer to avoid unnecessary, slow data moves + output_transfer_buffer->transfer_data_to_sink(pdMS_TO_TICKS(TASK_DELAY_MS), false); const uint32_t output_frames_free = this_mixer->audio_stream_info_.value().bytes_to_frames(output_transfer_buffer->free()); diff --git a/platformio.ini b/platformio.ini index fab7fda659..a2c2a74ac0 100644 --- a/platformio.ini +++ b/platformio.ini @@ -128,7 +128,7 @@ lib_deps = DNSServer ; captive_portal (Arduino built-in) esphome/ESP32-audioI2S@2.0.7 ; i2s_audio droscy/esp_wireguard@0.4.2 ; wireguard - esphome/esp-audio-libs@1.1.1 ; audio + esphome/esp-audio-libs@1.1.2 ; audio build_flags = ${common:arduino.build_flags} @@ -149,7 +149,7 @@ lib_deps = ${common:idf.lib_deps} droscy/esp_wireguard@0.4.2 ; wireguard kahrendt/ESPMicroSpeechFeatures@1.1.0 ; micro_wake_word - esphome/esp-audio-libs@1.1.1 ; audio + esphome/esp-audio-libs@1.1.2 ; audio build_flags = ${common:idf.build_flags} -Wno-nonnull-compare From 64d1d93fe085dc2bc7a555e97aed8fb95c5ed554 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Wed, 12 Mar 2025 14:34:38 -0500 Subject: [PATCH 04/88] [speaker, resampler, mixer] Make volume and mute getters virtual (#8391) --- esphome/components/mixer/speaker/mixer_speaker.cpp | 4 ++++ esphome/components/mixer/speaker/mixer_speaker.h | 2 ++ esphome/components/resampler/speaker/resampler_speaker.h | 2 ++ esphome/components/speaker/speaker.h | 4 ++-- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/esphome/components/mixer/speaker/mixer_speaker.cpp b/esphome/components/mixer/speaker/mixer_speaker.cpp index d9231154a3..121a62392c 100644 --- a/esphome/components/mixer/speaker/mixer_speaker.cpp +++ b/esphome/components/mixer/speaker/mixer_speaker.cpp @@ -177,11 +177,15 @@ void SourceSpeaker::set_mute_state(bool mute_state) { this->parent_->get_output_speaker()->set_mute_state(mute_state); } +bool SourceSpeaker::get_mute_state() { return this->parent_->get_output_speaker()->get_mute_state(); } + void SourceSpeaker::set_volume(float volume) { this->volume_ = volume; this->parent_->get_output_speaker()->set_volume(volume); } +float SourceSpeaker::get_volume() { return this->parent_->get_output_speaker()->get_volume(); } + size_t SourceSpeaker::process_data_from_source(TickType_t ticks_to_wait) { if (!this->transfer_buffer_.use_count()) { return 0; diff --git a/esphome/components/mixer/speaker/mixer_speaker.h b/esphome/components/mixer/speaker/mixer_speaker.h index b2cb3e1e39..0bd6b5f4c8 100644 --- a/esphome/components/mixer/speaker/mixer_speaker.h +++ b/esphome/components/mixer/speaker/mixer_speaker.h @@ -53,9 +53,11 @@ class SourceSpeaker : public speaker::Speaker, public Component { /// @brief Mute state changes are passed to the parent's output speaker void set_mute_state(bool mute_state) override; + bool get_mute_state() override; /// @brief Volume state changes are passed to the parent's output speaker void set_volume(float volume) override; + float get_volume() override; void set_pause_state(bool pause_state) override { this->pause_state_ = pause_state; } bool get_pause_state() const override { return this->pause_state_; } diff --git a/esphome/components/resampler/speaker/resampler_speaker.h b/esphome/components/resampler/speaker/resampler_speaker.h index c44f740fa2..d5e3f2b6d6 100644 --- a/esphome/components/resampler/speaker/resampler_speaker.h +++ b/esphome/components/resampler/speaker/resampler_speaker.h @@ -34,9 +34,11 @@ class ResamplerSpeaker : public Component, public speaker::Speaker { /// @brief Mute state changes are passed to the parent's output speaker void set_mute_state(bool mute_state) override; + bool get_mute_state() override { return this->output_speaker_->get_mute_state(); } /// @brief Volume state changes are passed to the parent's output speaker void set_volume(float volume) override; + float get_volume() override { return this->output_speaker_->get_volume(); } void set_output_speaker(speaker::Speaker *speaker) { this->output_speaker_ = speaker; } void set_task_stack_in_psram(bool task_stack_in_psram) { this->task_stack_in_psram_ = task_stack_in_psram; } diff --git a/esphome/components/speaker/speaker.h b/esphome/components/speaker/speaker.h index 74c4822eca..c4cf912fa6 100644 --- a/esphome/components/speaker/speaker.h +++ b/esphome/components/speaker/speaker.h @@ -76,7 +76,7 @@ class Speaker { } #endif }; - float get_volume() { return this->volume_; } + virtual float get_volume() { return this->volume_; } virtual void set_mute_state(bool mute_state) { this->mute_state_ = mute_state; @@ -90,7 +90,7 @@ class Speaker { } #endif } - bool get_mute_state() { return this->mute_state_; } + virtual bool get_mute_state() { return this->mute_state_; } #ifdef USE_AUDIO_DAC void set_audio_dac(audio_dac::AudioDac *audio_dac) { this->audio_dac_ = audio_dac; } From bd853e6883d5d7897cd916abbbb3ebc4bc0d0c61 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Wed, 12 Mar 2025 15:04:05 -0500 Subject: [PATCH 05/88] [core] add reallocation support to RAMAllocator (#8390) --- esphome/core/helpers.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/esphome/core/helpers.h b/esphome/core/helpers.h index 3f371cd829..7866eaa9bd 100644 --- a/esphome/core/helpers.h +++ b/esphome/core/helpers.h @@ -719,6 +719,25 @@ template class RAMAllocator { return ptr; } + T *reallocate(T *p, size_t n) { return this->reallocate(p, n, sizeof(T)); } + + T *reallocate(T *p, size_t n, size_t manual_size) { + size_t size = n * sizeof(T); + T *ptr = nullptr; +#ifdef USE_ESP32 + if (this->flags_ & Flags::ALLOC_EXTERNAL) { + ptr = static_cast(heap_caps_realloc(p, size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT)); + } + if (ptr == nullptr && this->flags_ & Flags::ALLOC_INTERNAL) { + ptr = static_cast(heap_caps_realloc(p, size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)); + } +#else + // Ignore ALLOC_EXTERNAL/ALLOC_INTERNAL flags if external allocation is not supported + ptr = static_cast(realloc(p, size)); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc) +#endif + return ptr; + } + void deallocate(T *p, size_t n) { free(p); // NOLINT(cppcoreguidelines-owning-memory,cppcoreguidelines-no-malloc) } From 00000e0ea813ab1bf3a0ef8eb5f0a2445d7621ad Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Wed, 12 Mar 2025 19:35:10 -0500 Subject: [PATCH 06/88] [api] add voice assistant announce to the api (#8395) --- esphome/components/api/api.proto | 2 ++ esphome/components/api/api_pb2.cpp | 24 ++++++++++++++++++++++++ esphome/components/api/api_pb2.h | 3 +++ 3 files changed, 29 insertions(+) diff --git a/esphome/components/api/api.proto b/esphome/components/api/api.proto index 8b7fdf8b11..d59b5e0d3e 100644 --- a/esphome/components/api/api.proto +++ b/esphome/components/api/api.proto @@ -1567,6 +1567,8 @@ message VoiceAssistantAnnounceRequest { string media_id = 1; string text = 2; + string preannounce_media_id = 3; + bool start_conversation = 4; } message VoiceAssistantAnnounceFinished { diff --git a/esphome/components/api/api_pb2.cpp b/esphome/components/api/api_pb2.cpp index 771f029eae..8001a74b6d 100644 --- a/esphome/components/api/api_pb2.cpp +++ b/esphome/components/api/api_pb2.cpp @@ -7094,6 +7094,16 @@ void VoiceAssistantTimerEventResponse::dump_to(std::string &out) const { out.append("}"); } #endif +bool VoiceAssistantAnnounceRequest::decode_varint(uint32_t field_id, ProtoVarInt value) { + switch (field_id) { + case 4: { + this->start_conversation = value.as_bool(); + return true; + } + default: + return false; + } +} bool VoiceAssistantAnnounceRequest::decode_length(uint32_t field_id, ProtoLengthDelimited value) { switch (field_id) { case 1: { @@ -7104,6 +7114,10 @@ bool VoiceAssistantAnnounceRequest::decode_length(uint32_t field_id, ProtoLength this->text = value.as_string(); return true; } + case 3: { + this->preannounce_media_id = value.as_string(); + return true; + } default: return false; } @@ -7111,6 +7125,8 @@ bool VoiceAssistantAnnounceRequest::decode_length(uint32_t field_id, ProtoLength void VoiceAssistantAnnounceRequest::encode(ProtoWriteBuffer buffer) const { buffer.encode_string(1, this->media_id); buffer.encode_string(2, this->text); + buffer.encode_string(3, this->preannounce_media_id); + buffer.encode_bool(4, this->start_conversation); } #ifdef HAS_PROTO_MESSAGE_DUMP void VoiceAssistantAnnounceRequest::dump_to(std::string &out) const { @@ -7123,6 +7139,14 @@ void VoiceAssistantAnnounceRequest::dump_to(std::string &out) const { out.append(" text: "); out.append("'").append(this->text).append("'"); out.append("\n"); + + out.append(" preannounce_media_id: "); + out.append("'").append(this->preannounce_media_id).append("'"); + out.append("\n"); + + out.append(" start_conversation: "); + out.append(YESNO(this->start_conversation)); + out.append("\n"); out.append("}"); } #endif diff --git a/esphome/components/api/api_pb2.h b/esphome/components/api/api_pb2.h index 1f96e2c151..455e3ff6cf 100644 --- a/esphome/components/api/api_pb2.h +++ b/esphome/components/api/api_pb2.h @@ -1832,6 +1832,8 @@ class VoiceAssistantAnnounceRequest : public ProtoMessage { public: std::string media_id{}; std::string text{}; + std::string preannounce_media_id{}; + bool start_conversation{false}; void encode(ProtoWriteBuffer buffer) const override; #ifdef HAS_PROTO_MESSAGE_DUMP void dump_to(std::string &out) const override; @@ -1839,6 +1841,7 @@ class VoiceAssistantAnnounceRequest : public ProtoMessage { protected: bool decode_length(uint32_t field_id, ProtoLengthDelimited value) override; + bool decode_varint(uint32_t field_id, ProtoVarInt value) override; }; class VoiceAssistantAnnounceFinished : public ProtoMessage { public: From f9a0a6329081d00b611ad1549bb90243c1c821ad Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 12 Mar 2025 15:00:31 -1000 Subject: [PATCH 07/88] Bump aioesphomeapi to 29.6.0 (#8396) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index a7e322ab6b..bb5b5d7d87 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ platformio==6.1.16 # When updating platformio, also update Dockerfile esptool==4.8.1 click==8.1.7 esphome-dashboard==20250212.0 -aioesphomeapi==29.5.1 +aioesphomeapi==29.6.0 zeroconf==0.146.1 puremagic==1.27 ruamel.yaml==0.18.6 # dashboard_import From 59d282489a273ae956c0550f1714af222f15571a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 12 Mar 2025 15:16:59 -1000 Subject: [PATCH 08/88] Rework pyproject.toml to make it parseable by dependabot (#8397) --- pyproject.toml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5cdf4a77b5..69b36cd14a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,11 +43,13 @@ include-package-data = true [tool.setuptools.dynamic] dependencies = {file = ["requirements.txt"]} -optional-dependencies.dev = { file = ["requirements_dev.txt"] } -optional-dependencies.test = { file = ["requirements_test.txt"] } -optional-dependencies.displays = { file = ["requirements_optional.txt"] } version = {attr = "esphome.const.__version__"} +[tool.setuptools.dynamic.optional-dependencies] +dev = { file = ["requirements_dev.txt"] } +test = { file = ["requirements_test.txt"] } +displays = { file = ["requirements_optional.txt"] } + [tool.setuptools.packages.find] include = ["esphome*"] From 7d8c39d29512ae359f63ddc78d6d0fe876904e1b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 12 Mar 2025 18:21:45 -1000 Subject: [PATCH 09/88] Bump cryptography to 44.0.2 (#8399) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index bb5b5d7d87..ba4a1d6b2e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ async_timeout==4.0.3; python_version <= "3.10" -cryptography==43.0.0 +cryptography==44.0.2 voluptuous==0.14.2 PyYAML==6.0.2 paho-mqtt==1.6.1 From c90185854ec39198821506fa212271c1a3f7a24e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 12 Mar 2025 23:22:08 -0500 Subject: [PATCH 10/88] Bump tornado from 6.4 to 6.4.2 (#8398) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ba4a1d6b2e..46746b08cf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ PyYAML==6.0.2 paho-mqtt==1.6.1 colorama==0.4.6 icmplib==3.0.4 -tornado==6.4 +tornado==6.4.2 tzlocal==5.2 # from time tzdata>=2021.1 # from time pyserial==3.5 From 7679c716b31a0cf79859383dc984e79b3ddf37dc Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Fri, 14 Mar 2025 20:17:16 +1100 Subject: [PATCH 11/88] [font] Fix issues with bitmap fonts (#8407) --- esphome/components/font/__init__.py | 113 ++++++++++++---------------- 1 file changed, 48 insertions(+), 65 deletions(-) diff --git a/esphome/components/font/__init__.py b/esphome/components/font/__init__.py index 426680604a..084574d09f 100644 --- a/esphome/components/font/__init__.py +++ b/esphome/components/font/__init__.py @@ -146,6 +146,13 @@ def check_missing_glyphs(file, codepoints, warning: bool = False): raise cv.Invalid(message) +def pt_to_px(pt): + """ + Convert a point size to pixels, rounding up to the nearest pixel + """ + return (pt + 63) // 64 + + def validate_font_config(config): """ Check for duplicate codepoints, then check that all requested codepoints actually @@ -172,42 +179,43 @@ def validate_font_config(config): ) # Make setpoints and glyphspoints disjoint setpoints.difference_update(glyphspoints) - if fileconf[CONF_TYPE] == TYPE_LOCAL_BITMAP: - if any(x >= 256 for x in setpoints.copy().union(glyphspoints)): - raise cv.Invalid("Codepoints in bitmap fonts must be in the range 0-255") - else: - # for TT fonts, check that glyphs are actually present - # Check extras against their own font, exclude from parent font codepoints - for extra in config[CONF_EXTRAS]: - points = {ord(x) for x in flatten(extra[CONF_GLYPHS])} - glyphspoints.difference_update(points) - setpoints.difference_update(points) - check_missing_glyphs(extra[CONF_FILE], points) + # check that glyphs are actually present + # Check extras against their own font, exclude from parent font codepoints + for extra in config[CONF_EXTRAS]: + points = {ord(x) for x in flatten(extra[CONF_GLYPHS])} + glyphspoints.difference_update(points) + setpoints.difference_update(points) + check_missing_glyphs(extra[CONF_FILE], points) - # A named glyph that can't be provided is an error + # A named glyph that can't be provided is an error - check_missing_glyphs(fileconf, glyphspoints) - # A missing glyph from a set is a warning. - if not config[CONF_IGNORE_MISSING_GLYPHS]: - check_missing_glyphs(fileconf, setpoints, warning=True) + check_missing_glyphs(fileconf, glyphspoints) + # A missing glyph from a set is a warning. + if not config[CONF_IGNORE_MISSING_GLYPHS]: + check_missing_glyphs(fileconf, setpoints, warning=True) # Populate the default after the above checks so that use of the default doesn't trigger errors + font = FONT_CACHE[fileconf] if not config[CONF_GLYPHS] and not config[CONF_GLYPHSETS]: - if fileconf[CONF_TYPE] == TYPE_LOCAL_BITMAP: - config[CONF_GLYPHS] = [DEFAULT_GLYPHS] - else: - # set a default glyphset, intersected with what the font actually offers - font = FONT_CACHE[fileconf] - config[CONF_GLYPHS] = [ - chr(x) - for x in glyphsets.unicodes_per_glyphset(DEFAULT_GLYPHSET) - if font.get_char_index(x) != 0 - ] + # set a default glyphset, intersected with what the font actually offers + config[CONF_GLYPHS] = [ + chr(x) + for x in glyphsets.unicodes_per_glyphset(DEFAULT_GLYPHSET) + if font.get_char_index(x) != 0 + ] - if config[CONF_FILE][CONF_TYPE] == TYPE_LOCAL_BITMAP: - if CONF_SIZE in config: + if font.has_fixed_sizes: + sizes = [pt_to_px(x.size) for x in font.available_sizes] + if not sizes: raise cv.Invalid( - "Size is not a valid option for bitmap fonts, which are inherently fixed size" + f"Font {FontCache.get_name(fileconf)} has no available sizes" + ) + if CONF_SIZE not in config: + config[CONF_SIZE] = sizes[0] + elif config[CONF_SIZE] not in sizes: + sizes = ", ".join(str(x) for x in sizes) + raise cv.Invalid( + f"Font {FontCache.get_name(fileconf)} only has size{'s' if len(sizes) != 1 else ''} {sizes} available" ) elif CONF_SIZE not in config: config[CONF_SIZE] = 20 @@ -215,14 +223,7 @@ def validate_font_config(config): return config -FONT_EXTENSIONS = (".ttf", ".woff", ".otf") -BITMAP_EXTENSIONS = (".bdf", ".pcf") - - -def validate_bitmap_file(value): - if not any(map(value.lower().endswith, BITMAP_EXTENSIONS)): - raise cv.Invalid(f"Only {', '.join(BITMAP_EXTENSIONS)} files are supported.") - return CORE.relative_config_path(cv.file_(value)) +FONT_EXTENSIONS = (".ttf", ".woff", ".otf", "bdf", ".pcf") def validate_truetype_file(value): @@ -246,7 +247,6 @@ def add_local_file(value): TYPE_LOCAL = "local" -TYPE_LOCAL_BITMAP = "local_bitmap" TYPE_GFONTS = "gfonts" TYPE_WEB = "web" LOCAL_SCHEMA = cv.All( @@ -258,15 +258,6 @@ LOCAL_SCHEMA = cv.All( add_local_file, ) -LOCAL_BITMAP_SCHEMA = cv.All( - cv.Schema( - { - cv.Required(CONF_PATH): validate_bitmap_file, - } - ), - add_local_file, -) - FULLPATH_SCHEMA = cv.maybe_simple_value( {cv.Required(CONF_PATH): cv.string}, key=CONF_PATH ) @@ -403,15 +394,6 @@ def validate_file_shorthand(value): } ) - extension = Path(value).suffix - if extension in BITMAP_EXTENSIONS: - return font_file_schema( - { - CONF_TYPE: TYPE_LOCAL_BITMAP, - CONF_PATH: value, - } - ) - return font_file_schema( { CONF_TYPE: TYPE_LOCAL, @@ -424,7 +406,6 @@ TYPED_FILE_SCHEMA = cv.typed_schema( { TYPE_LOCAL: LOCAL_SCHEMA, TYPE_GFONTS: GFONTS_SCHEMA, - TYPE_LOCAL_BITMAP: LOCAL_BITMAP_SCHEMA, TYPE_WEB: WEB_FONT_SCHEMA, } ) @@ -522,11 +503,13 @@ async def to_code(config): bpp = config[CONF_BPP] mode = ft_pixel_mode_grays scale = 256 // (1 << bpp) + size = config[CONF_SIZE] # create the data array for all glyphs for codepoint in codepoints: font = point_font_map[codepoint] - if not font.has_fixed_sizes: - font.set_pixel_sizes(config[CONF_SIZE], 0) + format = font.get_format().decode("utf-8") + if format != "PCF": + font.set_pixel_sizes(size, 0) font.load_char(codepoint) font.glyph.render(mode) width = font.glyph.bitmap.width @@ -550,17 +533,17 @@ async def to_code(config): if pixel & (1 << (bpp - bit_num - 1)): glyph_data[pos // 8] |= 0x80 >> (pos % 8) pos += 1 - ascender = font.size.ascender // 64 + ascender = pt_to_px(font.size.ascender) if ascender == 0: if font.has_fixed_sizes: - ascender = font.available_sizes[0].height + ascender = size else: _LOGGER.error( "Unable to determine ascender of font %s", config[CONF_FILE] ) glyph_args[codepoint] = GlyphInfo( len(data), - font.glyph.metrics.horiAdvance // 64, + pt_to_px(font.glyph.metrics.horiAdvance), font.glyph.bitmap_left, ascender - font.glyph.bitmap_top, width, @@ -599,11 +582,11 @@ async def to_code(config): glyphs = cg.static_const_array(config[CONF_RAW_GLYPH_ID], glyph_initializer) - font_height = base_font.size.height // 64 - ascender = base_font.size.ascender // 64 + font_height = pt_to_px(base_font.size.height) + ascender = pt_to_px(base_font.size.ascender) if font_height == 0: if base_font.has_fixed_sizes: - font_height = base_font.available_sizes[0].height + font_height = size ascender = font_height else: _LOGGER.error("Unable to determine height of font %s", config[CONF_FILE]) From fa25cebed52d48a026ad48463ed7e6170e61ae31 Mon Sep 17 00:00:00 2001 From: Mikkel Jeppesen <2756925+Duckle29@users.noreply.github.com> Date: Sat, 15 Mar 2025 06:55:20 +0100 Subject: [PATCH 12/88] Added getters for graphs ymin and ymax (#8112) Co-authored-by: guillempages --- esphome/components/graph/graph.cpp | 4 ++++ esphome/components/graph/graph.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/esphome/components/graph/graph.cpp b/esphome/components/graph/graph.cpp index cbe059b255..5abf2ade0d 100644 --- a/esphome/components/graph/graph.cpp +++ b/esphome/components/graph/graph.cpp @@ -132,6 +132,10 @@ void Graph::draw(Display *buff, uint16_t x_offset, uint16_t y_offset, Color colo yrange = ymax - ymin; } + // Store graph limts + this->graph_limit_max_ = ymax; + this->graph_limit_min_ = ymin; + /// Draw grid if (!std::isnan(this->gridspacing_y_)) { for (int y = yn; y <= ym; y++) { diff --git a/esphome/components/graph/graph.h b/esphome/components/graph/graph.h index 34accb7d3a..468583ca21 100644 --- a/esphome/components/graph/graph.h +++ b/esphome/components/graph/graph.h @@ -161,11 +161,15 @@ class Graph : public Component { uint32_t get_duration() { return duration_; } uint32_t get_width() { return width_; } uint32_t get_height() { return height_; } + float get_graph_limit_min() { return graph_limit_min_; } + float get_graph_limit_max() { return graph_limit_max_; } protected: uint32_t duration_; /// in seconds uint32_t width_; /// in pixels uint32_t height_; /// in pixels + float graph_limit_min_{NAN}; + float graph_limit_max_{NAN}; float min_value_{NAN}; float max_value_{NAN}; float min_range_{1.0}; From c336dd943621a3b1bcf5e12675c63b15e52ffeb6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 21:35:15 -1000 Subject: [PATCH 13/88] Bump setuptools from 69.2.0 to 76.0.0 (#8405) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 69b36cd14a..c8929238ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools==69.2.0", "wheel~=0.43.0"] +requires = ["setuptools==76.0.0", "wheel~=0.43.0"] build-backend = "setuptools.build_meta" [project] From 89f82be4cda0864f2ad6020bbfa1fd71b66381ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 21:35:51 -1000 Subject: [PATCH 14/88] Bump puremagic from 1.27 to 1.28 (#8406) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 46746b08cf..9c8cc95a7f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ click==8.1.7 esphome-dashboard==20250212.0 aioesphomeapi==29.6.0 zeroconf==0.146.1 -puremagic==1.27 +puremagic==1.28 ruamel.yaml==0.18.6 # dashboard_import esphome-glyphsets==0.1.0 pillow==10.4.0 From c63a5457509b69bd75cda9962ee654e6cacab405 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Mar 2025 21:36:12 -1000 Subject: [PATCH 15/88] Bump esphome-glyphsets from 0.1.0 to 0.2.0 (#8403) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 9c8cc95a7f..1ed77c635a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,7 +17,7 @@ aioesphomeapi==29.6.0 zeroconf==0.146.1 puremagic==1.28 ruamel.yaml==0.18.6 # dashboard_import -esphome-glyphsets==0.1.0 +esphome-glyphsets==0.2.0 pillow==10.4.0 freetype-py==2.5.1 From dfb162e7a607bd6bfdd261ade8b41a103be90796 Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Mon, 17 Mar 2025 01:55:29 -0500 Subject: [PATCH 16/88] [docker] Bump curl, git, openssh-client, libopenjp2-7, nginx-light (#8419) --- docker/Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 6da5c52d64..1642945d32 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -33,9 +33,9 @@ RUN \ python3-venv=3.11.2-1+b1 \ python3-wheel=0.38.4-2 \ iputils-ping=3:20221126-1+deb12u1 \ - git=1:2.39.5-0+deb12u1 \ - curl=7.88.1-10+deb12u8 \ - openssh-client=1:9.2p1-2+deb12u4 \ + git=1:2.39.5-0+deb12u2 \ + curl=7.88.1-10+deb12u12 \ + openssh-client=1:9.2p1-2+deb12u5 \ python3-cffi=1.15.1-5 \ libcairo2=1.16.0-7 \ libmagic1=1:5.44-3 \ @@ -84,7 +84,7 @@ BUILD_DEPS=" " LIB_DEPS=" libtiff6=4.5.0-6+deb12u1 - libopenjp2-7=2.5.0-2 + libopenjp2-7=2.5.0-2+deb12u1 " if [ "$TARGETARCH$TARGETVARIANT" = "arm64" ] then @@ -160,7 +160,7 @@ RUN \ apt-get update \ # Use pinned versions so that we get updates with build caching && apt-get install -y --no-install-recommends \ - nginx-light=1.22.1-9 \ + nginx-light=1.22.1-9+deb12u1 \ && rm -rf \ /tmp/* \ /var/{cache,log}/* \ From afa481aeea90dffa069ccfc5cdf40705ae323dbd Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Mon, 17 Mar 2025 23:28:15 -0500 Subject: [PATCH 17/88] [docker] Bump libfreetype (#8426) --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1642945d32..ee375ba690 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -76,7 +76,7 @@ BUILD_DEPS=" python3-dev=3.11.2-1+b1 zlib1g-dev=1:1.2.13.dfsg-1 libjpeg-dev=1:2.1.5-2 - libfreetype-dev=2.12.1+dfsg-5+deb12u3 + libfreetype-dev=2.12.1+dfsg-5+deb12u4 libssl-dev=3.0.15-1~deb12u1 libffi-dev=3.4.4-1 cargo=0.66.0+ds1-1 From f993bb08c7d728e8cb238023532f199cc2fbcec3 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 19 Mar 2025 06:42:14 +1100 Subject: [PATCH 18/88] [core] Handle mis-typed platform name more cleanly (#8424) --- esphome/core/config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/esphome/core/config.py b/esphome/core/config.py index 359b78acf1..f2b8585143 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -189,10 +189,11 @@ def _is_target_platform(name): from esphome.loader import get_component try: - if get_component(name, True).is_target_platform: - return True + return get_component(name, True).is_target_platform except KeyError: pass + except ImportError: + pass return False From cbf68f1fd27a0cecbd48a705cbdd83da4884aa34 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Wed, 19 Mar 2025 10:14:42 -0500 Subject: [PATCH 19/88] [audio] Bugfix: fix flac decoding glitches by using esp-audio-libs v1.1.3 (#8431) --- esphome/components/audio/__init__.py | 2 +- platformio.ini | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/esphome/components/audio/__init__.py b/esphome/components/audio/__init__.py index c5ef781060..f8ec8cbd85 100644 --- a/esphome/components/audio/__init__.py +++ b/esphome/components/audio/__init__.py @@ -118,4 +118,4 @@ def final_validate_audio_schema( async def to_code(config): - cg.add_library("esphome/esp-audio-libs", "1.1.2") + cg.add_library("esphome/esp-audio-libs", "1.1.3") diff --git a/platformio.ini b/platformio.ini index a2c2a74ac0..88e7c3b331 100644 --- a/platformio.ini +++ b/platformio.ini @@ -128,7 +128,7 @@ lib_deps = DNSServer ; captive_portal (Arduino built-in) esphome/ESP32-audioI2S@2.0.7 ; i2s_audio droscy/esp_wireguard@0.4.2 ; wireguard - esphome/esp-audio-libs@1.1.2 ; audio + esphome/esp-audio-libs@1.1.3 ; audio build_flags = ${common:arduino.build_flags} @@ -149,7 +149,7 @@ lib_deps = ${common:idf.lib_deps} droscy/esp_wireguard@0.4.2 ; wireguard kahrendt/ESPMicroSpeechFeatures@1.1.0 ; micro_wake_word - esphome/esp-audio-libs@1.1.2 ; audio + esphome/esp-audio-libs@1.1.3 ; audio build_flags = ${common:idf.build_flags} -Wno-nonnull-compare From 38bbfaccc63bedafb390f80fba8de2c4a0a2edd0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 12:46:01 -1000 Subject: [PATCH 20/88] Bump actions/cache from 4.2.2 to 4.2.3 in /.github/actions/restore-python (#8437) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/actions/restore-python/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/restore-python/action.yml b/.github/actions/restore-python/action.yml index 6eb557a514..a97733567d 100644 --- a/.github/actions/restore-python/action.yml +++ b/.github/actions/restore-python/action.yml @@ -22,7 +22,7 @@ runs: python-version: ${{ inputs.python-version }} - name: Restore Python virtual environment id: cache-venv - uses: actions/cache/restore@v4.2.2 + uses: actions/cache/restore@v4.2.3 with: path: venv # yamllint disable-line rule:line-length From 43805e6c568972600f785724af40a6a501a49aba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 12:46:38 -1000 Subject: [PATCH 21/88] Bump actions/cache from 4.2.2 to 4.2.3 (#8433) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b7220d011..67d382b240 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: python-version: ${{ env.DEFAULT_PYTHON }} - name: Restore Python virtual environment id: cache-venv - uses: actions/cache@v4.2.2 + uses: actions/cache@v4.2.3 with: path: venv # yamllint disable-line rule:line-length @@ -303,14 +303,14 @@ jobs: - name: Cache platformio if: github.ref == 'refs/heads/dev' - uses: actions/cache@v4.2.2 + uses: actions/cache@v4.2.3 with: path: ~/.platformio key: platformio-${{ matrix.pio_cache_key }} - name: Cache platformio if: github.ref != 'refs/heads/dev' - uses: actions/cache/restore@v4.2.2 + uses: actions/cache/restore@v4.2.3 with: path: ~/.platformio key: platformio-${{ matrix.pio_cache_key }} From 6ea89644e7476d3f8326c744d57060e987f13175 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 20 Mar 2025 15:37:44 +1100 Subject: [PATCH 22/88] [ft63x6] Get correct dimensions from display (#8417) --- esphome/components/ft63x6/ft63x6.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/esphome/components/ft63x6/ft63x6.cpp b/esphome/components/ft63x6/ft63x6.cpp index e5f7613901..8bc66822eb 100644 --- a/esphome/components/ft63x6/ft63x6.cpp +++ b/esphome/components/ft63x6/ft63x6.cpp @@ -42,10 +42,10 @@ void FT63X6Touchscreen::setup() { // Get touch resolution if (this->x_raw_max_ == this->x_raw_min_) { - this->x_raw_max_ = 320; + this->x_raw_max_ = this->display_->get_native_width(); } if (this->y_raw_max_ == this->y_raw_min_) { - this->y_raw_max_ = 480; + this->y_raw_max_ = this->display_->get_native_height(); } uint8_t chip_id = this->read_byte_(FT63X6_ADDR_CHIP_ID); if (chip_id != 0) { @@ -71,6 +71,8 @@ void FT63X6Touchscreen::dump_config() { LOG_I2C_DEVICE(this); LOG_PIN(" Interrupt Pin: ", this->interrupt_pin_); LOG_PIN(" Reset Pin: ", this->reset_pin_); + ESP_LOGCONFIG(TAG, " X Calibration: [%d, %d]", this->x_raw_min_, this->x_raw_max_); + ESP_LOGCONFIG(TAG, " Y Calibration: [%d, %d]", this->y_raw_min_, this->y_raw_max_); LOG_UPDATE_INTERVAL(this); } From 4adda632bb39d132a3b1585ae0695a9354dcaaee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 09:51:23 -1000 Subject: [PATCH 23/88] Bump ruff from 0.9.2 to 0.11.0 (#8409) --- .pre-commit-config.yaml | 2 +- docker/generate_tags.py | 2 +- esphome/components/a01nyub/sensor.py | 4 +- esphome/components/a02yyuw/sensor.py | 4 +- esphome/components/a4988/stepper.py | 3 +- .../components/absolute_humidity/sensor.py | 6 +-- esphome/components/ac_dimmer/output.py | 6 +-- esphome/components/adalight/__init__.py | 4 +- esphome/components/adc128s102/__init__.py | 2 +- .../components/adc128s102/sensor/__init__.py | 6 +-- .../components/addressable_light/display.py | 10 ++--- esphome/components/ade7880/sensor.py | 6 +-- esphome/components/ade7953_base/__init__.py | 28 ++++++------- esphome/components/ade7953_i2c/sensor.py | 3 +- esphome/components/ade7953_spi/sensor.py | 3 +- esphome/components/ads1115/__init__.py | 2 +- esphome/components/ads1115/sensor/__init__.py | 7 ++-- esphome/components/ads1118/__init__.py | 2 +- esphome/components/ads1118/sensor/__init__.py | 9 ++-- esphome/components/ags10/sensor.py | 18 ++++---- esphome/components/aht10/sensor.py | 4 +- esphome/components/airthings_ble/__init__.py | 2 +- .../airthings_wave_base/__init__.py | 5 +-- .../components/airthings_wave_mini/sensor.py | 7 +--- .../components/airthings_wave_plus/sensor.py | 19 ++++----- esphome/components/alpha3/sensor.py | 10 ++--- esphome/components/am2315c/sensor.py | 2 +- esphome/components/am2320/sensor.py | 2 +- esphome/components/am43/cover/__init__.py | 2 +- esphome/components/am43/sensor/__init__.py | 6 +-- .../analog_threshold/binary_sensor.py | 7 +--- esphome/components/anova/climate.py | 2 +- esphome/components/apds9306/sensor.py | 2 +- esphome/components/apds9960/__init__.py | 2 +- esphome/components/apds9960/binary_sensor.py | 3 +- esphome/components/apds9960/sensor.py | 5 ++- esphome/components/as3935/__init__.py | 6 +-- esphome/components/as3935/binary_sensor.py | 3 +- esphome/components/as3935/sensor.py | 7 ++-- esphome/components/as3935_i2c/__init__.py | 2 +- esphome/components/as3935_spi/__init__.py | 2 +- esphome/components/as5600/__init__.py | 4 +- esphome/components/as5600/sensor/__init__.py | 19 +++++---- esphome/components/as7341/sensor.py | 3 +- esphome/components/at581x/__init__.py | 12 ++---- esphome/components/at581x/switch/__init__.py | 6 +-- .../components/atc_mithermometer/sensor.py | 6 +-- esphome/components/b_parasite/sensor.py | 4 +- esphome/components/ballu/climate.py | 2 +- esphome/components/bang_bang/climate.py | 4 +- esphome/components/bedjet/__init__.py | 8 +--- esphome/components/bedjet/climate/__init__.py | 9 ++-- esphome/components/bedjet/fan/__init__.py | 13 ++---- esphome/components/bedjet/sensor/__init__.py | 9 ++-- .../components/beken_spi_led_strip/light.py | 4 +- esphome/components/bh1750/sensor.py | 8 +--- esphome/components/binary/fan/__init__.py | 3 +- esphome/components/binary/light/__init__.py | 5 ++- .../components/binary_sensor_map/sensor.py | 11 +++-- esphome/components/bl0939/sensor.py | 2 +- esphome/components/bl0940/sensor.py | 6 +-- .../components/ble_client/sensor/__init__.py | 2 +- .../ble_client/text_sensor/__init__.py | 2 +- .../components/bluetooth_proxy/__init__.py | 11 ++--- esphome/components/bme280_base/__init__.py | 2 +- esphome/components/bme280_i2c/sensor.py | 5 ++- esphome/components/bme280_spi/sensor.py | 5 ++- esphome/components/bme680/sensor.py | 8 ++-- esphome/components/bme680_bsec/__init__.py | 2 +- esphome/components/bme680_bsec/sensor.py | 9 ++-- esphome/components/bme680_bsec/text_sensor.py | 5 ++- esphome/components/bmi160/sensor.py | 12 +++--- esphome/components/bmp085/sensor.py | 2 +- esphome/components/bmp280_base/__init__.py | 2 +- esphome/components/bmp280_i2c/sensor.py | 5 ++- esphome/components/bmp280_spi/sensor.py | 5 ++- esphome/components/bmp3xx_base/__init__.py | 2 +- esphome/components/bmp3xx_i2c/sensor.py | 3 +- esphome/components/bmp3xx_spi/sensor.py | 3 +- esphome/components/bmp581/sensor.py | 3 +- esphome/components/bp1658cj/__init__.py | 8 +--- esphome/components/bp1658cj/output.py | 3 +- esphome/components/bp5758d/__init__.py | 8 +--- esphome/components/bp5758d/output.py | 5 ++- esphome/components/canbus/__init__.py | 4 +- esphome/components/cap1188/__init__.py | 8 ++-- esphome/components/cap1188/binary_sensor.py | 5 ++- esphome/components/captive_portal/__init__.py | 6 +-- esphome/components/ccs811/sensor.py | 20 ++++----- esphome/components/cd74hc4067/__init__.py | 7 +--- esphome/components/cd74hc4067/sensor.py | 13 +++--- esphome/components/climate_ir/__init__.py | 4 +- esphome/components/climate_ir_lg/climate.py | 2 +- esphome/components/color/__init__.py | 3 +- esphome/components/color_temperature/light.py | 4 +- esphome/components/combination/sensor.py | 2 +- esphome/components/coolix/climate.py | 2 +- .../components/copy/binary_sensor/__init__.py | 2 +- esphome/components/copy/button/__init__.py | 2 +- esphome/components/copy/cover/__init__.py | 2 +- esphome/components/copy/fan/__init__.py | 9 +--- esphome/components/copy/lock/__init__.py | 9 +--- esphome/components/copy/number/__init__.py | 2 +- esphome/components/copy/select/__init__.py | 9 +--- esphome/components/copy/sensor/__init__.py | 4 +- esphome/components/copy/switch/__init__.py | 2 +- esphome/components/copy/text/__init__.py | 9 +--- .../components/copy/text_sensor/__init__.py | 8 +--- esphome/components/cs5460a/sensor.py | 14 +++---- esphome/components/cse7761/sensor.py | 4 +- esphome/components/cse7766/sensor.py | 2 +- .../components/cst226/touchscreen/__init__.py | 9 ++-- esphome/components/ct_clamp/sensor.py | 2 +- esphome/components/current_based/cover.py | 9 ++-- esphome/components/cwww/light.py | 6 +-- esphome/components/dac7678/__init__.py | 2 +- esphome/components/dac7678/output.py | 3 +- esphome/components/daikin/climate.py | 2 +- esphome/components/daikin_arc/climate.py | 2 +- esphome/components/daikin_brc/climate.py | 2 +- esphome/components/dallas_temp/sensor.py | 2 +- esphome/components/daly_bms/__init__.py | 4 +- esphome/components/daly_bms/binary_sensor.py | 5 ++- esphome/components/daly_bms/sensor.py | 29 ++++++------- esphome/components/daly_bms/text_sensor.py | 5 ++- .../components/dashboard_import/__init__.py | 12 +++--- esphome/components/debug/sensor.py | 13 +++--- esphome/components/debug/text_sensor.py | 2 +- esphome/components/deep_sleep/__init__.py | 23 +++++------ esphome/components/delonghi/climate.py | 2 +- esphome/components/demo/__init__.py | 2 +- esphome/components/dfplayer/__init__.py | 6 +-- .../components/dfrobot_sen0395/__init__.py | 6 +-- .../dfrobot_sen0395/binary_sensor.py | 3 +- .../dfrobot_sen0395/switch/__init__.py | 5 +-- esphome/components/dht/sensor.py | 9 ++-- esphome/components/dht12/sensor.py | 6 +-- esphome/components/dps310/sensor.py | 6 +-- esphome/components/ds1307/time.py | 5 +-- esphome/components/dsmr/__init__.py | 10 ++--- esphome/components/dsmr/sensor.py | 9 ++-- esphome/components/dsmr/text_sensor.py | 5 ++- esphome/components/duty_cycle/sensor.py | 11 ++--- esphome/components/duty_time/sensor.py | 14 +++---- esphome/components/e131/__init__.py | 6 +-- esphome/components/ee895/sensor.py | 12 +++--- .../ektf2232/touchscreen/__init__.py | 5 +-- esphome/components/emc2101/__init__.py | 2 +- esphome/components/emc2101/output/__init__.py | 5 ++- esphome/components/emc2101/sensor/__init__.py | 7 ++-- esphome/components/emmeti/climate.py | 2 +- esphome/components/endstop/cover.py | 6 +-- esphome/components/ens160_base/__init__.py | 2 +- esphome/components/ens160_i2c/sensor.py | 3 +- esphome/components/ens160_spi/sensor.py | 3 +- esphome/components/ens210/sensor.py | 2 +- esphome/components/esp32_camera/__init__.py | 15 ++++--- .../esp32_camera_web_server/__init__.py | 4 +- esphome/components/esp32_dac/output.py | 4 +- esphome/components/esp32_hall/sensor.py | 8 +--- esphome/components/esp32_touch/__init__.py | 14 +++---- .../components/esp32_touch/binary_sensor.py | 11 ++--- esphome/components/esp8266_pwm/output.py | 11 ++--- esphome/components/ethernet/__init__.py | 1 + .../exposure_notifications/__init__.py | 4 +- .../external_components/__init__.py | 2 +- esphome/components/ezo/sensor.py | 4 +- esphome/components/ezo_pmp/__init__.py | 8 ++-- esphome/components/ezo_pmp/binary_sensor.py | 8 ++-- esphome/components/ezo_pmp/sensor.py | 9 ++-- esphome/components/ezo_pmp/text_sensor.py | 8 +--- .../factory_reset/button/__init__.py | 3 +- .../factory_reset/switch/__init__.py | 5 ++- esphome/components/fastled_base/__init__.py | 8 ++-- esphome/components/fastled_clockless/light.py | 4 +- esphome/components/fastled_spi/light.py | 4 +- esphome/components/feedback/cover.py | 6 +-- .../components/fingerprint_grow/__init__.py | 13 +++--- .../fingerprint_grow/binary_sensor.py | 3 +- esphome/components/fingerprint_grow/sensor.py | 3 +- esphome/components/fs3000/sensor.py | 8 +--- .../components/ft5x06/touchscreen/__init__.py | 4 +- esphome/components/ft63x6/touchscreen.py | 5 +-- esphome/components/fujitsu_general/climate.py | 2 +- esphome/components/gcja5/sensor.py | 8 ++-- esphome/components/gdk101/__init__.py | 2 +- esphome/components/gdk101/binary_sensor.py | 3 +- esphome/components/gdk101/sensor.py | 9 ++-- esphome/components/globals/__init__.py | 3 +- esphome/components/gp2y1010au0f/sensor.py | 6 +-- esphome/components/gp8403/__init__.py | 3 +- esphome/components/gp8403/output/__init__.py | 7 ++-- .../components/gpio/binary_sensor/__init__.py | 5 ++- esphome/components/gpio/one_wire/__init__.py | 7 ++-- esphome/components/gpio/output/__init__.py | 5 ++- esphome/components/gpio/switch/__init__.py | 5 ++- esphome/components/gps/__init__.py | 9 ++-- esphome/components/gps/time/__init__.py | 5 ++- esphome/components/graph/__init__.py | 26 ++++++------ .../components/grove_tb6612fng/__init__.py | 13 +++--- esphome/components/growatt_solar/sensor.py | 2 +- .../gt911/binary_sensor/__init__.py | 4 +- .../haier/binary_sensor/__init__.py | 14 ++----- esphome/components/haier/button/__init__.py | 9 ++-- esphome/components/haier/sensor/__init__.py | 10 ++--- esphome/components/haier/switch/__init__.py | 13 +++--- .../components/haier/text_sensor/__init__.py | 13 ++---- esphome/components/havells_solar/sensor.py | 2 +- esphome/components/hbridge/fan/__init__.py | 12 +++--- esphome/components/hbridge/light/__init__.py | 3 +- esphome/components/hdc1080/sensor.py | 2 +- esphome/components/he60r/cover.py | 8 +--- esphome/components/heatpumpir/climate.py | 2 +- esphome/components/hitachi_ac344/climate.py | 2 +- esphome/components/hitachi_ac424/climate.py | 2 +- esphome/components/hlw8012/sensor.py | 14 +++---- esphome/components/hm3301/sensor.py | 6 +-- esphome/components/hmc5883l/sensor.py | 12 +++--- .../components/homeassistant/time/__init__.py | 3 +- .../components/honeywell_hih_i2c/sensor.py | 6 +-- esphome/components/honeywellabp/sensor.py | 3 +- .../components/honeywellabp2_i2c/sensor.py | 3 +- esphome/components/host/time/__init__.py | 4 +- esphome/components/hrxl_maxsonar_wr/sensor.py | 2 +- esphome/components/hte501/sensor.py | 6 +-- .../components/http_request/ota/__init__.py | 16 +++----- .../http_request/update/__init__.py | 10 ++--- esphome/components/htu21d/sensor.py | 14 +++---- esphome/components/htu31d/sensor.py | 2 +- esphome/components/hx711/sensor.py | 11 ++--- .../components/hydreon_rgxx/binary_sensor.py | 10 ++--- esphome/components/hydreon_rgxx/sensor.py | 8 ++-- esphome/components/hyt271/sensor.py | 2 +- esphome/components/i2c_device/__init__.py | 2 +- .../i2s_audio/media_player/__init__.py | 16 ++++---- esphome/components/iaqcore/sensor.py | 4 +- esphome/components/ina219/sensor.py | 4 +- esphome/components/ina226/sensor.py | 8 ++-- esphome/components/ina260/sensor.py | 8 ++-- esphome/components/ina2xx_base/__init__.py | 4 +- esphome/components/ina2xx_i2c/sensor.py | 2 +- esphome/components/ina2xx_spi/sensor.py | 2 +- esphome/components/ina3221/sensor.py | 6 +-- .../components/inkbird_ibsth1_mini/sensor.py | 4 +- esphome/components/inkplate6/display.py | 4 +- esphome/components/integration/sensor.py | 8 ++-- .../components/internal_temperature/sensor.py | 12 +++--- esphome/components/interval/__init__.py | 2 +- esphome/components/jsn_sr04t/sensor.py | 6 +-- esphome/components/kamstrup_kmp/sensor.py | 2 +- esphome/components/key_collector/__init__.py | 4 +- esphome/components/kmeteriso/sensor.py | 4 +- esphome/components/kuntze/sensor.py | 10 ++--- esphome/components/lcd_base/__init__.py | 4 +- esphome/components/lcd_gpio/display.py | 8 ++-- esphome/components/lcd_menu/__init__.py | 10 ++--- esphome/components/lcd_pcf8574/display.py | 2 +- esphome/components/ld2410/__init__.py | 8 ++-- esphome/components/ld2410/binary_sensor.py | 9 ++-- esphome/components/ld2410/button/__init__.py | 5 ++- esphome/components/ld2410/number/__init__.py | 9 ++-- esphome/components/ld2410/select/__init__.py | 7 ++-- esphome/components/ld2410/sensor.py | 11 ++--- esphome/components/ld2410/switch/__init__.py | 3 +- esphome/components/ld2410/text_sensor.py | 5 ++- esphome/components/ld2420/__init__.py | 2 +- .../ld2420/binary_sensor/__init__.py | 7 ++-- esphome/components/ld2420/button/__init__.py | 5 ++- esphome/components/ld2420/number/__init__.py | 5 ++- esphome/components/ld2420/select/__init__.py | 1 + esphome/components/ld2420/sensor/__init__.py | 5 ++- .../components/ld2420/text_sensor/__init__.py | 8 +--- esphome/components/ld2450/__init__.py | 7 +--- esphome/components/ledc/output.py | 6 +-- esphome/components/libretiny/text_sensor.py | 2 +- esphome/components/libretiny_pwm/output.py | 10 ++--- esphome/components/lightwaverf/__init__.py | 18 ++++---- .../lilygo_t5_47/touchscreen/__init__.py | 5 +-- esphome/components/ltr390/sensor.py | 2 +- esphome/components/ltr501/sensor.py | 4 +- esphome/components/ltr_als_ps/sensor.py | 4 +- esphome/components/m5stack_8angle/__init__.py | 3 +- .../m5stack_8angle/binary_sensor/__init__.py | 5 +-- .../m5stack_8angle/light/__init__.py | 6 +-- .../m5stack_8angle/sensor/__init__.py | 6 +-- .../matrix_keypad/binary_sensor/__init__.py | 7 ++-- esphome/components/max31855/sensor.py | 2 +- esphome/components/max31865/sensor.py | 2 +- esphome/components/max44009/sensor.py | 2 +- esphome/components/max6675/sensor.py | 2 +- esphome/components/max6956/__init__.py | 10 ++--- esphome/components/max6956/output/__init__.py | 7 ++-- esphome/components/max7219/display.py | 2 +- esphome/components/max7219digit/display.py | 2 +- esphome/components/max9611/sensor.py | 20 ++++----- esphome/components/mcp23008/__init__.py | 2 +- esphome/components/mcp23016/__init__.py | 8 ++-- esphome/components/mcp23017/__init__.py | 2 +- esphome/components/mcp23s08/__init__.py | 2 +- esphome/components/mcp23s17/__init__.py | 2 +- esphome/components/mcp23xxx_base/__init__.py | 8 ++-- esphome/components/mcp2515/canbus.py | 6 +-- esphome/components/mcp3008/__init__.py | 2 +- esphome/components/mcp3008/sensor/__init__.py | 8 ++-- esphome/components/mcp3204/__init__.py | 2 +- esphome/components/mcp3204/sensor/__init__.py | 5 ++- esphome/components/mcp4725/output.py | 4 +- esphome/components/mcp4728/__init__.py | 2 +- esphome/components/mcp4728/output/__init__.py | 7 ++-- esphome/components/mcp47a1/output.py | 4 +- esphome/components/mcp9808/sensor.py | 2 +- esphome/components/mhz19/sensor.py | 8 ++-- esphome/components/micronova/__init__.py | 8 ++-- .../components/micronova/button/__init__.py | 10 ++--- .../components/micronova/number/__init__.py | 16 +++----- .../components/micronova/sensor/__init__.py | 12 +++--- .../components/micronova/switch/__init__.py | 14 +++---- .../micronova/text_sensor/__init__.py | 10 ++--- esphome/components/microphone/__init__.py | 6 +-- esphome/components/midea/climate.py | 16 +++----- esphome/components/midea_ir/climate.py | 2 +- esphome/components/mitsubishi/climate.py | 2 +- esphome/components/mlx90614/sensor.py | 2 +- esphome/components/mmc5603/sensor.py | 12 +++--- esphome/components/mmc5983/sensor.py | 2 +- esphome/components/modbus/__init__.py | 18 ++++---- .../components/modbus_controller/__init__.py | 2 +- esphome/components/monochromatic/light.py | 4 +- esphome/components/mopeka_ble/__init__.py | 2 +- esphome/components/mopeka_pro_check/sensor.py | 26 ++++++------ esphome/components/mopeka_std_check/sensor.py | 16 ++++---- esphome/components/mpl3115a2/sensor.py | 2 +- esphome/components/mpr121/__init__.py | 6 +-- .../mpr121/binary_sensor/__init__.py | 9 ++-- esphome/components/mpu6050/sensor.py | 8 ++-- esphome/components/mpu6886/sensor.py | 8 ++-- .../mqtt_subscribe/sensor/__init__.py | 8 ++-- .../mqtt_subscribe/text_sensor/__init__.py | 2 +- esphome/components/ms5611/sensor.py | 4 +- esphome/components/ms8607/sensor.py | 2 +- esphome/components/my9231/__init__.py | 2 +- esphome/components/my9231/output.py | 3 +- esphome/components/neopixelbus/_methods.py | 20 +++++---- esphome/components/neopixelbus/light.py | 29 +++++-------- .../nextion/binary_sensor/__init__.py | 20 +++------ esphome/components/nextion/sensor/__init__.py | 17 ++++---- esphome/components/nextion/switch/__init__.py | 8 ++-- .../nextion/text_sensor/__init__.py | 10 ++--- esphome/components/noblex/climate.py | 2 +- esphome/components/ntc/sensor.py | 2 +- esphome/components/opentherm/__init__.py | 12 +++--- esphome/components/opentherm/input.py | 3 +- .../components/opentherm/number/__init__.py | 9 ++-- .../components/opentherm/output/__init__.py | 5 ++- esphome/components/opentherm/schema.py | 14 +++---- .../components/opentherm/switch/__init__.py | 5 ++- esphome/components/opentherm/validate.py | 2 +- esphome/components/output/__init__.py | 5 +-- esphome/components/output/button/__init__.py | 5 ++- esphome/components/output/lock/__init__.py | 3 +- esphome/components/output/switch/__init__.py | 3 +- esphome/components/partition/light.py | 8 ++-- esphome/components/pca6416a/__init__.py | 8 ++-- esphome/components/pca9554/__init__.py | 8 ++-- esphome/components/pca9685/__init__.py | 4 +- esphome/components/pca9685/output.py | 3 +- esphome/components/pcf85063/time.py | 5 +-- esphome/components/pcf8563/time.py | 4 +- esphome/components/pcf8574/__init__.py | 8 ++-- esphome/components/pid/climate.py | 6 +-- esphome/components/pid/sensor/__init__.py | 12 ++---- esphome/components/pipsolar/__init__.py | 2 +- .../pipsolar/binary_sensor/__init__.py | 4 +- .../components/pipsolar/output/__init__.py | 7 ++-- .../components/pipsolar/sensor/__init__.py | 9 ++-- .../components/pipsolar/switch/__init__.py | 3 +- .../pipsolar/text_sensor/__init__.py | 3 +- esphome/components/pm1006/sensor.py | 4 +- esphome/components/pmsa003i/sensor.py | 8 ++-- esphome/components/pmsx003/sensor.py | 21 +++++----- esphome/components/pmwcs3/sensor.py | 10 ++--- esphome/components/pn532/__init__.py | 6 +-- esphome/components/pn532_i2c/__init__.py | 2 +- esphome/components/pn532_spi/__init__.py | 2 +- esphome/components/pn7150/__init__.py | 4 +- esphome/components/pn7150_i2c/__init__.py | 2 +- esphome/components/pn7160/__init__.py | 4 +- esphome/components/pn7160_i2c/__init__.py | 2 +- esphome/components/pn7160_spi/__init__.py | 2 +- esphome/components/power_supply/__init__.py | 2 +- esphome/components/prometheus/__init__.py | 11 ++--- esphome/components/psram/__init__.py | 8 +--- esphome/components/pulse_counter/sensor.py | 8 ++-- esphome/components/pulse_meter/sensor.py | 6 +-- esphome/components/pulse_width/sensor.py | 11 ++--- .../pvvx_mithermometer/display/__init__.py | 2 +- .../components/pvvx_mithermometer/sensor.py | 6 +-- esphome/components/pylontech/__init__.py | 1 + .../components/pylontech/sensor/__init__.py | 21 ++++------ .../pylontech/text_sensor/__init__.py | 9 +--- esphome/components/pzem004t/sensor.py | 6 +-- esphome/components/pzemac/sensor.py | 18 ++++---- esphome/components/pzemdc/sensor.py | 12 +++--- esphome/components/qmc5883l/sensor.py | 10 ++--- esphome/components/qmp6988/sensor.py | 6 +-- esphome/components/qr_code/__init__.py | 2 +- esphome/components/qwiic_pir/binary_sensor.py | 7 +--- esphome/components/radon_eye_ble/__init__.py | 2 +- esphome/components/radon_eye_rd200/sensor.py | 7 ++-- esphome/components/rc522/__init__.py | 6 +-- esphome/components/rc522_i2c/__init__.py | 2 +- esphome/components/rc522_spi/__init__.py | 2 +- esphome/components/rdm6300/__init__.py | 4 +- esphome/components/rdm6300/binary_sensor.py | 3 +- esphome/components/resistance/sensor.py | 4 +- esphome/components/restart/button/__init__.py | 2 +- esphome/components/restart/switch/__init__.py | 7 +--- esphome/components/rf_bridge/__init__.py | 6 +-- esphome/components/rgb/light.py | 4 +- esphome/components/rgbct/light.py | 6 +-- esphome/components/rgbw/light.py | 4 +- esphome/components/rgbww/light.py | 8 ++-- esphome/components/rotary_encoder/sensor.py | 16 ++++---- esphome/components/rp2040_pio/__init__.py | 1 - .../components/rp2040_pio_led_strip/light.py | 6 +-- esphome/components/rp2040_pwm/output.py | 10 ++--- esphome/components/rtttl/__init__.py | 12 +++--- esphome/components/ruuvi_ble/__init__.py | 2 +- esphome/components/ruuvitag/sensor.py | 30 +++++++------- esphome/components/safe_mode/__init__.py | 5 +-- .../components/safe_mode/button/__init__.py | 5 ++- .../components/safe_mode/switch/__init__.py | 11 ++--- esphome/components/scd30/sensor.py | 13 +++--- esphome/components/scd4x/sensor.py | 14 +++---- esphome/components/script/__init__.py | 4 +- esphome/components/sdl/display.py | 6 +-- .../components/sdl/touchscreen/__init__.py | 4 +- esphome/components/sdm_meter/sensor.py | 6 +-- esphome/components/sdp3x/sensor.py | 3 +- esphome/components/sds011/sensor.py | 8 ++-- esphome/components/seeed_mr24hpc1/__init__.py | 2 +- .../seeed_mr24hpc1/binary_sensor.py | 7 +--- .../seeed_mr24hpc1/button/__init__.py | 1 + .../seeed_mr24hpc1/number/__init__.py | 6 +-- .../seeed_mr24hpc1/select/__init__.py | 5 +-- esphome/components/seeed_mr24hpc1/sensor.py | 1 + .../seeed_mr24hpc1/switch/__init__.py | 6 +-- .../components/seeed_mr24hpc1/text_sensor.py | 1 + .../seeed_mr60bha2/binary_sensor.py | 6 +-- esphome/components/seeed_mr60bha2/sensor.py | 2 +- .../seeed_mr60fda2/button/__init__.py | 2 +- .../seeed_mr60fda2/select/__init__.py | 1 - esphome/components/selec_meter/sensor.py | 2 +- esphome/components/sen0321/sensor.py | 4 +- esphome/components/sen21231/sensor.py | 2 +- esphome/components/senseair/sensor.py | 6 +-- .../components/sensirion_common/__init__.py | 2 - esphome/components/servo/__init__.py | 6 +-- esphome/components/sfa30/sensor.py | 9 ++-- esphome/components/sgp4x/sensor.py | 4 +- esphome/components/shelly_dimmer/light.py | 34 +++++++-------- esphome/components/sht3xd/sensor.py | 2 +- esphome/components/sht4x/sensor.py | 12 +++--- esphome/components/shtcx/sensor.py | 2 +- .../components/shutdown/button/__init__.py | 8 +--- .../components/shutdown/switch/__init__.py | 7 +--- .../components/sigma_delta_output/output.py | 9 +--- esphome/components/sim800l/__init__.py | 10 ++--- esphome/components/sim800l/binary_sensor.py | 8 ++-- esphome/components/sim800l/sensor.py | 3 +- esphome/components/slow_pwm/output.py | 9 ++-- esphome/components/sm10bit_base/__init__.py | 8 +--- esphome/components/sm16716/__init__.py | 2 +- esphome/components/sm16716/output.py | 3 +- esphome/components/sm2135/__init__.py | 8 +--- esphome/components/sm2135/output.py | 3 +- esphome/components/sm2235/__init__.py | 2 +- esphome/components/sm2235/output.py | 3 +- esphome/components/sm2335/__init__.py | 2 +- esphome/components/sm2335/output.py | 3 +- esphome/components/sm300d2/sensor.py | 30 +++++++------- esphome/components/sml/__init__.py | 2 +- esphome/components/sml/sensor/__init__.py | 2 +- .../components/sml/text_sensor/__init__.py | 2 +- esphome/components/smt100/sensor.py | 11 +++-- esphome/components/sn74hc165/__init__.py | 10 ++--- esphome/components/sn74hc595/__init__.py | 12 +++--- esphome/components/socket/__init__.py | 2 +- esphome/components/sonoff_d1/light.py | 8 +--- esphome/components/speed/fan/__init__.py | 4 +- esphome/components/sprinkler/__init__.py | 9 ++-- esphome/components/sps30/sensor.py | 16 ++++---- esphome/components/ssd1306_i2c/display.py | 4 +- esphome/components/ssd1322_base/__init__.py | 4 +- esphome/components/ssd1325_base/__init__.py | 4 +- esphome/components/ssd1327_base/__init__.py | 4 +- esphome/components/ssd1327_i2c/display.py | 2 +- esphome/components/ssd1331_base/__init__.py | 4 +- esphome/components/ssd1351_base/__init__.py | 4 +- esphome/components/st7567_base/__init__.py | 8 ++-- esphome/components/st7567_i2c/display.py | 2 +- esphome/components/st7920/display.py | 4 +- esphome/components/statsd/__init__.py | 10 ++--- esphome/components/status/binary_sensor.py | 7 +--- esphome/components/status_led/__init__.py | 2 +- .../components/status_led/light/__init__.py | 3 +- esphome/components/stepper/__init__.py | 4 +- esphome/components/sts3x/sensor.py | 2 +- esphome/components/substitutions/__init__.py | 4 +- esphome/components/sun/__init__.py | 8 ++-- esphome/components/sun/sensor/__init__.py | 11 ++--- .../components/sun/text_sensor/__init__.py | 9 ++-- esphome/components/sun_gtil2/__init__.py | 2 +- esphome/components/sun_gtil2/sensor.py | 13 +++--- esphome/components/sun_gtil2/text_sensor.py | 5 ++- esphome/components/sx1509/__init__.py | 10 ++--- .../sx1509/binary_sensor/__init__.py | 6 +-- esphome/components/sx1509/output/__init__.py | 7 ++-- esphome/components/t6615/sensor.py | 2 +- esphome/components/tca9548a/__init__.py | 2 +- esphome/components/tcl112/climate.py | 2 +- esphome/components/tcs34725/sensor.py | 8 ++-- esphome/components/tee501/sensor.py | 2 +- esphome/components/teleinfo/__init__.py | 2 +- .../components/teleinfo/sensor/__init__.py | 8 +--- .../teleinfo/text_sensor/__init__.py | 2 +- esphome/components/tem3200/sensor.py | 3 +- .../template/alarm_control_panel/__init__.py | 13 ++---- esphome/components/template/cover/__init__.py | 7 ++-- .../components/template/datetime/__init__.py | 17 ++++---- esphome/components/template/event/__init__.py | 7 +--- esphome/components/template/fan/__init__.py | 8 +--- esphome/components/template/lock/__init__.py | 5 ++- .../components/template/number/__init__.py | 5 ++- .../components/template/output/__init__.py | 7 ++-- .../components/template/select/__init__.py | 5 ++- .../components/template/sensor/__init__.py | 11 ++--- .../components/template/switch/__init__.py | 5 ++- esphome/components/template/text/__init__.py | 7 ++-- .../template/text_sensor/__init__.py | 5 ++- esphome/components/template/valve/__init__.py | 5 ++- esphome/components/time_based/cover.py | 6 +-- esphome/components/tlc59208f/__init__.py | 2 +- esphome/components/tlc59208f/output.py | 3 +- esphome/components/tlc5947/__init__.py | 2 +- esphome/components/tlc5947/output/__init__.py | 3 +- esphome/components/tlc5971/__init__.py | 10 +---- esphome/components/tlc5971/output/__init__.py | 3 +- esphome/components/tm1621/display.py | 6 +-- esphome/components/tm1637/binary_sensor.py | 2 +- esphome/components/tm1637/display.py | 6 +-- esphome/components/tm1651/__init__.py | 8 ++-- esphome/components/tmp102/sensor.py | 2 +- esphome/components/tmp1075/sensor.py | 4 +- esphome/components/tmp117/sensor.py | 2 +- esphome/components/tof10120/sensor.py | 4 +- esphome/components/tormatic/cover.py | 8 +--- esphome/components/toshiba/climate.py | 2 +- .../components/total_daily_energy/sensor.py | 10 ++--- esphome/components/tsl2561/sensor.py | 2 +- esphome/components/tsl2591/sensor.py | 20 ++++----- .../tt21100/binary_sensor/__init__.py | 4 +- .../tt21100/touchscreen/__init__.py | 5 +-- esphome/components/ttp229_bsf/__init__.py | 4 +- .../components/ttp229_bsf/binary_sensor.py | 5 ++- esphome/components/ttp229_lsf/__init__.py | 2 +- .../components/ttp229_lsf/binary_sensor.py | 5 ++- esphome/components/tuya/__init__.py | 8 ++-- .../components/tuya/binary_sensor/__init__.py | 4 +- esphome/components/tuya/climate/__init__.py | 11 ++--- esphome/components/tuya/cover/__init__.py | 9 ++-- esphome/components/tuya/fan/__init__.py | 5 ++- esphome/components/tuya/light/__init__.py | 19 +++++---- esphome/components/tuya/number/__init__.py | 11 ++--- esphome/components/tuya/select/__init__.py | 7 ++-- esphome/components/tuya/sensor/__init__.py | 5 ++- esphome/components/tuya/switch/__init__.py | 5 ++- .../components/tuya/text_sensor/__init__.py | 5 ++- esphome/components/tx20/sensor.py | 12 +++--- esphome/components/uart/__init__.py | 41 ++++++++++--------- esphome/components/uart/button/__init__.py | 3 +- esphome/components/uart/switch/__init__.py | 3 +- esphome/components/ufire_ise/sensor.py | 4 +- esphome/components/uln2003/stepper.py | 4 +- esphome/components/ultrasonic/sensor.py | 8 ++-- esphome/components/uponor_smatrix/__init__.py | 8 +--- .../uponor_smatrix/climate/__init__.py | 6 +-- esphome/components/vbus/__init__.py | 2 +- .../components/vbus/binary_sensor/__init__.py | 13 +++--- esphome/components/vbus/sensor/__init__.py | 13 +++--- esphome/components/veml3235/sensor.py | 2 +- esphome/components/veml7700/sensor.py | 2 +- esphome/components/version/text_sensor.py | 8 +--- esphome/components/vl53l0x/sensor.py | 12 +++--- .../components/web_server_base/__init__.py | 4 +- esphome/components/web_server_idf/__init__.py | 2 +- esphome/components/weikai/__init__.py | 2 +- esphome/components/whirlpool/climate.py | 2 +- esphome/components/whynter/climate.py | 2 +- esphome/components/wireguard/binary_sensor.py | 2 +- esphome/components/wireguard/sensor.py | 7 +--- esphome/components/wireguard/text_sensor.py | 7 +--- esphome/components/wk2132_i2c/__init__.py | 2 +- esphome/components/wk2132_spi/__init__.py | 3 +- esphome/components/wk2168_i2c/__init__.py | 11 ++--- esphome/components/wk2168_spi/__init__.py | 11 ++--- esphome/components/wk2204_i2c/__init__.py | 2 +- esphome/components/wk2204_spi/__init__.py | 2 +- esphome/components/wk2212_i2c/__init__.py | 11 ++--- esphome/components/wk2212_spi/__init__.py | 11 ++--- esphome/components/wl_134/text_sensor.py | 6 +-- esphome/components/wled/__init__.py | 4 +- esphome/components/x9c/output.py | 8 ++-- esphome/components/xgzp68xx/sensor.py | 10 ++--- esphome/components/xiaomi_ble/__init__.py | 2 +- esphome/components/xiaomi_cgd1/sensor.py | 6 +-- esphome/components/xiaomi_cgdk2/sensor.py | 6 +-- esphome/components/xiaomi_cgg1/sensor.py | 4 +- .../components/xiaomi_cgpr1/binary_sensor.py | 12 +++--- esphome/components/xiaomi_gcls002/sensor.py | 14 +++---- esphome/components/xiaomi_hhccjcy01/sensor.py | 18 ++++---- esphome/components/xiaomi_hhccjcy10/sensor.py | 18 ++++---- .../components/xiaomi_hhccpot002/sensor.py | 16 ++++---- esphome/components/xiaomi_jqjcy01ym/sensor.py | 12 +++--- esphome/components/xiaomi_lywsd02/sensor.py | 8 ++-- .../components/xiaomi_lywsd02mmc/sensor.py | 10 ++--- .../components/xiaomi_lywsd03mmc/sensor.py | 12 +++--- esphome/components/xiaomi_lywsdcgq/sensor.py | 10 ++--- esphome/components/xiaomi_mhoc303/sensor.py | 8 ++-- esphome/components/xiaomi_mhoc401/sensor.py | 12 +++--- esphome/components/xiaomi_miscale/sensor.py | 12 +++--- .../xiaomi_mjyd02yla/binary_sensor.py | 20 ++++----- .../xiaomi_mue4094rt/binary_sensor.py | 9 +--- .../components/xiaomi_rtcgq02lm/__init__.py | 5 +-- .../xiaomi_rtcgq02lm/binary_sensor.py | 6 +-- esphome/components/xiaomi_rtcgq02lm/sensor.py | 6 +-- .../components/xiaomi_wx08zm/binary_sensor.py | 5 +-- esphome/components/xl9535/__init__.py | 4 +- esphome/components/yashima/climate.py | 2 +- esphome/components/zhlt01/climate.py | 2 +- esphome/components/zio_ultrasonic/sensor.py | 7 +--- esphome/components/zyaura/sensor.py | 18 ++++---- requirements_test.txt | 2 +- script/api_protobuf/api_protobuf.py | 8 ++-- script/build_language_schema.py | 24 +++++------ script/run-in-env.py | 4 +- tests/component_tests/conftest.py | 10 ++--- tests/unit_tests/conftest.py | 5 +-- tests/unit_tests/test_cpp_helpers.py | 6 +-- tests/unit_tests/test_helpers.py | 3 +- tests/unit_tests/test_wizard.py | 17 ++++---- 651 files changed, 1962 insertions(+), 2270 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 667a8f2e8b..ff34e60fa4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.9.2 + rev: v0.11.0 hooks: # Run the linter. - id: ruff diff --git a/docker/generate_tags.py b/docker/generate_tags.py index 3fc787d485..31f98c4614 100755 --- a/docker/generate_tags.py +++ b/docker/generate_tags.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -import re import argparse +import re CHANNEL_DEV = "dev" CHANNEL_BETA = "beta" diff --git a/esphome/components/a01nyub/sensor.py b/esphome/components/a01nyub/sensor.py index b57daa0357..e5f4f7ef30 100644 --- a/esphome/components/a01nyub/sensor.py +++ b/esphome/components/a01nyub/sensor.py @@ -1,10 +1,10 @@ import esphome.codegen as cg from esphome.components import sensor, uart from esphome.const import ( + DEVICE_CLASS_DISTANCE, + ICON_ARROW_EXPAND_VERTICAL, STATE_CLASS_MEASUREMENT, UNIT_METER, - ICON_ARROW_EXPAND_VERTICAL, - DEVICE_CLASS_DISTANCE, ) CODEOWNERS = ["@MrSuicideParrot"] diff --git a/esphome/components/a02yyuw/sensor.py b/esphome/components/a02yyuw/sensor.py index d491a51be9..f0bc59ae6c 100644 --- a/esphome/components/a02yyuw/sensor.py +++ b/esphome/components/a02yyuw/sensor.py @@ -1,9 +1,9 @@ import esphome.codegen as cg from esphome.components import sensor, uart from esphome.const import ( - STATE_CLASS_MEASUREMENT, - ICON_ARROW_EXPAND_VERTICAL, DEVICE_CLASS_DISTANCE, + ICON_ARROW_EXPAND_VERTICAL, + STATE_CLASS_MEASUREMENT, UNIT_MILLIMETER, ) diff --git a/esphome/components/a4988/stepper.py b/esphome/components/a4988/stepper.py index 744e9dc1cc..97f5a6fe0f 100644 --- a/esphome/components/a4988/stepper.py +++ b/esphome/components/a4988/stepper.py @@ -1,10 +1,9 @@ from esphome import pins +import esphome.codegen as cg from esphome.components import stepper import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import CONF_DIR_PIN, CONF_ID, CONF_SLEEP_PIN, CONF_STEP_PIN - a4988_ns = cg.esphome_ns.namespace("a4988") A4988 = a4988_ns.class_("A4988", stepper.Stepper, cg.Component) diff --git a/esphome/components/absolute_humidity/sensor.py b/esphome/components/absolute_humidity/sensor.py index f2b075f4d9..62a2c8ab7c 100644 --- a/esphome/components/absolute_humidity/sensor.py +++ b/esphome/components/absolute_humidity/sensor.py @@ -1,12 +1,12 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_EQUATION, CONF_HUMIDITY, CONF_TEMPERATURE, - STATE_CLASS_MEASUREMENT, - CONF_EQUATION, ICON_WATER, + STATE_CLASS_MEASUREMENT, UNIT_GRAMS_PER_CUBIC_METER, ) diff --git a/esphome/components/ac_dimmer/output.py b/esphome/components/ac_dimmer/output.py index c39fc382b6..5e24779510 100644 --- a/esphome/components/ac_dimmer/output.py +++ b/esphome/components/ac_dimmer/output.py @@ -1,8 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import output -from esphome.const import CONF_ID, CONF_MIN_POWER, CONF_METHOD +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_METHOD, CONF_MIN_POWER CODEOWNERS = ["@glmnet"] diff --git a/esphome/components/adalight/__init__.py b/esphome/components/adalight/__init__.py index 919ffecbea..5e122676cd 100644 --- a/esphome/components/adalight/__init__.py +++ b/esphome/components/adalight/__init__.py @@ -1,8 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import uart -from esphome.components.light.types import AddressableLightEffect from esphome.components.light.effects import register_addressable_effect +from esphome.components.light.types import AddressableLightEffect +import esphome.config_validation as cv from esphome.const import CONF_NAME, CONF_UART_ID DEPENDENCIES = ["uart"] diff --git a/esphome/components/adc128s102/__init__.py b/esphome/components/adc128s102/__init__.py index c4e9d5831e..a5281aacc7 100644 --- a/esphome/components/adc128s102/__init__.py +++ b/esphome/components/adc128s102/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import spi +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["spi"] diff --git a/esphome/components/adc128s102/sensor/__init__.py b/esphome/components/adc128s102/sensor/__init__.py index 640a1b628e..a65ae9d537 100644 --- a/esphome/components/adc128s102/sensor/__init__.py +++ b/esphome/components/adc128s102/sensor/__init__.py @@ -1,9 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, voltage_sampler -from esphome.const import CONF_ID, CONF_CHANNEL +import esphome.config_validation as cv +from esphome.const import CONF_CHANNEL, CONF_ID -from .. import adc128s102_ns, ADC128S102 +from .. import ADC128S102, adc128s102_ns AUTO_LOAD = ["voltage_sampler"] DEPENDENCIES = ["adc128s102"] diff --git a/esphome/components/addressable_light/display.py b/esphome/components/addressable_light/display.py index 327ec8296a..929d45121c 100644 --- a/esphome/components/addressable_light/display.py +++ b/esphome/components/addressable_light/display.py @@ -1,15 +1,15 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import display, light +import esphome.config_validation as cv from esphome.const import ( + CONF_ADDRESSABLE_LIGHT_ID, + CONF_HEIGHT, CONF_ID, CONF_LAMBDA, CONF_PAGES, - CONF_ADDRESSABLE_LIGHT_ID, - CONF_HEIGHT, - CONF_WIDTH, - CONF_UPDATE_INTERVAL, CONF_PIXEL_MAPPER, + CONF_UPDATE_INTERVAL, + CONF_WIDTH, ) CODEOWNERS = ["@justfalter"] diff --git a/esphome/components/ade7880/sensor.py b/esphome/components/ade7880/sensor.py index e075adb04c..3ef5e6bfff 100644 --- a/esphome/components/ade7880/sensor.py +++ b/esphome/components/ade7880/sensor.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import sensor, i2c from esphome import pins +import esphome.codegen as cg +from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ACTIVE_POWER, CONF_APPARENT_POWER, diff --git a/esphome/components/ade7953_base/__init__.py b/esphome/components/ade7953_base/__init__.py index af3f629ca8..42b6c8ba24 100644 --- a/esphome/components/ade7953_base/__init__.py +++ b/esphome/components/ade7953_base/__init__.py @@ -1,27 +1,27 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import sensor from esphome import pins +import esphome.codegen as cg +from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_FREQUENCY, CONF_IRQ_PIN, CONF_VOLTAGE, - CONF_FREQUENCY, CONF_VOLTAGE_GAIN, - DEVICE_CLASS_CURRENT, DEVICE_CLASS_APPARENT_POWER, - DEVICE_CLASS_POWER, - DEVICE_CLASS_REACTIVE_POWER, - DEVICE_CLASS_POWER_FACTOR, - DEVICE_CLASS_VOLTAGE, + DEVICE_CLASS_CURRENT, DEVICE_CLASS_FREQUENCY, + DEVICE_CLASS_POWER, + DEVICE_CLASS_POWER_FACTOR, + DEVICE_CLASS_REACTIVE_POWER, + DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, - UNIT_VOLT, - UNIT_HERTZ, UNIT_AMPERE, - UNIT_VOLT_AMPS, - UNIT_WATT, - UNIT_VOLT_AMPS_REACTIVE, + UNIT_HERTZ, UNIT_PERCENT, + UNIT_VOLT, + UNIT_VOLT_AMPS, + UNIT_VOLT_AMPS_REACTIVE, + UNIT_WATT, ) CONF_CURRENT_A = "current_a" diff --git a/esphome/components/ade7953_i2c/sensor.py b/esphome/components/ade7953_i2c/sensor.py index e52a44eced..4b55acdafa 100644 --- a/esphome/components/ade7953_i2c/sensor.py +++ b/esphome/components/ade7953_i2c/sensor.py @@ -1,9 +1,8 @@ import esphome.codegen as cg +from esphome.components import ade7953_base, i2c import esphome.config_validation as cv -from esphome.components import i2c, ade7953_base from esphome.const import CONF_ID - DEPENDENCIES = ["i2c"] AUTO_LOAD = ["ade7953_base"] diff --git a/esphome/components/ade7953_spi/sensor.py b/esphome/components/ade7953_spi/sensor.py index 5f9682c711..dce021daad 100644 --- a/esphome/components/ade7953_spi/sensor.py +++ b/esphome/components/ade7953_spi/sensor.py @@ -1,9 +1,8 @@ import esphome.codegen as cg +from esphome.components import ade7953_base, spi import esphome.config_validation as cv -from esphome.components import spi, ade7953_base from esphome.const import CONF_ID - DEPENDENCIES = ["spi"] AUTO_LOAD = ["ade7953_base"] diff --git a/esphome/components/ads1115/__init__.py b/esphome/components/ads1115/__init__.py index a463d8390d..6d52fc83fd 100644 --- a/esphome/components/ads1115/__init__.py +++ b/esphome/components/ads1115/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["i2c"] diff --git a/esphome/components/ads1115/sensor/__init__.py b/esphome/components/ads1115/sensor/__init__.py index f346a71198..afb70d07c8 100644 --- a/esphome/components/ads1115/sensor/__init__.py +++ b/esphome/components/ads1115/sensor/__init__.py @@ -1,17 +1,18 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, voltage_sampler +import esphome.config_validation as cv from esphome.const import ( CONF_GAIN, + CONF_ID, CONF_MULTIPLEXER, CONF_RESOLUTION, CONF_SAMPLE_RATE, DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, UNIT_VOLT, - CONF_ID, ) -from .. import ads1115_ns, ADS1115Component, CONF_ADS1115_ID + +from .. import CONF_ADS1115_ID, ADS1115Component, ads1115_ns AUTO_LOAD = ["voltage_sampler"] DEPENDENCIES = ["ads1115"] diff --git a/esphome/components/ads1118/__init__.py b/esphome/components/ads1118/__init__.py index f8d51101a6..128e0d0701 100644 --- a/esphome/components/ads1118/__init__.py +++ b/esphome/components/ads1118/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import spi +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@solomondg1"] diff --git a/esphome/components/ads1118/sensor/__init__.py b/esphome/components/ads1118/sensor/__init__.py index 4e89115447..33bfe97789 100644 --- a/esphome/components/ads1118/sensor/__init__.py +++ b/esphome/components/ads1118/sensor/__init__.py @@ -1,17 +1,18 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, voltage_sampler +import esphome.config_validation as cv from esphome.const import ( CONF_GAIN, CONF_MULTIPLEXER, - DEVICE_CLASS_VOLTAGE, + CONF_TYPE, DEVICE_CLASS_TEMPERATURE, + DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_VOLT, - CONF_TYPE, ) -from .. import ads1118_ns, ADS1118, CONF_ADS1118_ID + +from .. import ADS1118, CONF_ADS1118_ID, ads1118_ns AUTO_LOAD = ["voltage_sampler"] DEPENDENCIES = ["ads1118"] diff --git a/esphome/components/ags10/sensor.py b/esphome/components/ags10/sensor.py index 59aebd636b..8f0f372951 100644 --- a/esphome/components/ags10/sensor.py +++ b/esphome/components/ags10/sensor.py @@ -1,21 +1,21 @@ -import esphome.codegen as cg from esphome import automation -import esphome.config_validation as cv +import esphome.codegen as cg from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_ADDRESS, CONF_ID, - ICON_RADIATOR, - ICON_RESTART, + CONF_MODE, + CONF_TVOC, + CONF_VALUE, + CONF_VERSION, DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS, ENTITY_CATEGORY_DIAGNOSTIC, + ICON_RADIATOR, + ICON_RESTART, STATE_CLASS_MEASUREMENT, UNIT_OHM, UNIT_PARTS_PER_BILLION, - CONF_ADDRESS, - CONF_TVOC, - CONF_VERSION, - CONF_MODE, - CONF_VALUE, ) CONF_RESISTANCE = "resistance" diff --git a/esphome/components/aht10/sensor.py b/esphome/components/aht10/sensor.py index 31b07c0e73..a5b1cf0ffb 100644 --- a/esphome/components/aht10/sensor.py +++ b/esphome/components/aht10/sensor.py @@ -1,16 +1,16 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_HUMIDITY, CONF_ID, CONF_TEMPERATURE, + CONF_VARIANT, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - CONF_VARIANT, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/airthings_ble/__init__.py b/esphome/components/airthings_ble/__init__.py index ca94069703..eae400ab39 100644 --- a/esphome/components/airthings_ble/__init__.py +++ b/esphome/components/airthings_ble/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import esp32_ble_tracker +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/airthings_wave_base/__init__.py b/esphome/components/airthings_wave_base/__init__.py index d9b97f1c8d..6a29683ced 100644 --- a/esphome/components/airthings_wave_base/__init__.py +++ b/esphome/components/airthings_wave_base/__init__.py @@ -1,18 +1,17 @@ import esphome.codegen as cg +from esphome.components import ble_client, sensor import esphome.config_validation as cv -from esphome.components import sensor, ble_client - from esphome.const import ( CONF_BATTERY_VOLTAGE, CONF_HUMIDITY, CONF_PRESSURE, CONF_TEMPERATURE, CONF_TVOC, - DEVICE_CLASS_VOLTAGE, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_PRESSURE, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS, + DEVICE_CLASS_VOLTAGE, ENTITY_CATEGORY_DIAGNOSTIC, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, diff --git a/esphome/components/airthings_wave_mini/sensor.py b/esphome/components/airthings_wave_mini/sensor.py index 0f4fd1a13a..f231be6670 100644 --- a/esphome/components/airthings_wave_mini/sensor.py +++ b/esphome/components/airthings_wave_mini/sensor.py @@ -1,10 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import airthings_wave_base - -from esphome.const import ( - CONF_ID, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID DEPENDENCIES = airthings_wave_base.DEPENDENCIES diff --git a/esphome/components/airthings_wave_plus/sensor.py b/esphome/components/airthings_wave_plus/sensor.py index d28c7e2abc..e0e90735f0 100644 --- a/esphome/components/airthings_wave_plus/sensor.py +++ b/esphome/components/airthings_wave_plus/sensor.py @@ -1,20 +1,19 @@ import esphome.codegen as cg +from esphome.components import airthings_wave_base, sensor import esphome.config_validation as cv -from esphome.components import sensor, airthings_wave_base - from esphome.const import ( - DEVICE_CLASS_CARBON_DIOXIDE, - STATE_CLASS_MEASUREMENT, - ICON_RADIOACTIVE, + CONF_CO2, CONF_ID, + CONF_ILLUMINANCE, CONF_RADON, CONF_RADON_LONG_TERM, - CONF_CO2, - UNIT_BECQUEREL_PER_CUBIC_METER, - UNIT_PARTS_PER_MILLION, - CONF_ILLUMINANCE, - UNIT_LUX, + DEVICE_CLASS_CARBON_DIOXIDE, DEVICE_CLASS_ILLUMINANCE, + ICON_RADIOACTIVE, + STATE_CLASS_MEASUREMENT, + UNIT_BECQUEREL_PER_CUBIC_METER, + UNIT_LUX, + UNIT_PARTS_PER_MILLION, ) DEPENDENCIES = airthings_wave_base.DEPENDENCIES diff --git a/esphome/components/alpha3/sensor.py b/esphome/components/alpha3/sensor.py index 55a5d7c620..361e1d101f 100644 --- a/esphome/components/alpha3/sensor.py +++ b/esphome/components/alpha3/sensor.py @@ -1,20 +1,20 @@ import esphome.codegen as cg +from esphome.components import ble_client, sensor import esphome.config_validation as cv -from esphome.components import sensor, ble_client from esphome.const import ( - CONF_ID, CONF_CURRENT, CONF_FLOW, CONF_HEAD, + CONF_ID, CONF_POWER, CONF_SPEED, CONF_VOLTAGE, UNIT_AMPERE, + UNIT_CUBIC_METER_PER_HOUR, + UNIT_METER, + UNIT_REVOLUTIONS_PER_MINUTE, UNIT_VOLT, UNIT_WATT, - UNIT_METER, - UNIT_CUBIC_METER_PER_HOUR, - UNIT_REVOLUTIONS_PER_MINUTE, ) alpha3_ns = cg.esphome_ns.namespace("alpha3") diff --git a/esphome/components/am2315c/sensor.py b/esphome/components/am2315c/sensor.py index f3201b05a2..ec12ab717e 100644 --- a/esphome/components/am2315c/sensor.py +++ b/esphome/components/am2315c/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_HUMIDITY, CONF_ID, diff --git a/esphome/components/am2320/sensor.py b/esphome/components/am2320/sensor.py index ccd37d02c2..ed4a5fd922 100644 --- a/esphome/components/am2320/sensor.py +++ b/esphome/components/am2320/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_HUMIDITY, CONF_ID, diff --git a/esphome/components/am43/cover/__init__.py b/esphome/components/am43/cover/__init__.py index 103ac809e6..d60f9cd4e7 100644 --- a/esphome/components/am43/cover/__init__.py +++ b/esphome/components/am43/cover/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import ble_client, cover import esphome.config_validation as cv -from esphome.components import cover, ble_client from esphome.const import CONF_ID, CONF_PIN CODEOWNERS = ["@buxtronix"] diff --git a/esphome/components/am43/sensor/__init__.py b/esphome/components/am43/sensor/__init__.py index df068546cd..4b3e1716a4 100644 --- a/esphome/components/am43/sensor/__init__.py +++ b/esphome/components/am43/sensor/__init__.py @@ -1,12 +1,12 @@ import esphome.codegen as cg +from esphome.components import ble_client, sensor import esphome.config_validation as cv -from esphome.components import sensor, ble_client from esphome.const import ( - CONF_ID, CONF_BATTERY_LEVEL, + CONF_ID, + CONF_ILLUMINANCE, DEVICE_CLASS_BATTERY, ENTITY_CATEGORY_DIAGNOSTIC, - CONF_ILLUMINANCE, ICON_BRIGHTNESS_5, UNIT_PERCENT, ) diff --git a/esphome/components/analog_threshold/binary_sensor.py b/esphome/components/analog_threshold/binary_sensor.py index 7b964dfae6..775b3e6bbf 100644 --- a/esphome/components/analog_threshold/binary_sensor.py +++ b/esphome/components/analog_threshold/binary_sensor.py @@ -1,10 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor, sensor -from esphome.const import ( - CONF_SENSOR_ID, - CONF_THRESHOLD, -) +import esphome.config_validation as cv +from esphome.const import CONF_SENSOR_ID, CONF_THRESHOLD analog_threshold_ns = cg.esphome_ns.namespace("analog_threshold") diff --git a/esphome/components/anova/climate.py b/esphome/components/anova/climate.py index bdd77d6a33..052296294b 100644 --- a/esphome/components/anova/climate.py +++ b/esphome/components/anova/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import ble_client, climate import esphome.config_validation as cv -from esphome.components import climate, ble_client from esphome.const import CONF_ID, CONF_UNIT_OF_MEASUREMENT UNITS = { diff --git a/esphome/components/apds9306/sensor.py b/esphome/components/apds9306/sensor.py index 25b301444f..c3cba96fbf 100644 --- a/esphome/components/apds9306/sensor.py +++ b/esphome/components/apds9306/sensor.py @@ -2,8 +2,8 @@ # https://www.mouser.ca/datasheet/2/678/AVGO_S_A0002854364_1-2574547.pdf import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_GAIN, DEVICE_CLASS_ILLUMINANCE, diff --git a/esphome/components/apds9960/__init__.py b/esphome/components/apds9960/__init__.py index 06b3c85aee..99e37d3764 100644 --- a/esphome/components/apds9960/__init__.py +++ b/esphome/components/apds9960/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["i2c"] diff --git a/esphome/components/apds9960/binary_sensor.py b/esphome/components/apds9960/binary_sensor.py index 46b08d8d69..48e923ab2b 100644 --- a/esphome/components/apds9960/binary_sensor.py +++ b/esphome/components/apds9960/binary_sensor.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_DIRECTION, DEVICE_CLASS_MOVING + from . import APDS9960, CONF_APDS9960_ID DEPENDENCIES = ["apds9960"] diff --git a/esphome/components/apds9960/sensor.py b/esphome/components/apds9960/sensor.py index c9865f8687..468eb0995f 100644 --- a/esphome/components/apds9960/sensor.py +++ b/esphome/components/apds9960/sensor.py @@ -1,12 +1,13 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_TYPE, + ICON_LIGHTBULB, STATE_CLASS_MEASUREMENT, UNIT_PERCENT, - ICON_LIGHTBULB, ) + from . import APDS9960, CONF_APDS9960_ID DEPENDENCIES = ["apds9960"] diff --git a/esphome/components/as3935/__init__.py b/esphome/components/as3935/__init__.py index 2ec7c50859..70015c53b9 100644 --- a/esphome/components/as3935/__init__.py +++ b/esphome/components/as3935/__init__.py @@ -1,17 +1,17 @@ +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins from esphome.const import ( + CONF_CALIBRATION, CONF_CAPACITANCE, CONF_DIV_RATIO, CONF_INDOOR, CONF_IRQ_PIN, CONF_LIGHTNING_THRESHOLD, CONF_MASK_DISTURBER, - CONF_CALIBRATION, - CONF_TUNE_ANTENNA, CONF_NOISE_LEVEL, CONF_SPIKE_REJECTION, + CONF_TUNE_ANTENNA, CONF_WATCHDOG_THRESHOLD, ) diff --git a/esphome/components/as3935/binary_sensor.py b/esphome/components/as3935/binary_sensor.py index 3081d2115f..10004e69dc 100644 --- a/esphome/components/as3935/binary_sensor.py +++ b/esphome/components/as3935/binary_sensor.py @@ -1,6 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv + from . import AS3935, CONF_AS3935_ID DEPENDENCIES = ["as3935"] diff --git a/esphome/components/as3935/sensor.py b/esphome/components/as3935/sensor.py index ff78b8a050..79bc7af4a9 100644 --- a/esphome/components/as3935/sensor.py +++ b/esphome/components/as3935/sensor.py @@ -1,13 +1,14 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_DISTANCE, CONF_LIGHTNING_ENERGY, - UNIT_KILOMETER, - ICON_SIGNAL_DISTANCE_VARIANT, ICON_FLASH, + ICON_SIGNAL_DISTANCE_VARIANT, + UNIT_KILOMETER, ) + from . import AS3935, CONF_AS3935_ID DEPENDENCIES = ["as3935"] diff --git a/esphome/components/as3935_i2c/__init__.py b/esphome/components/as3935_i2c/__init__.py index aa741b2ea6..09b588cb0c 100644 --- a/esphome/components/as3935_i2c/__init__.py +++ b/esphome/components/as3935_i2c/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import as3935, i2c +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["as3935"] diff --git a/esphome/components/as3935_spi/__init__.py b/esphome/components/as3935_spi/__init__.py index 849539f092..f4cf07a906 100644 --- a/esphome/components/as3935_spi/__init__.py +++ b/esphome/components/as3935_spi/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import as3935, spi +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["as3935"] diff --git a/esphome/components/as5600/__init__.py b/esphome/components/as5600/__init__.py index feeae107a7..1a437a68a2 100644 --- a/esphome/components/as5600/__init__.py +++ b/esphome/components/as5600/__init__.py @@ -1,12 +1,12 @@ from esphome import pins import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_DIR_PIN, CONF_DIRECTION, CONF_HYSTERESIS, + CONF_ID, CONF_RANGE, ) diff --git a/esphome/components/as5600/sensor/__init__.py b/esphome/components/as5600/sensor/__init__.py index 30337ab61b..cfc38d796d 100644 --- a/esphome/components/as5600/sensor/__init__.py +++ b/esphome/components/as5600/sensor/__init__.py @@ -1,19 +1,20 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_ANGLE, + CONF_GAIN, CONF_ID, - STATE_CLASS_MEASUREMENT, + CONF_MAGNITUDE, + CONF_POSITION, + CONF_STATUS, + ENTITY_CATEGORY_DIAGNOSTIC, ICON_MAGNET, ICON_ROTATE_RIGHT, - CONF_GAIN, - ENTITY_CATEGORY_DIAGNOSTIC, - CONF_MAGNITUDE, - CONF_STATUS, - CONF_POSITION, - CONF_ANGLE, + STATE_CLASS_MEASUREMENT, ) -from .. import as5600_ns, AS5600Component + +from .. import AS5600Component, as5600_ns CODEOWNERS = ["@ammmze"] DEPENDENCIES = ["as5600"] diff --git a/esphome/components/as7341/sensor.py b/esphome/components/as7341/sensor.py index de60444aed..2832b7c3df 100644 --- a/esphome/components/as7341/sensor.py +++ b/esphome/components/as7341/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_GAIN, CONF_ID, @@ -9,7 +9,6 @@ from esphome.const import ( STATE_CLASS_MEASUREMENT, ) - CODEOWNERS = ["@mrgnr"] DEPENDENCIES = ["i2c"] diff --git a/esphome/components/at581x/__init__.py b/esphome/components/at581x/__init__.py index e636510a4b..117ada123d 100644 --- a/esphome/components/at581x/__init__.py +++ b/esphome/components/at581x/__init__.py @@ -1,13 +1,9 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation, core -from esphome.components import i2c from esphome.automation import maybe_simple_id -from esphome.const import ( - CONF_ID, - CONF_FREQUENCY, -) - +import esphome.codegen as cg +from esphome.components import i2c +import esphome.config_validation as cv +from esphome.const import CONF_FREQUENCY, CONF_ID CODEOWNERS = ["@X-Ryl669"] DEPENDENCIES = ["i2c"] diff --git a/esphome/components/at581x/switch/__init__.py b/esphome/components/at581x/switch/__init__.py index c441b381a3..8e1b82b356 100644 --- a/esphome/components/at581x/switch/__init__.py +++ b/esphome/components/at581x/switch/__init__.py @@ -1,10 +1,8 @@ import esphome.codegen as cg from esphome.components import switch import esphome.config_validation as cv -from esphome.const import ( - DEVICE_CLASS_SWITCH, - ICON_WIFI, -) +from esphome.const import DEVICE_CLASS_SWITCH, ICON_WIFI + from .. import CONF_AT581X_ID, AT581XComponent, at581x_ns DEPENDENCIES = ["at581x"] diff --git a/esphome/components/atc_mithermometer/sensor.py b/esphome/components/atc_mithermometer/sensor.py index e86afa500d..5286d29d1b 100644 --- a/esphome/components/atc_mithermometer/sensor.py +++ b/esphome/components/atc_mithermometer/sensor.py @@ -1,14 +1,14 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, CONF_BATTERY_VOLTAGE, - CONF_MAC_ADDRESS, CONF_HUMIDITY, + CONF_ID, + CONF_MAC_ADDRESS, CONF_SIGNAL_STRENGTH, CONF_TEMPERATURE, - CONF_ID, DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_SIGNAL_STRENGTH, diff --git a/esphome/components/b_parasite/sensor.py b/esphome/components/b_parasite/sensor.py index 86eef29b14..041303ad8b 100644 --- a/esphome/components/b_parasite/sensor.py +++ b/esphome/components/b_parasite/sensor.py @@ -1,13 +1,13 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_VOLTAGE, CONF_HUMIDITY, CONF_ID, CONF_ILLUMINANCE, - CONF_MOISTURE, CONF_MAC_ADDRESS, + CONF_MOISTURE, CONF_TEMPERATURE, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, diff --git a/esphome/components/ballu/climate.py b/esphome/components/ballu/climate.py index 82e9fead1e..416fa250cc 100644 --- a/esphome/components/ballu/climate.py +++ b/esphome/components/ballu/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/bang_bang/climate.py b/esphome/components/bang_bang/climate.py index 9dde0ae1ac..6511270f60 100644 --- a/esphome/components/bang_bang/climate.py +++ b/esphome/components/bang_bang/climate.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import climate, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_AWAY_CONFIG, CONF_COOL_ACTION, diff --git a/esphome/components/bedjet/__init__.py b/esphome/components/bedjet/__init__.py index a4b8a50eab..d4bf813846 100644 --- a/esphome/components/bedjet/__init__.py +++ b/esphome/components/bedjet/__init__.py @@ -1,11 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import ble_client, time -from esphome.const import ( - CONF_ID, - CONF_RECEIVE_TIMEOUT, - CONF_TIME_ID, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_RECEIVE_TIMEOUT, CONF_TIME_ID CODEOWNERS = ["@jhansche"] DEPENDENCIES = ["ble_client"] diff --git a/esphome/components/bedjet/climate/__init__.py b/esphome/components/bedjet/climate/__init__.py index e454b0922b..7ba3e439b2 100644 --- a/esphome/components/bedjet/climate/__init__.py +++ b/esphome/components/bedjet/climate/__init__.py @@ -1,8 +1,8 @@ import logging import esphome.codegen as cg +from esphome.components import ble_client, climate import esphome.config_validation as cv -from esphome.components import climate, ble_client from esphome.const import ( CONF_HEAT_MODE, CONF_ID, @@ -10,11 +10,8 @@ from esphome.const import ( CONF_TEMPERATURE_SOURCE, CONF_TIME_ID, ) -from .. import ( - BEDJET_CLIENT_SCHEMA, - bedjet_ns, - register_bedjet_child, -) + +from .. import BEDJET_CLIENT_SCHEMA, bedjet_ns, register_bedjet_child _LOGGER = logging.getLogger(__name__) CODEOWNERS = ["@jhansche"] diff --git a/esphome/components/bedjet/fan/__init__.py b/esphome/components/bedjet/fan/__init__.py index 06e81ea979..fdf0636153 100644 --- a/esphome/components/bedjet/fan/__init__.py +++ b/esphome/components/bedjet/fan/__init__.py @@ -1,16 +1,11 @@ import logging import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import fan -from esphome.const import ( - CONF_ID, -) -from .. import ( - BEDJET_CLIENT_SCHEMA, - bedjet_ns, - register_bedjet_child, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID + +from .. import BEDJET_CLIENT_SCHEMA, bedjet_ns, register_bedjet_child _LOGGER = logging.getLogger(__name__) CODEOWNERS = ["@jhansche"] diff --git a/esphome/components/bedjet/sensor/__init__.py b/esphome/components/bedjet/sensor/__init__.py index 756b31de53..fa9ca7953e 100644 --- a/esphome/components/bedjet/sensor/__init__.py +++ b/esphome/components/bedjet/sensor/__init__.py @@ -1,19 +1,16 @@ import logging import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, ) -from .. import ( - BEDJET_CLIENT_SCHEMA, - bedjet_ns, - register_bedjet_child, -) + +from .. import BEDJET_CLIENT_SCHEMA, bedjet_ns, register_bedjet_child _LOGGER = logging.getLogger(__name__) CODEOWNERS = ["@jhansche", "@javawizard"] diff --git a/esphome/components/beken_spi_led_strip/light.py b/esphome/components/beken_spi_led_strip/light.py index 2a1aa05c79..31572cd800 100644 --- a/esphome/components/beken_spi_led_strip/light.py +++ b/esphome/components/beken_spi_led_strip/light.py @@ -1,9 +1,9 @@ from dataclasses import dataclass -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import libretiny, light +import esphome.config_validation as cv from esphome.const import ( CONF_CHIPSET, CONF_IS_RGBW, diff --git a/esphome/components/bh1750/sensor.py b/esphome/components/bh1750/sensor.py index 69778f49ce..7c7eecb88c 100644 --- a/esphome/components/bh1750/sensor.py +++ b/esphome/components/bh1750/sensor.py @@ -1,11 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor -from esphome.const import ( - DEVICE_CLASS_ILLUMINANCE, - STATE_CLASS_MEASUREMENT, - UNIT_LUX, -) +import esphome.config_validation as cv +from esphome.const import DEVICE_CLASS_ILLUMINANCE, STATE_CLASS_MEASUREMENT, UNIT_LUX DEPENDENCIES = ["i2c"] CODEOWNERS = ["@OttoWinter"] diff --git a/esphome/components/binary/fan/__init__.py b/esphome/components/binary/fan/__init__.py index 73d6b9339f..a504ef642c 100644 --- a/esphome/components/binary/fan/__init__.py +++ b/esphome/components/binary/fan/__init__.py @@ -1,12 +1,13 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import fan, output +import esphome.config_validation as cv from esphome.const import ( CONF_DIRECTION_OUTPUT, CONF_OSCILLATION_OUTPUT, CONF_OUTPUT, CONF_OUTPUT_ID, ) + from .. import binary_ns BinaryFan = binary_ns.class_("BinaryFan", fan.Fan, cg.Component) diff --git a/esphome/components/binary/light/__init__.py b/esphome/components/binary/light/__init__.py index 49227ccadc..ebb22f4409 100644 --- a/esphome/components/binary/light/__init__.py +++ b/esphome/components/binary/light/__init__.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import light, output -from esphome.const import CONF_OUTPUT_ID, CONF_OUTPUT +import esphome.config_validation as cv +from esphome.const import CONF_OUTPUT, CONF_OUTPUT_ID + from .. import binary_ns BinaryLightOutput = binary_ns.class_("BinaryLightOutput", light.LightOutput) diff --git a/esphome/components/binary_sensor_map/sensor.py b/esphome/components/binary_sensor_map/sensor.py index 1181905f30..965e332e28 100644 --- a/esphome/components/binary_sensor_map/sensor.py +++ b/esphome/components/binary_sensor_map/sensor.py @@ -1,15 +1,14 @@ import esphome.codegen as cg +from esphome.components import binary_sensor, sensor import esphome.config_validation as cv - -from esphome.components import sensor, binary_sensor from esphome.const import ( - CONF_CHANNELS, - CONF_VALUE, - CONF_TYPE, - ICON_CHECK_CIRCLE_OUTLINE, CONF_BINARY_SENSOR, + CONF_CHANNELS, CONF_GROUP, CONF_SUM, + CONF_TYPE, + CONF_VALUE, + ICON_CHECK_CIRCLE_OUTLINE, ) DEPENDENCIES = ["binary_sensor"] diff --git a/esphome/components/bl0939/sensor.py b/esphome/components/bl0939/sensor.py index 2a85b34567..bd4bdd93e5 100644 --- a/esphome/components/bl0939/sensor.py +++ b/esphome/components/bl0939/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_VOLTAGE, diff --git a/esphome/components/bl0940/sensor.py b/esphome/components/bl0940/sensor.py index 5cb1472d76..f49e961f0a 100644 --- a/esphome/components/bl0940/sensor.py +++ b/esphome/components/bl0940/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( CONF_CURRENT, CONF_ENERGY, @@ -12,15 +12,15 @@ from esphome.const import ( DEVICE_CLASS_CURRENT, DEVICE_CLASS_ENERGY, DEVICE_CLASS_POWER, - DEVICE_CLASS_VOLTAGE, DEVICE_CLASS_TEMPERATURE, + DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, + STATE_CLASS_TOTAL_INCREASING, UNIT_AMPERE, UNIT_CELSIUS, UNIT_KILOWATT_HOURS, UNIT_VOLT, UNIT_WATT, - STATE_CLASS_TOTAL_INCREASING, ) DEPENDENCIES = ["uart"] diff --git a/esphome/components/ble_client/sensor/__init__.py b/esphome/components/ble_client/sensor/__init__.py index 960410a5cc..0975640ece 100644 --- a/esphome/components/ble_client/sensor/__init__.py +++ b/esphome/components/ble_client/sensor/__init__.py @@ -5,13 +5,13 @@ import esphome.config_validation as cv from esphome.const import ( CONF_CHARACTERISTIC_UUID, CONF_LAMBDA, + CONF_NOTIFY, CONF_SERVICE_UUID, CONF_TRIGGER_ID, CONF_TYPE, DEVICE_CLASS_SIGNAL_STRENGTH, STATE_CLASS_MEASUREMENT, UNIT_DECIBEL_MILLIWATT, - CONF_NOTIFY, ) from .. import ble_client_ns diff --git a/esphome/components/ble_client/text_sensor/__init__.py b/esphome/components/ble_client/text_sensor/__init__.py index a6672e68f5..afa60f6c0c 100644 --- a/esphome/components/ble_client/text_sensor/__init__.py +++ b/esphome/components/ble_client/text_sensor/__init__.py @@ -5,8 +5,8 @@ import esphome.config_validation as cv from esphome.const import ( CONF_CHARACTERISTIC_UUID, CONF_ID, - CONF_SERVICE_UUID, CONF_NOTIFY, + CONF_SERVICE_UUID, CONF_TRIGGER_ID, ) diff --git a/esphome/components/bluetooth_proxy/__init__.py b/esphome/components/bluetooth_proxy/__init__.py index 5a4ba36666..edfea50473 100644 --- a/esphome/components/bluetooth_proxy/__init__.py +++ b/esphome/components/bluetooth_proxy/__init__.py @@ -34,13 +34,10 @@ def validate_connections(config): raise cv.Invalid( "Connections can only be used if the proxy is set to active" ) - else: - if config[CONF_ACTIVE]: - conf = config.copy() - conf[CONF_CONNECTIONS] = [ - CONNECTION_SCHEMA({}) for _ in range(MAX_CONNECTIONS) - ] - return conf + elif config[CONF_ACTIVE]: + conf = config.copy() + conf[CONF_CONNECTIONS] = [CONNECTION_SCHEMA({}) for _ in range(MAX_CONNECTIONS)] + return conf return config diff --git a/esphome/components/bme280_base/__init__.py b/esphome/components/bme280_base/__init__.py index 6a5f7e1127..c37191bc07 100644 --- a/esphome/components/bme280_base/__init__.py +++ b/esphome/components/bme280_base/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_HUMIDITY, CONF_ID, diff --git a/esphome/components/bme280_i2c/sensor.py b/esphome/components/bme280_i2c/sensor.py index f3007ebaac..1c37033613 100644 --- a/esphome/components/bme280_i2c/sensor.py +++ b/esphome/components/bme280_i2c/sensor.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c -from ..bme280_base import to_code_base, CONFIG_SCHEMA_BASE +import esphome.config_validation as cv + +from ..bme280_base import CONFIG_SCHEMA_BASE, to_code_base AUTO_LOAD = ["bme280_base"] DEPENDENCIES = ["i2c"] diff --git a/esphome/components/bme280_spi/sensor.py b/esphome/components/bme280_spi/sensor.py index 33a12318a5..7f4fb5cf44 100644 --- a/esphome/components/bme280_spi/sensor.py +++ b/esphome/components/bme280_spi/sensor.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import spi -from ..bme280_base import to_code_base, CONFIG_SCHEMA_BASE +import esphome.config_validation as cv + +from ..bme280_base import CONFIG_SCHEMA_BASE, to_code_base AUTO_LOAD = ["bme280_base"] CODEOWNERS = ["@apbodrov"] diff --git a/esphome/components/bme680/sensor.py b/esphome/components/bme680/sensor.py index 586b454697..5937ac6ad8 100644 --- a/esphome/components/bme680/sensor.py +++ b/esphome/components/bme680/sensor.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import core +import esphome.codegen as cg from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_DURATION, CONF_GAS_RESISTANCE, @@ -15,11 +15,11 @@ from esphome.const import ( DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_PRESSURE, DEVICE_CLASS_TEMPERATURE, - STATE_CLASS_MEASUREMENT, - UNIT_OHM, ICON_GAS_CYLINDER, + STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_HECTOPASCAL, + UNIT_OHM, UNIT_PERCENT, ) diff --git a/esphome/components/bme680_bsec/__init__.py b/esphome/components/bme680_bsec/__init__.py index 743ef6e85d..8ee463a59a 100644 --- a/esphome/components/bme680_bsec/__init__.py +++ b/esphome/components/bme680_bsec/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import esp32, i2c import esphome.config_validation as cv -from esphome.components import i2c, esp32 from esphome.const import CONF_ID, CONF_SAMPLE_RATE, CONF_TEMPERATURE_OFFSET CODEOWNERS = ["@trvrnrth"] diff --git a/esphome/components/bme680_bsec/sensor.py b/esphome/components/bme680_bsec/sensor.py index aa96998232..5107b0bfcd 100644 --- a/esphome/components/bme680_bsec/sensor.py +++ b/esphome/components/bme680_bsec/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_GAS_RESISTANCE, CONF_HUMIDITY, @@ -22,11 +22,8 @@ from esphome.const import ( UNIT_PARTS_PER_MILLION, UNIT_PERCENT, ) -from . import ( - BME680BSECComponent, - CONF_BME680_BSEC_ID, - SAMPLE_RATE_OPTIONS, -) + +from . import CONF_BME680_BSEC_ID, SAMPLE_RATE_OPTIONS, BME680BSECComponent DEPENDENCIES = ["bme680_bsec"] diff --git a/esphome/components/bme680_bsec/text_sensor.py b/esphome/components/bme680_bsec/text_sensor.py index 6b46e501da..1fbb9e2aeb 100644 --- a/esphome/components/bme680_bsec/text_sensor.py +++ b/esphome/components/bme680_bsec/text_sensor.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor +import esphome.config_validation as cv from esphome.const import CONF_IAQ_ACCURACY -from . import BME680BSECComponent, CONF_BME680_BSEC_ID + +from . import CONF_BME680_BSEC_ID, BME680BSECComponent DEPENDENCIES = ["bme680_bsec"] diff --git a/esphome/components/bmi160/sensor.py b/esphome/components/bmi160/sensor.py index baf185f95a..cc4037c1ee 100644 --- a/esphome/components/bmi160/sensor.py +++ b/esphome/components/bmi160/sensor.py @@ -1,26 +1,26 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, - CONF_TEMPERATURE, CONF_ACCELERATION_X, CONF_ACCELERATION_Y, CONF_ACCELERATION_Z, CONF_GYROSCOPE_X, CONF_GYROSCOPE_Y, CONF_GYROSCOPE_Z, + CONF_ID, + CONF_TEMPERATURE, DEVICE_CLASS_TEMPERATURE, - STATE_CLASS_MEASUREMENT, - UNIT_METER_PER_SECOND_SQUARED, ICON_ACCELERATION_X, ICON_ACCELERATION_Y, ICON_ACCELERATION_Z, ICON_GYROSCOPE_X, ICON_GYROSCOPE_Y, ICON_GYROSCOPE_Z, - UNIT_DEGREE_PER_SECOND, + STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, + UNIT_DEGREE_PER_SECOND, + UNIT_METER_PER_SECOND_SQUARED, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/bmp085/sensor.py b/esphome/components/bmp085/sensor.py index 83f5a0c821..6e51984e1f 100644 --- a/esphome/components/bmp085/sensor.py +++ b/esphome/components/bmp085/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_PRESSURE, diff --git a/esphome/components/bmp280_base/__init__.py b/esphome/components/bmp280_base/__init__.py index c0f9af9dd7..d612920dd4 100644 --- a/esphome/components/bmp280_base/__init__.py +++ b/esphome/components/bmp280_base/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_IIR_FILTER, diff --git a/esphome/components/bmp280_i2c/sensor.py b/esphome/components/bmp280_i2c/sensor.py index 991bb827a3..3ff556d51a 100644 --- a/esphome/components/bmp280_i2c/sensor.py +++ b/esphome/components/bmp280_i2c/sensor.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c -from ..bmp280_base import to_code_base, CONFIG_SCHEMA_BASE +import esphome.config_validation as cv + +from ..bmp280_base import CONFIG_SCHEMA_BASE, to_code_base AUTO_LOAD = ["bmp280_base"] CODEOWNERS = ["@ademuri"] diff --git a/esphome/components/bmp280_spi/sensor.py b/esphome/components/bmp280_spi/sensor.py index 511d45b24e..b3678ec01d 100644 --- a/esphome/components/bmp280_spi/sensor.py +++ b/esphome/components/bmp280_spi/sensor.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import spi -from ..bmp280_base import to_code_base, CONFIG_SCHEMA_BASE +import esphome.config_validation as cv + +from ..bmp280_base import CONFIG_SCHEMA_BASE, to_code_base AUTO_LOAD = ["bmp280_base"] CODEOWNERS = ["@ademuri"] diff --git a/esphome/components/bmp3xx_base/__init__.py b/esphome/components/bmp3xx_base/__init__.py index 589d170907..c31db31761 100644 --- a/esphome/components/bmp3xx_base/__init__.py +++ b/esphome/components/bmp3xx_base/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_IIR_FILTER, diff --git a/esphome/components/bmp3xx_i2c/sensor.py b/esphome/components/bmp3xx_i2c/sensor.py index ae59d29e89..6fed9fc9ee 100644 --- a/esphome/components/bmp3xx_i2c/sensor.py +++ b/esphome/components/bmp3xx_i2c/sensor.py @@ -1,6 +1,7 @@ import esphome.codegen as cg from esphome.components import i2c -from ..bmp3xx_base import to_code_base, cv, CONFIG_SCHEMA_BASE + +from ..bmp3xx_base import CONFIG_SCHEMA_BASE, cv, to_code_base AUTO_LOAD = ["bmp3xx_base"] CODEOWNERS = ["@latonita"] diff --git a/esphome/components/bmp3xx_spi/sensor.py b/esphome/components/bmp3xx_spi/sensor.py index 3d1acd3c1b..22aab71977 100644 --- a/esphome/components/bmp3xx_spi/sensor.py +++ b/esphome/components/bmp3xx_spi/sensor.py @@ -1,6 +1,7 @@ import esphome.codegen as cg from esphome.components import spi -from ..bmp3xx_base import to_code_base, cv, CONFIG_SCHEMA_BASE + +from ..bmp3xx_base import CONFIG_SCHEMA_BASE, cv, to_code_base AUTO_LOAD = ["bmp3xx_base"] CODEOWNERS = ["@latonita"] diff --git a/esphome/components/bmp581/sensor.py b/esphome/components/bmp581/sensor.py index 1e0350075a..e2790f83b9 100644 --- a/esphome/components/bmp581/sensor.py +++ b/esphome/components/bmp581/sensor.py @@ -1,7 +1,8 @@ import math + import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_IIR_FILTER, diff --git a/esphome/components/bp1658cj/__init__.py b/esphome/components/bp1658cj/__init__.py index 8388b16df9..dc80c67b44 100644 --- a/esphome/components/bp1658cj/__init__.py +++ b/esphome/components/bp1658cj/__init__.py @@ -1,11 +1,7 @@ +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins -from esphome.const import ( - CONF_CLOCK_PIN, - CONF_DATA_PIN, - CONF_ID, -) +from esphome.const import CONF_CLOCK_PIN, CONF_DATA_PIN, CONF_ID CODEOWNERS = ["@Cossid"] MULTI_CONF = True diff --git a/esphome/components/bp1658cj/output.py b/esphome/components/bp1658cj/output.py index 3b89518621..023b6ecd1e 100644 --- a/esphome/components/bp1658cj/output.py +++ b/esphome/components/bp1658cj/output.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL, CONF_ID + from . import BP1658CJ DEPENDENCIES = ["bp1658cj"] diff --git a/esphome/components/bp5758d/__init__.py b/esphome/components/bp5758d/__init__.py index eeeab2a1bd..af78b38ef5 100644 --- a/esphome/components/bp5758d/__init__.py +++ b/esphome/components/bp5758d/__init__.py @@ -1,11 +1,7 @@ +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins -from esphome.const import ( - CONF_CLOCK_PIN, - CONF_DATA_PIN, - CONF_ID, -) +from esphome.const import CONF_CLOCK_PIN, CONF_DATA_PIN, CONF_ID CODEOWNERS = ["@Cossid"] MULTI_CONF = True diff --git a/esphome/components/bp5758d/output.py b/esphome/components/bp5758d/output.py index d0083fb33f..9adf13de55 100644 --- a/esphome/components/bp5758d/output.py +++ b/esphome/components/bp5758d/output.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output -from esphome.const import CONF_CHANNEL, CONF_ID, CONF_CURRENT +import esphome.config_validation as cv +from esphome.const import CONF_CHANNEL, CONF_CURRENT, CONF_ID + from . import BP5758D DEPENDENCIES = ["bp5758d"] diff --git a/esphome/components/canbus/__init__.py b/esphome/components/canbus/__init__.py index 76e77021ad..cb3634917e 100644 --- a/esphome/components/canbus/__init__.py +++ b/esphome/components/canbus/__init__.py @@ -1,8 +1,8 @@ +from esphome import automation import esphome.codegen as cg import esphome.config_validation as cv -from esphome import automation +from esphome.const import CONF_DATA, CONF_ID, CONF_TRIGGER_ID from esphome.core import CORE -from esphome.const import CONF_ID, CONF_TRIGGER_ID, CONF_DATA CODEOWNERS = ["@mvturnho", "@danielschramm"] IS_PLATFORM_COMPONENT = True diff --git a/esphome/components/cap1188/__init__.py b/esphome/components/cap1188/__init__.py index f22e6d6c9e..cde9dd46ae 100644 --- a/esphome/components/cap1188/__init__.py +++ b/esphome/components/cap1188/__init__.py @@ -1,8 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import i2c -from esphome.const import CONF_ID, CONF_RESET_PIN from esphome import pins +import esphome.codegen as cg +from esphome.components import i2c +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_RESET_PIN CONF_TOUCH_THRESHOLD = "touch_threshold" CONF_ALLOW_MULTIPLE_TOUCHES = "allow_multiple_touches" diff --git a/esphome/components/cap1188/binary_sensor.py b/esphome/components/cap1188/binary_sensor.py index 7950774340..b7af53638a 100644 --- a/esphome/components/cap1188/binary_sensor.py +++ b/esphome/components/cap1188/binary_sensor.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL -from . import cap1188_ns, CAP1188Component, CONF_CAP1188_ID + +from . import CONF_CAP1188_ID, CAP1188Component, cap1188_ns DEPENDENCIES = ["cap1188"] CAP1188Channel = cap1188_ns.class_("CAP1188Channel", binary_sensor.BinarySensor) diff --git a/esphome/components/captive_portal/__init__.py b/esphome/components/captive_portal/__init__.py index a90ea14c4e..ea11e733ac 100644 --- a/esphome/components/captive_portal/__init__.py +++ b/esphome/components/captive_portal/__init__.py @@ -1,15 +1,15 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import web_server_base from esphome.components.web_server_base import CONF_WEB_SERVER_BASE_ID +import esphome.config_validation as cv from esphome.const import ( CONF_ID, + PLATFORM_BK72XX, PLATFORM_ESP32, PLATFORM_ESP8266, - PLATFORM_BK72XX, PLATFORM_RTL87XX, ) -from esphome.core import coroutine_with_priority, CORE +from esphome.core import CORE, coroutine_with_priority AUTO_LOAD = ["web_server_base"] DEPENDENCIES = ["wifi"] diff --git a/esphome/components/ccs811/sensor.py b/esphome/components/ccs811/sensor.py index 66d9274fe8..10565cb328 100644 --- a/esphome/components/ccs811/sensor.py +++ b/esphome/components/ccs811/sensor.py @@ -1,22 +1,22 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor, text_sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, - ICON_RADIATOR, - ICON_RESTART, - DEVICE_CLASS_CARBON_DIOXIDE, - DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS, - STATE_CLASS_MEASUREMENT, - UNIT_PARTS_PER_MILLION, - UNIT_PARTS_PER_BILLION, CONF_BASELINE, CONF_ECO2, + CONF_HUMIDITY, + CONF_ID, CONF_TEMPERATURE, CONF_TVOC, - CONF_HUMIDITY, CONF_VERSION, + DEVICE_CLASS_CARBON_DIOXIDE, + DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS, ICON_MOLECULE_CO2, + ICON_RADIATOR, + ICON_RESTART, + STATE_CLASS_MEASUREMENT, + UNIT_PARTS_PER_BILLION, + UNIT_PARTS_PER_MILLION, ) AUTO_LOAD = ["text_sensor"] diff --git a/esphome/components/cd74hc4067/__init__.py b/esphome/components/cd74hc4067/__init__.py index d57061b710..9b69576b43 100644 --- a/esphome/components/cd74hc4067/__init__.py +++ b/esphome/components/cd74hc4067/__init__.py @@ -1,10 +1,7 @@ -import esphome.codegen as cg from esphome import pins +import esphome.codegen as cg import esphome.config_validation as cv -from esphome.const import ( - CONF_DELAY, - CONF_ID, -) +from esphome.const import CONF_DELAY, CONF_ID AUTO_LOAD = ["sensor", "voltage_sampler"] CODEOWNERS = ["@asoehlke"] diff --git a/esphome/components/cd74hc4067/sensor.py b/esphome/components/cd74hc4067/sensor.py index 3eee34b85e..dceaf6f371 100644 --- a/esphome/components/cd74hc4067/sensor.py +++ b/esphome/components/cd74hc4067/sensor.py @@ -1,16 +1,17 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, voltage_sampler +import esphome.config_validation as cv from esphome.const import ( CONF_ID, - CONF_SENSOR, CONF_NUMBER, - ICON_FLASH, - UNIT_VOLT, - STATE_CLASS_MEASUREMENT, + CONF_SENSOR, DEVICE_CLASS_VOLTAGE, + ICON_FLASH, + STATE_CLASS_MEASUREMENT, + UNIT_VOLT, ) -from . import cd74hc4067_ns, CD74HC4067Component + +from . import CD74HC4067Component, cd74hc4067_ns DEPENDENCIES = ["cd74hc4067"] diff --git a/esphome/components/climate_ir/__init__.py b/esphome/components/climate_ir/__init__.py index c7c286d679..d8be61397e 100644 --- a/esphome/components/climate_ir/__init__.py +++ b/esphome/components/climate_ir/__init__.py @@ -1,7 +1,7 @@ import esphome.codegen as cg +from esphome.components import climate, remote_base, sensor import esphome.config_validation as cv -from esphome.components import climate, sensor, remote_base -from esphome.const import CONF_SUPPORTS_COOL, CONF_SUPPORTS_HEAT, CONF_SENSOR +from esphome.const import CONF_SENSOR, CONF_SUPPORTS_COOL, CONF_SUPPORTS_HEAT DEPENDENCIES = ["remote_transmitter"] AUTO_LOAD = ["sensor", "remote_base"] diff --git a/esphome/components/climate_ir_lg/climate.py b/esphome/components/climate_ir_lg/climate.py index c58e40f7f4..76d4c00baf 100644 --- a/esphome/components/climate_ir_lg/climate.py +++ b/esphome/components/climate_ir_lg/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/color/__init__.py b/esphome/components/color/__init__.py index 609d416a0b..c3381cfd70 100644 --- a/esphome/components/color/__init__.py +++ b/esphome/components/color/__init__.py @@ -1,5 +1,4 @@ -from esphome import config_validation as cv -from esphome import codegen as cg +from esphome import codegen as cg, config_validation as cv from esphome.const import CONF_BLUE, CONF_GREEN, CONF_ID, CONF_RED, CONF_WHITE ColorStruct = cg.esphome_ns.struct("Color") diff --git a/esphome/components/color_temperature/light.py b/esphome/components/color_temperature/light.py index 3e7a0e73ae..045ab265cd 100644 --- a/esphome/components/color_temperature/light.py +++ b/esphome/components/color_temperature/light.py @@ -1,11 +1,11 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import light, output +import esphome.config_validation as cv from esphome.const import ( CONF_BRIGHTNESS, + CONF_COLD_WHITE_COLOR_TEMPERATURE, CONF_COLOR_TEMPERATURE, CONF_OUTPUT_ID, - CONF_COLD_WHITE_COLOR_TEMPERATURE, CONF_WARM_WHITE_COLOR_TEMPERATURE, ) diff --git a/esphome/components/combination/sensor.py b/esphome/components/combination/sensor.py index fad0277061..f5255fec03 100644 --- a/esphome/components/combination/sensor.py +++ b/esphome/components/combination/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ACCURACY_DECIMALS, CONF_DEVICE_CLASS, diff --git a/esphome/components/coolix/climate.py b/esphome/components/coolix/climate.py index 2cfd1912e5..339e7de906 100644 --- a/esphome/components/coolix/climate.py +++ b/esphome/components/coolix/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/copy/binary_sensor/__init__.py b/esphome/components/copy/binary_sensor/__init__.py index 1b6836fae7..840200409f 100644 --- a/esphome/components/copy/binary_sensor/__init__.py +++ b/esphome/components/copy/binary_sensor/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import ( CONF_DEVICE_CLASS, CONF_ENTITY_CATEGORY, diff --git a/esphome/components/copy/button/__init__.py b/esphome/components/copy/button/__init__.py index 626a5a8db1..8028d6a217 100644 --- a/esphome/components/copy/button/__init__.py +++ b/esphome/components/copy/button/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import button +import esphome.config_validation as cv from esphome.const import ( CONF_DEVICE_CLASS, CONF_ENTITY_CATEGORY, diff --git a/esphome/components/copy/cover/__init__.py b/esphome/components/copy/cover/__init__.py index 155e22883b..7db9034d02 100644 --- a/esphome/components/copy/cover/__init__.py +++ b/esphome/components/copy/cover/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import cover +import esphome.config_validation as cv from esphome.const import ( CONF_DEVICE_CLASS, CONF_ENTITY_CATEGORY, diff --git a/esphome/components/copy/fan/__init__.py b/esphome/components/copy/fan/__init__.py index 22672c02d8..04872fb029 100644 --- a/esphome/components/copy/fan/__init__.py +++ b/esphome/components/copy/fan/__init__.py @@ -1,12 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import fan -from esphome.const import ( - CONF_ENTITY_CATEGORY, - CONF_ICON, - CONF_ID, - CONF_SOURCE_ID, -) +import esphome.config_validation as cv +from esphome.const import CONF_ENTITY_CATEGORY, CONF_ICON, CONF_ID, CONF_SOURCE_ID from esphome.core.entity_helpers import inherit_property_from from .. import copy_ns diff --git a/esphome/components/copy/lock/__init__.py b/esphome/components/copy/lock/__init__.py index d19e4a5807..ddedea64c0 100644 --- a/esphome/components/copy/lock/__init__.py +++ b/esphome/components/copy/lock/__init__.py @@ -1,12 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import lock -from esphome.const import ( - CONF_ENTITY_CATEGORY, - CONF_ICON, - CONF_ID, - CONF_SOURCE_ID, -) +import esphome.config_validation as cv +from esphome.const import CONF_ENTITY_CATEGORY, CONF_ICON, CONF_ID, CONF_SOURCE_ID from esphome.core.entity_helpers import inherit_property_from from .. import copy_ns diff --git a/esphome/components/copy/number/__init__.py b/esphome/components/copy/number/__init__.py index 204518da39..3e2bbf2aae 100644 --- a/esphome/components/copy/number/__init__.py +++ b/esphome/components/copy/number/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import number +import esphome.config_validation as cv from esphome.const import ( CONF_ENTITY_CATEGORY, CONF_ICON, diff --git a/esphome/components/copy/select/__init__.py b/esphome/components/copy/select/__init__.py index 6254ed03e1..d7ddc52c44 100644 --- a/esphome/components/copy/select/__init__.py +++ b/esphome/components/copy/select/__init__.py @@ -1,12 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import select -from esphome.const import ( - CONF_ENTITY_CATEGORY, - CONF_ICON, - CONF_ID, - CONF_SOURCE_ID, -) +import esphome.config_validation as cv +from esphome.const import CONF_ENTITY_CATEGORY, CONF_ICON, CONF_ID, CONF_SOURCE_ID from esphome.core.entity_helpers import inherit_property_from from .. import copy_ns diff --git a/esphome/components/copy/sensor/__init__.py b/esphome/components/copy/sensor/__init__.py index 8e78cda7c7..57ca06aca7 100644 --- a/esphome/components/copy/sensor/__init__.py +++ b/esphome/components/copy/sensor/__init__.py @@ -1,14 +1,14 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_ACCURACY_DECIMALS, CONF_DEVICE_CLASS, CONF_ENTITY_CATEGORY, CONF_ICON, CONF_SOURCE_ID, CONF_STATE_CLASS, CONF_UNIT_OF_MEASUREMENT, - CONF_ACCURACY_DECIMALS, ) from esphome.core.entity_helpers import inherit_property_from diff --git a/esphome/components/copy/switch/__init__.py b/esphome/components/copy/switch/__init__.py index beffbe7fbb..ee27e38c5f 100644 --- a/esphome/components/copy/switch/__init__.py +++ b/esphome/components/copy/switch/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import switch +import esphome.config_validation as cv from esphome.const import ( CONF_DEVICE_CLASS, CONF_ENTITY_CATEGORY, diff --git a/esphome/components/copy/text/__init__.py b/esphome/components/copy/text/__init__.py index 7593789250..aa39225bc2 100644 --- a/esphome/components/copy/text/__init__.py +++ b/esphome/components/copy/text/__init__.py @@ -1,12 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text -from esphome.const import ( - CONF_ENTITY_CATEGORY, - CONF_ICON, - CONF_MODE, - CONF_SOURCE_ID, -) +import esphome.config_validation as cv +from esphome.const import CONF_ENTITY_CATEGORY, CONF_ICON, CONF_MODE, CONF_SOURCE_ID from esphome.core.entity_helpers import inherit_property_from from .. import copy_ns diff --git a/esphome/components/copy/text_sensor/__init__.py b/esphome/components/copy/text_sensor/__init__.py index 5b59f21319..7b38ff1a64 100644 --- a/esphome/components/copy/text_sensor/__init__.py +++ b/esphome/components/copy/text_sensor/__init__.py @@ -1,11 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor -from esphome.const import ( - CONF_ENTITY_CATEGORY, - CONF_ICON, - CONF_SOURCE_ID, -) +import esphome.config_validation as cv +from esphome.const import CONF_ENTITY_CATEGORY, CONF_ICON, CONF_SOURCE_ID from esphome.core.entity_helpers import inherit_property_from from .. import copy_ns diff --git a/esphome/components/cs5460a/sensor.py b/esphome/components/cs5460a/sensor.py index d8219e1df1..07b5ea1c63 100644 --- a/esphome/components/cs5460a/sensor.py +++ b/esphome/components/cs5460a/sensor.py @@ -1,21 +1,21 @@ +from esphome import automation +from esphome.automation import maybe_simple_id import esphome.codegen as cg +from esphome.components import sensor, spi import esphome.config_validation as cv -from esphome.components import spi, sensor from esphome.const import ( CONF_CURRENT, CONF_ID, CONF_POWER, CONF_VOLTAGE, CONF_VOLTAGE_GAIN, - UNIT_VOLT, - UNIT_AMPERE, - UNIT_WATT, - DEVICE_CLASS_POWER, DEVICE_CLASS_CURRENT, + DEVICE_CLASS_POWER, DEVICE_CLASS_VOLTAGE, + UNIT_AMPERE, + UNIT_VOLT, + UNIT_WATT, ) -from esphome import automation -from esphome.automation import maybe_simple_id CODEOWNERS = ["@balrog-kun"] DEPENDENCIES = ["spi"] diff --git a/esphome/components/cse7761/sensor.py b/esphome/components/cse7761/sensor.py index c5ec3e5b71..7e8caf1ae1 100644 --- a/esphome/components/cse7761/sensor.py +++ b/esphome/components/cse7761/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_VOLTAGE, @@ -8,8 +8,8 @@ from esphome.const import ( DEVICE_CLASS_POWER, DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, - UNIT_VOLT, UNIT_AMPERE, + UNIT_VOLT, UNIT_WATT, ) diff --git a/esphome/components/cse7766/sensor.py b/esphome/components/cse7766/sensor.py index b5b11a661e..6572a914aa 100644 --- a/esphome/components/cse7766/sensor.py +++ b/esphome/components/cse7766/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( CONF_APPARENT_POWER, CONF_CURRENT, diff --git a/esphome/components/cst226/touchscreen/__init__.py b/esphome/components/cst226/touchscreen/__init__.py index 76975ffe78..62c2e3b20a 100644 --- a/esphome/components/cst226/touchscreen/__init__.py +++ b/esphome/components/cst226/touchscreen/__init__.py @@ -1,11 +1,10 @@ -import esphome.codegen as cg -import esphome.config_validation as cv - from esphome import pins +import esphome.codegen as cg from esphome.components import i2c, touchscreen -from esphome.const import CONF_INTERRUPT_PIN, CONF_ID, CONF_RESET_PIN -from .. import cst226_ns +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_INTERRUPT_PIN, CONF_RESET_PIN +from .. import cst226_ns CST226Touchscreen = cst226_ns.class_( "CST226Touchscreen", diff --git a/esphome/components/ct_clamp/sensor.py b/esphome/components/ct_clamp/sensor.py index 18ea5877d2..6ad7990e80 100644 --- a/esphome/components/ct_clamp/sensor.py +++ b/esphome/components/ct_clamp/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, voltage_sampler +import esphome.config_validation as cv from esphome.const import ( CONF_SENSOR, DEVICE_CLASS_CURRENT, diff --git a/esphome/components/current_based/cover.py b/esphome/components/current_based/cover.py index 1fa4eaa03f..75f083ef14 100644 --- a/esphome/components/current_based/cover.py +++ b/esphome/components/current_based/cover.py @@ -1,18 +1,17 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation -from esphome.components import sensor, cover +import esphome.codegen as cg +from esphome.components import cover, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_CLOSE_ACTION, CONF_CLOSE_DURATION, CONF_ID, + CONF_MAX_DURATION, CONF_OPEN_ACTION, CONF_OPEN_DURATION, CONF_STOP_ACTION, - CONF_MAX_DURATION, ) - CONF_OPEN_SENSOR = "open_sensor" CONF_OPEN_MOVING_CURRENT_THRESHOLD = "open_moving_current_threshold" CONF_OPEN_OBSTACLE_CURRENT_THRESHOLD = "open_obstacle_current_threshold" diff --git a/esphome/components/cwww/light.py b/esphome/components/cwww/light.py index c88a6b0054..50d84a582d 100644 --- a/esphome/components/cwww/light.py +++ b/esphome/components/cwww/light.py @@ -1,12 +1,12 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import light, output +import esphome.config_validation as cv from esphome.const import ( + CONF_COLD_WHITE, + CONF_COLD_WHITE_COLOR_TEMPERATURE, CONF_CONSTANT_BRIGHTNESS, CONF_OUTPUT_ID, - CONF_COLD_WHITE, CONF_WARM_WHITE, - CONF_COLD_WHITE_COLOR_TEMPERATURE, CONF_WARM_WHITE_COLOR_TEMPERATURE, ) diff --git a/esphome/components/dac7678/__init__.py b/esphome/components/dac7678/__init__.py index b6cd2b384e..842c84832e 100644 --- a/esphome/components/dac7678/__init__.py +++ b/esphome/components/dac7678/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["output"] diff --git a/esphome/components/dac7678/output.py b/esphome/components/dac7678/output.py index f41e5c2422..cb7739242c 100644 --- a/esphome/components/dac7678/output.py +++ b/esphome/components/dac7678/output.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL, CONF_ID + from . import DAC7678Output, dac7678_ns DEPENDENCIES = ["dac7678"] diff --git a/esphome/components/daikin/climate.py b/esphome/components/daikin/climate.py index af60b17448..3946513191 100644 --- a/esphome/components/daikin/climate.py +++ b/esphome/components/daikin/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/daikin_arc/climate.py b/esphome/components/daikin_arc/climate.py index 51f253e9cb..967d080c24 100644 --- a/esphome/components/daikin_arc/climate.py +++ b/esphome/components/daikin_arc/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/daikin_brc/climate.py b/esphome/components/daikin_brc/climate.py index 7a5bd9b14d..aacac408ca 100644 --- a/esphome/components/daikin_brc/climate.py +++ b/esphome/components/daikin_brc/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_USE_FAHRENHEIT AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/dallas_temp/sensor.py b/esphome/components/dallas_temp/sensor.py index ab14a9afd5..3d35881722 100644 --- a/esphome/components/dallas_temp/sensor.py +++ b/esphome/components/dallas_temp/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import one_wire, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_RESOLUTION, DEVICE_CLASS_TEMPERATURE, diff --git a/esphome/components/daly_bms/__init__.py b/esphome/components/daly_bms/__init__.py index 669d40a68d..87f00ce507 100644 --- a/esphome/components/daly_bms/__init__.py +++ b/esphome/components/daly_bms/__init__.py @@ -1,7 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import uart -from esphome.const import CONF_ID, CONF_ADDRESS +import esphome.config_validation as cv +from esphome.const import CONF_ADDRESS, CONF_ID CODEOWNERS = ["@s1lvi0"] MULTI_CONF = True diff --git a/esphome/components/daly_bms/binary_sensor.py b/esphome/components/daly_bms/binary_sensor.py index 724f19315b..95a2ae3b44 100644 --- a/esphome/components/daly_bms/binary_sensor.py +++ b/esphome/components/daly_bms/binary_sensor.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor -from . import DalyBmsComponent, CONF_BMS_DALY_ID +import esphome.config_validation as cv + +from . import CONF_BMS_DALY_ID, DalyBmsComponent CONF_CHARGING_MOS_ENABLED = "charging_mos_enabled" CONF_DISCHARGING_MOS_ENABLED = "discharging_mos_enabled" diff --git a/esphome/components/daly_bms/sensor.py b/esphome/components/daly_bms/sensor.py index 6d78946a02..560bcef64e 100644 --- a/esphome/components/daly_bms/sensor.py +++ b/esphome/components/daly_bms/sensor.py @@ -1,28 +1,29 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_VOLTAGE, - CONF_CURRENT, CONF_BATTERY_LEVEL, + CONF_CURRENT, CONF_MAX_TEMPERATURE, CONF_MIN_TEMPERATURE, - DEVICE_CLASS_VOLTAGE, - DEVICE_CLASS_CURRENT, + CONF_VOLTAGE, DEVICE_CLASS_BATTERY, + DEVICE_CLASS_CURRENT, DEVICE_CLASS_TEMPERATURE, - STATE_CLASS_MEASUREMENT, - UNIT_VOLT, - UNIT_AMPERE, - UNIT_PERCENT, - UNIT_CELSIUS, - ICON_FLASH, - ICON_PERCENT, + DEVICE_CLASS_VOLTAGE, ICON_COUNTER, - ICON_THERMOMETER, + ICON_FLASH, ICON_GAUGE, + ICON_PERCENT, + ICON_THERMOMETER, + STATE_CLASS_MEASUREMENT, + UNIT_AMPERE, + UNIT_CELSIUS, + UNIT_PERCENT, + UNIT_VOLT, ) -from . import DalyBmsComponent, CONF_BMS_DALY_ID + +from . import CONF_BMS_DALY_ID, DalyBmsComponent CONF_MAX_CELL_VOLTAGE = "max_cell_voltage" CONF_MAX_CELL_VOLTAGE_NUMBER = "max_cell_voltage_number" diff --git a/esphome/components/daly_bms/text_sensor.py b/esphome/components/daly_bms/text_sensor.py index fcd5ee531b..9f4e2df85a 100644 --- a/esphome/components/daly_bms/text_sensor.py +++ b/esphome/components/daly_bms/text_sensor.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor +import esphome.config_validation as cv from esphome.const import CONF_STATUS -from . import DalyBmsComponent, CONF_BMS_DALY_ID + +from . import CONF_BMS_DALY_ID, DalyBmsComponent ICON_CAR_BATTERY = "mdi:car-battery" diff --git a/esphome/components/dashboard_import/__init__.py b/esphome/components/dashboard_import/__init__.py index b1b22b816b..acaadab544 100644 --- a/esphome/components/dashboard_import/__init__.py +++ b/esphome/components/dashboard_import/__init__.py @@ -1,18 +1,18 @@ import base64 -import secrets from pathlib import Path -from typing import Optional import re +import secrets +from typing import Optional import requests from ruamel.yaml import YAML -import esphome.codegen as cg -import esphome.config_validation as cv -import esphome.final_validate as fv from esphome import git +import esphome.codegen as cg from esphome.components.packages import validate_source_shorthand -from esphome.const import CONF_REF, CONF_WIFI, CONF_ESPHOME, CONF_PROJECT +import esphome.config_validation as cv +from esphome.const import CONF_ESPHOME, CONF_PROJECT, CONF_REF, CONF_WIFI +import esphome.final_validate as fv from esphome.yaml_util import dump dashboard_import_ns = cg.esphome_ns.namespace("dashboard_import") diff --git a/esphome/components/debug/sensor.py b/esphome/components/debug/sensor.py index 061c2750e4..0a23658907 100644 --- a/esphome/components/debug/sensor.py +++ b/esphome/components/debug/sensor.py @@ -1,18 +1,19 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_FREE, - CONF_FRAGMENTATION, CONF_BLOCK, + CONF_FRAGMENTATION, + CONF_FREE, CONF_LOOP_TIME, ENTITY_CATEGORY_DIAGNOSTIC, - UNIT_MILLISECOND, - UNIT_PERCENT, - UNIT_BYTES, ICON_COUNTER, ICON_TIMER, + UNIT_BYTES, + UNIT_MILLISECOND, + UNIT_PERCENT, ) + from . import CONF_DEBUG_ID, DebugComponent DEPENDENCIES = ["debug"] diff --git a/esphome/components/debug/text_sensor.py b/esphome/components/debug/text_sensor.py index 24f938a0e2..96ef231850 100644 --- a/esphome/components/debug/text_sensor.py +++ b/esphome/components/debug/text_sensor.py @@ -1,6 +1,6 @@ +import esphome.codegen as cg from esphome.components import text_sensor import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import ( CONF_DEVICE, ENTITY_CATEGORY_DIAGNOSTIC, diff --git a/esphome/components/deep_sleep/__init__.py b/esphome/components/deep_sleep/__init__.py index fd7ef6fcce..e7f563a0d2 100644 --- a/esphome/components/deep_sleep/__init__.py +++ b/esphome/components/deep_sleep/__init__.py @@ -1,7 +1,17 @@ +from esphome import automation, pins import esphome.codegen as cg from esphome.components import time +from esphome.components.esp32 import get_esp32_variant +from esphome.components.esp32.const import ( + VARIANT_ESP32, + VARIANT_ESP32C2, + VARIANT_ESP32C3, + VARIANT_ESP32C6, + VARIANT_ESP32H2, + VARIANT_ESP32S2, + VARIANT_ESP32S3, +) import esphome.config_validation as cv -from esphome import pins, automation from esphome.const import ( CONF_HOUR, CONF_ID, @@ -18,17 +28,6 @@ from esphome.const import ( PLATFORM_ESP8266, ) -from esphome.components.esp32 import get_esp32_variant -from esphome.components.esp32.const import ( - VARIANT_ESP32, - VARIANT_ESP32C3, - VARIANT_ESP32S2, - VARIANT_ESP32S3, - VARIANT_ESP32C2, - VARIANT_ESP32C6, - VARIANT_ESP32H2, -) - WAKEUP_PINS = { VARIANT_ESP32: [ 0, diff --git a/esphome/components/delonghi/climate.py b/esphome/components/delonghi/climate.py index 614706defe..0d3bb76c98 100644 --- a/esphome/components/delonghi/climate.py +++ b/esphome/components/delonghi/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/demo/__init__.py b/esphome/components/demo/__init__.py index 05160bf8cb..349bd8e4cb 100644 --- a/esphome/components/demo/__init__.py +++ b/esphome/components/demo/__init__.py @@ -1,5 +1,4 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import ( binary_sensor, climate, @@ -11,6 +10,7 @@ from esphome.components import ( switch, text_sensor, ) +import esphome.config_validation as cv from esphome.const import ( CONF_ACCURACY_DECIMALS, CONF_BINARY_SENSORS, diff --git a/esphome/components/dfplayer/__init__.py b/esphome/components/dfplayer/__init__.py index c37c9999aa..53ebda6bcc 100644 --- a/esphome/components/dfplayer/__init__.py +++ b/esphome/components/dfplayer/__init__.py @@ -1,8 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation -from esphome.const import CONF_ID, CONF_TRIGGER_ID, CONF_FILE, CONF_DEVICE, CONF_VOLUME +import esphome.codegen as cg from esphome.components import uart +import esphome.config_validation as cv +from esphome.const import CONF_DEVICE, CONF_FILE, CONF_ID, CONF_TRIGGER_ID, CONF_VOLUME DEPENDENCIES = ["uart"] CODEOWNERS = ["@glmnet"] diff --git a/esphome/components/dfrobot_sen0395/__init__.py b/esphome/components/dfrobot_sen0395/__init__.py index 39787ca66b..8c9438dccb 100644 --- a/esphome/components/dfrobot_sen0395/__init__.py +++ b/esphome/components/dfrobot_sen0395/__init__.py @@ -1,9 +1,9 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation from esphome.automation import maybe_simple_id -from esphome.const import CONF_FACTORY_RESET, CONF_ID, CONF_SENSITIVITY +import esphome.codegen as cg from esphome.components import uart +import esphome.config_validation as cv +from esphome.const import CONF_FACTORY_RESET, CONF_ID, CONF_SENSITIVITY CODEOWNERS = ["@niklasweber"] DEPENDENCIES = ["uart"] diff --git a/esphome/components/dfrobot_sen0395/binary_sensor.py b/esphome/components/dfrobot_sen0395/binary_sensor.py index 2fd0510476..193ef925a4 100644 --- a/esphome/components/dfrobot_sen0395/binary_sensor.py +++ b/esphome/components/dfrobot_sen0395/binary_sensor.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import DEVICE_CLASS_MOTION + from . import CONF_DFROBOT_SEN0395_ID, DfrobotSen0395Component DEPENDENCIES = ["dfrobot_sen0395"] diff --git a/esphome/components/dfrobot_sen0395/switch/__init__.py b/esphome/components/dfrobot_sen0395/switch/__init__.py index b1c35d27ac..f854d08398 100644 --- a/esphome/components/dfrobot_sen0395/switch/__init__.py +++ b/esphome/components/dfrobot_sen0395/switch/__init__.py @@ -1,11 +1,10 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import switch -from esphome.const import ENTITY_CATEGORY_CONFIG, CONF_TYPE +import esphome.config_validation as cv +from esphome.const import CONF_TYPE, ENTITY_CATEGORY_CONFIG from .. import CONF_DFROBOT_SEN0395_ID, DfrobotSen0395Component - DEPENDENCIES = ["dfrobot_sen0395"] dfrobot_sen0395_ns = cg.esphome_ns.namespace("dfrobot_sen0395") diff --git a/esphome/components/dht/sensor.py b/esphome/components/dht/sensor.py index be53df2625..d907495ba2 100644 --- a/esphome/components/dht/sensor.py +++ b/esphome/components/dht/sensor.py @@ -1,20 +1,19 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_HUMIDITY, CONF_ID, CONF_MODEL, CONF_PIN, CONF_TEMPERATURE, + DEVICE_CLASS_HUMIDITY, + DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_HUMIDITY, ) - from esphome.cpp_helpers import gpio_pin_expression dht_ns = cg.esphome_ns.namespace("dht") diff --git a/esphome/components/dht12/sensor.py b/esphome/components/dht12/sensor.py index ae2173ef22..eb93cbae2c 100644 --- a/esphome/components/dht12/sensor.py +++ b/esphome/components/dht12/sensor.py @@ -1,15 +1,15 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_HUMIDITY, CONF_ID, CONF_TEMPERATURE, + DEVICE_CLASS_HUMIDITY, + DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_HUMIDITY, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/dps310/sensor.py b/esphome/components/dps310/sensor.py index 742c873d9e..b2a98e5bab 100644 --- a/esphome/components/dps310/sensor.py +++ b/esphome/components/dps310/sensor.py @@ -1,16 +1,16 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_PRESSURE, CONF_TEMPERATURE, DEVICE_CLASS_PRESSURE, DEVICE_CLASS_TEMPERATURE, - STATE_CLASS_MEASUREMENT, - UNIT_CELSIUS, ICON_GAUGE, ICON_THERMOMETER, + STATE_CLASS_MEASUREMENT, + UNIT_CELSIUS, UNIT_HECTOPASCAL, ) diff --git a/esphome/components/ds1307/time.py b/esphome/components/ds1307/time.py index ddc2939038..42b7184db9 100644 --- a/esphome/components/ds1307/time.py +++ b/esphome/components/ds1307/time.py @@ -1,10 +1,9 @@ -import esphome.config_validation as cv -import esphome.codegen as cg from esphome import automation +import esphome.codegen as cg from esphome.components import i2c, time +import esphome.config_validation as cv from esphome.const import CONF_ID - CODEOWNERS = ["@badbadc0ffee"] DEPENDENCIES = ["i2c"] ds1307_ns = cg.esphome_ns.namespace("ds1307") diff --git a/esphome/components/dsmr/__init__.py b/esphome/components/dsmr/__init__.py index 9f56dc3465..017a11673f 100644 --- a/esphome/components/dsmr/__init__.py +++ b/esphome/components/dsmr/__init__.py @@ -1,12 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import uart -from esphome.const import ( - CONF_ID, - CONF_UART_ID, - CONF_RECEIVE_TIMEOUT, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_RECEIVE_TIMEOUT, CONF_UART_ID CODEOWNERS = ["@glmnet", "@zuidwijk"] diff --git a/esphome/components/dsmr/sensor.py b/esphome/components/dsmr/sensor.py index f2398d1908..0696fccdf7 100644 --- a/esphome/components/dsmr/sensor.py +++ b/esphome/components/dsmr/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, DEVICE_CLASS_CURRENT, @@ -13,13 +13,14 @@ from esphome.const import ( STATE_CLASS_TOTAL_INCREASING, UNIT_AMPERE, UNIT_CUBIC_METER, + UNIT_KILOVOLT_AMPS_REACTIVE, + UNIT_KILOVOLT_AMPS_REACTIVE_HOURS, UNIT_KILOWATT, UNIT_KILOWATT_HOURS, - UNIT_KILOVOLT_AMPS_REACTIVE_HOURS, - UNIT_KILOVOLT_AMPS_REACTIVE, UNIT_VOLT, ) -from . import Dsmr, CONF_DSMR_ID + +from . import CONF_DSMR_ID, Dsmr AUTO_LOAD = ["dsmr"] diff --git a/esphome/components/dsmr/text_sensor.py b/esphome/components/dsmr/text_sensor.py index 7c13fe7d58..3223d943be 100644 --- a/esphome/components/dsmr/text_sensor.py +++ b/esphome/components/dsmr/text_sensor.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor +import esphome.config_validation as cv from esphome.const import CONF_INTERNAL -from . import Dsmr, CONF_DSMR_ID + +from . import CONF_DSMR_ID, Dsmr AUTO_LOAD = ["dsmr"] diff --git a/esphome/components/duty_cycle/sensor.py b/esphome/components/duty_cycle/sensor.py index 3dcdf7a818..37c889cd85 100644 --- a/esphome/components/duty_cycle/sensor.py +++ b/esphome/components/duty_cycle/sensor.py @@ -1,13 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import sensor -from esphome.const import ( - CONF_PIN, - STATE_CLASS_MEASUREMENT, - UNIT_PERCENT, - ICON_PERCENT, -) +import esphome.config_validation as cv +from esphome.const import CONF_PIN, ICON_PERCENT, STATE_CLASS_MEASUREMENT, UNIT_PERCENT duty_cycle_ns = cg.esphome_ns.namespace("duty_cycle") DutyCycleSensor = duty_cycle_ns.class_( diff --git a/esphome/components/duty_time/sensor.py b/esphome/components/duty_time/sensor.py index 556cd459a5..1907b3fcfe 100644 --- a/esphome/components/duty_time/sensor.py +++ b/esphome/components/duty_time/sensor.py @@ -1,5 +1,3 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome.automation import ( Action, Condition, @@ -7,17 +5,19 @@ from esphome.automation import ( register_action, register_condition, ) +import esphome.codegen as cg from esphome.components import binary_sensor, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, - CONF_SENSOR, - CONF_RESTORE, CONF_LAMBDA, - UNIT_SECOND, - STATE_CLASS_TOTAL, - STATE_CLASS_TOTAL_INCREASING, + CONF_RESTORE, + CONF_SENSOR, DEVICE_CLASS_DURATION, ENTITY_CATEGORY_DIAGNOSTIC, + STATE_CLASS_TOTAL, + STATE_CLASS_TOTAL_INCREASING, + UNIT_SECOND, ) CONF_LAST_TIME = "last_time" diff --git a/esphome/components/e131/__init__.py b/esphome/components/e131/__init__.py index cec0bdf4fa..301812e314 100644 --- a/esphome/components/e131/__init__.py +++ b/esphome/components/e131/__init__.py @@ -1,8 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components.light.types import AddressableLightEffect from esphome.components.light.effects import register_addressable_effect -from esphome.const import CONF_ID, CONF_NAME, CONF_METHOD, CONF_CHANNELS +from esphome.components.light.types import AddressableLightEffect +import esphome.config_validation as cv +from esphome.const import CONF_CHANNELS, CONF_ID, CONF_METHOD, CONF_NAME AUTO_LOAD = ["socket"] DEPENDENCIES = ["network"] diff --git a/esphome/components/ee895/sensor.py b/esphome/components/ee895/sensor.py index d06f9ca02f..0f8f44c8a2 100644 --- a/esphome/components/ee895/sensor.py +++ b/esphome/components/ee895/sensor.py @@ -1,17 +1,17 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_CO2, CONF_ID, CONF_PRESSURE, CONF_TEMPERATURE, - CONF_CO2, - DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_PRESSURE, - STATE_CLASS_MEASUREMENT, - UNIT_HECTOPASCAL, - UNIT_CELSIUS, + DEVICE_CLASS_TEMPERATURE, ICON_MOLECULE_CO2, + STATE_CLASS_MEASUREMENT, + UNIT_CELSIUS, + UNIT_HECTOPASCAL, UNIT_PARTS_PER_MILLION, ) diff --git a/esphome/components/ektf2232/touchscreen/__init__.py b/esphome/components/ektf2232/touchscreen/__init__.py index c1fefb7f09..7d946fdcb9 100644 --- a/esphome/components/ektf2232/touchscreen/__init__.py +++ b/esphome/components/ektf2232/touchscreen/__init__.py @@ -1,8 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv - from esphome import pins +import esphome.codegen as cg from esphome.components import i2c, touchscreen +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_INTERRUPT_PIN CODEOWNERS = ["@jesserockz"] diff --git a/esphome/components/emc2101/__init__.py b/esphome/components/emc2101/__init__.py index 8012d3e897..323195e99a 100644 --- a/esphome/components/emc2101/__init__.py +++ b/esphome/components/emc2101/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_INVERTED, CONF_RESOLUTION CODEOWNERS = ["@ellull"] diff --git a/esphome/components/emc2101/output/__init__.py b/esphome/components/emc2101/output/__init__.py index 461ef73de1..586f0800a6 100644 --- a/esphome/components/emc2101/output/__init__.py +++ b/esphome/components/emc2101/output/__init__.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_ID -from .. import EMC2101_COMPONENT_SCHEMA, CONF_EMC2101_ID, emc2101_ns + +from .. import CONF_EMC2101_ID, EMC2101_COMPONENT_SCHEMA, emc2101_ns DEPENDENCIES = ["emc2101"] diff --git a/esphome/components/emc2101/sensor/__init__.py b/esphome/components/emc2101/sensor/__init__.py index 10ea3dfae6..b6a2c8a333 100644 --- a/esphome/components/emc2101/sensor/__init__.py +++ b/esphome/components/emc2101/sensor/__init__.py @@ -1,19 +1,20 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_EXTERNAL_TEMPERATURE, CONF_ID, CONF_INTERNAL_TEMPERATURE, CONF_SPEED, DEVICE_CLASS_TEMPERATURE, + ICON_PERCENT, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, UNIT_REVOLUTIONS_PER_MINUTE, - ICON_PERCENT, ) -from .. import EMC2101_COMPONENT_SCHEMA, CONF_EMC2101_ID, emc2101_ns + +from .. import CONF_EMC2101_ID, EMC2101_COMPONENT_SCHEMA, emc2101_ns DEPENDENCIES = ["emc2101"] diff --git a/esphome/components/emmeti/climate.py b/esphome/components/emmeti/climate.py index 36585061e6..b925f4b61e 100644 --- a/esphome/components/emmeti/climate.py +++ b/esphome/components/emmeti/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@E440QF"] diff --git a/esphome/components/endstop/cover.py b/esphome/components/endstop/cover.py index 9f3cd395a5..286c876ff6 100644 --- a/esphome/components/endstop/cover.py +++ b/esphome/components/endstop/cover.py @@ -1,17 +1,17 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import binary_sensor, cover +import esphome.config_validation as cv from esphome.const import ( CONF_CLOSE_ACTION, CONF_CLOSE_DURATION, CONF_CLOSE_ENDSTOP, CONF_ID, + CONF_MAX_DURATION, CONF_OPEN_ACTION, CONF_OPEN_DURATION, CONF_OPEN_ENDSTOP, CONF_STOP_ACTION, - CONF_MAX_DURATION, ) endstop_ns = cg.esphome_ns.namespace("endstop") diff --git a/esphome/components/ens160_base/__init__.py b/esphome/components/ens160_base/__init__.py index eb6d0880af..28e77e322b 100644 --- a/esphome/components/ens160_base/__init__.py +++ b/esphome/components/ens160_base/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_COMPENSATION, CONF_ECO2, diff --git a/esphome/components/ens160_i2c/sensor.py b/esphome/components/ens160_i2c/sensor.py index 96cbbaa7e9..cad4e81afc 100644 --- a/esphome/components/ens160_i2c/sensor.py +++ b/esphome/components/ens160_i2c/sensor.py @@ -1,6 +1,7 @@ import esphome.codegen as cg from esphome.components import i2c -from ..ens160_base import to_code_base, cv, CONFIG_SCHEMA_BASE + +from ..ens160_base import CONFIG_SCHEMA_BASE, cv, to_code_base AUTO_LOAD = ["ens160_base"] CODEOWNERS = ["@latonita"] diff --git a/esphome/components/ens160_spi/sensor.py b/esphome/components/ens160_spi/sensor.py index 552697fe1b..1bda05c7bb 100644 --- a/esphome/components/ens160_spi/sensor.py +++ b/esphome/components/ens160_spi/sensor.py @@ -1,6 +1,7 @@ import esphome.codegen as cg from esphome.components import spi -from ..ens160_base import to_code_base, cv, CONFIG_SCHEMA_BASE + +from ..ens160_base import CONFIG_SCHEMA_BASE, cv, to_code_base AUTO_LOAD = ["ens160_base"] CODEOWNERS = ["@latonita"] diff --git a/esphome/components/ens210/sensor.py b/esphome/components/ens210/sensor.py index 3037156e01..289a559673 100644 --- a/esphome/components/ens210/sensor.py +++ b/esphome/components/ens210/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_HUMIDITY, CONF_ID, diff --git a/esphome/components/esp32_camera/__init__.py b/esphome/components/esp32_camera/__init__.py index 2f1f9b90bb..e55c54f097 100644 --- a/esphome/components/esp32_camera/__init__.py +++ b/esphome/components/esp32_camera/__init__.py @@ -1,23 +1,22 @@ +from esphome import automation, pins import esphome.codegen as cg +from esphome.components.esp32 import add_idf_component import esphome.config_validation as cv -from esphome import automation -from esphome import pins from esphome.const import ( + CONF_BRIGHTNESS, + CONF_CONTRAST, + CONF_DATA_PINS, CONF_FREQUENCY, CONF_ID, CONF_PIN, - CONF_SCL, - CONF_SDA, - CONF_DATA_PINS, CONF_RESET_PIN, CONF_RESOLUTION, - CONF_BRIGHTNESS, - CONF_CONTRAST, + CONF_SCL, + CONF_SDA, CONF_TRIGGER_ID, CONF_VSYNC_PIN, ) from esphome.core import CORE -from esphome.components.esp32 import add_idf_component from esphome.cpp_helpers import setup_entity DEPENDENCIES = ["esp32"] diff --git a/esphome/components/esp32_camera_web_server/__init__.py b/esphome/components/esp32_camera_web_server/__init__.py index d8afea27b4..363218bbac 100644 --- a/esphome/components/esp32_camera_web_server/__init__.py +++ b/esphome/components/esp32_camera_web_server/__init__.py @@ -1,6 +1,6 @@ -import esphome.config_validation as cv import esphome.codegen as cg -from esphome.const import CONF_ID, CONF_PORT, CONF_MODE +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_MODE, CONF_PORT CODEOWNERS = ["@ayufan"] DEPENDENCIES = ["esp32_camera"] diff --git a/esphome/components/esp32_dac/output.py b/esphome/components/esp32_dac/output.py index c80780986f..cf4f12c46d 100644 --- a/esphome/components/esp32_dac/output.py +++ b/esphome/components/esp32_dac/output.py @@ -1,9 +1,9 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import output from esphome.components.esp32 import get_esp32_variant from esphome.components.esp32.const import VARIANT_ESP32, VARIANT_ESP32S2 +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_NUMBER, CONF_PIN DEPENDENCIES = ["esp32"] diff --git a/esphome/components/esp32_hall/sensor.py b/esphome/components/esp32_hall/sensor.py index 0c94224ef8..e7953d4b3d 100644 --- a/esphome/components/esp32_hall/sensor.py +++ b/esphome/components/esp32_hall/sensor.py @@ -1,11 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor -from esphome.const import ( - STATE_CLASS_MEASUREMENT, - UNIT_MICROTESLA, - ICON_MAGNET, -) +import esphome.config_validation as cv +from esphome.const import ICON_MAGNET, STATE_CLASS_MEASUREMENT, UNIT_MICROTESLA DEPENDENCIES = ["esp32"] diff --git a/esphome/components/esp32_touch/__init__.py b/esphome/components/esp32_touch/__init__.py index fc7bf200e4..224e301683 100644 --- a/esphome/components/esp32_touch/__init__.py +++ b/esphome/components/esp32_touch/__init__.py @@ -1,4 +1,11 @@ import esphome.codegen as cg +from esphome.components import esp32 +from esphome.components.esp32 import get_esp32_variant, gpio +from esphome.components.esp32.const import ( + VARIANT_ESP32, + VARIANT_ESP32S2, + VARIANT_ESP32S3, +) import esphome.config_validation as cv from esphome.const import ( CONF_HIGH_VOLTAGE_REFERENCE, @@ -11,13 +18,6 @@ from esphome.const import ( CONF_VOLTAGE_ATTENUATION, ) from esphome.core import TimePeriod -from esphome.components import esp32 -from esphome.components.esp32 import get_esp32_variant, gpio -from esphome.components.esp32.const import ( - VARIANT_ESP32, - VARIANT_ESP32S2, - VARIANT_ESP32S3, -) AUTO_LOAD = ["binary_sensor"] DEPENDENCIES = ["esp32"] diff --git a/esphome/components/esp32_touch/binary_sensor.py b/esphome/components/esp32_touch/binary_sensor.py index e9322b3080..75560d71b1 100644 --- a/esphome/components/esp32_touch/binary_sensor.py +++ b/esphome/components/esp32_touch/binary_sensor.py @@ -1,12 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor -from esphome.const import ( - CONF_PIN, - CONF_THRESHOLD, - CONF_ID, -) -from . import esp32_touch_ns, ESP32TouchComponent, validate_touch_pad +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_PIN, CONF_THRESHOLD + +from . import ESP32TouchComponent, esp32_touch_ns, validate_touch_pad DEPENDENCIES = ["esp32_touch", "esp32"] diff --git a/esphome/components/esp8266_pwm/output.py b/esphome/components/esp8266_pwm/output.py index 7feee79ff2..1404ef8ac3 100644 --- a/esphome/components/esp8266_pwm/output.py +++ b/esphome/components/esp8266_pwm/output.py @@ -1,13 +1,8 @@ -from esphome import pins, automation +from esphome import automation, pins +import esphome.codegen as cg from esphome.components import output import esphome.config_validation as cv -import esphome.codegen as cg -from esphome.const import ( - CONF_FREQUENCY, - CONF_ID, - CONF_NUMBER, - CONF_PIN, -) +from esphome.const import CONF_FREQUENCY, CONF_ID, CONF_NUMBER, CONF_PIN DEPENDENCIES = ["esp8266"] diff --git a/esphome/components/ethernet/__init__.py b/esphome/components/ethernet/__init__.py index ab760a9b6c..cd77ea6053 100644 --- a/esphome/components/ethernet/__init__.py +++ b/esphome/components/ethernet/__init__.py @@ -1,4 +1,5 @@ import logging + from esphome import pins import esphome.codegen as cg from esphome.components.esp32 import add_idf_sdkconfig_option, get_esp32_variant diff --git a/esphome/components/exposure_notifications/__init__.py b/esphome/components/exposure_notifications/__init__.py index 9c28552267..ab7416a264 100644 --- a/esphome/components/exposure_notifications/__init__.py +++ b/esphome/components/exposure_notifications/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg from esphome import automation -import esphome.config_validation as cv +import esphome.codegen as cg from esphome.components import esp32_ble_tracker +import esphome.config_validation as cv from esphome.const import CONF_TRIGGER_ID CODEOWNERS = ["@OttoWinter"] diff --git a/esphome/components/external_components/__init__.py b/esphome/components/external_components/__init__.py index f4432a0362..a09217fd21 100644 --- a/esphome/components/external_components/__init__.py +++ b/esphome/components/external_components/__init__.py @@ -1,8 +1,8 @@ import logging from pathlib import Path -import esphome.config_validation as cv from esphome import git, loader +import esphome.config_validation as cv from esphome.const import ( CONF_COMPONENTS, CONF_EXTERNAL_COMPONENTS, diff --git a/esphome/components/ezo/sensor.py b/esphome/components/ezo/sensor.py index 486ba0126e..cf240faec3 100644 --- a/esphome/components/ezo/sensor.py +++ b/esphome/components/ezo/sensor.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_TRIGGER_ID CODEOWNERS = ["@ssieb"] diff --git a/esphome/components/ezo_pmp/__init__.py b/esphome/components/ezo_pmp/__init__.py index 87cda41f89..c1f72bb05d 100644 --- a/esphome/components/ezo_pmp/__init__.py +++ b/esphome/components/ezo_pmp/__init__.py @@ -1,15 +1,15 @@ +from esphome import automation +from esphome.automation import maybe_simple_id import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import ( CONF_ADDRESS, CONF_COMMAND, - CONF_ID, CONF_DURATION, + CONF_ID, CONF_VOLUME, ) -from esphome import automation -from esphome.automation import maybe_simple_id CODEOWNERS = ["@carlos-sarmiento"] DEPENDENCIES = ["i2c"] diff --git a/esphome/components/ezo_pmp/binary_sensor.py b/esphome/components/ezo_pmp/binary_sensor.py index 582eb7af25..a81b6c09f0 100644 --- a/esphome/components/ezo_pmp/binary_sensor.py +++ b/esphome/components/ezo_pmp/binary_sensor.py @@ -1,11 +1,11 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import ( - ENTITY_CATEGORY_NONE, - DEVICE_CLASS_RUNNING, - DEVICE_CLASS_EMPTY, CONF_ID, + DEVICE_CLASS_EMPTY, + DEVICE_CLASS_RUNNING, + ENTITY_CATEGORY_NONE, ) from . import EzoPMP diff --git a/esphome/components/ezo_pmp/sensor.py b/esphome/components/ezo_pmp/sensor.py index 737985f4c5..a0473b292c 100644 --- a/esphome/components/ezo_pmp/sensor.py +++ b/esphome/components/ezo_pmp/sensor.py @@ -1,20 +1,19 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( - ENTITY_CATEGORY_DIAGNOSTIC, - ENTITY_CATEGORY_NONE, + CONF_ID, DEVICE_CLASS_EMPTY, DEVICE_CLASS_VOLTAGE, + ENTITY_CATEGORY_DIAGNOSTIC, + ENTITY_CATEGORY_NONE, STATE_CLASS_MEASUREMENT, STATE_CLASS_NONE, - CONF_ID, UNIT_VOLT, ) from . import EzoPMP - DEPENDENCIES = ["ezo_pmp"] CONF_CURRENT_VOLUME_DOSED = "current_volume_dosed" diff --git a/esphome/components/ezo_pmp/text_sensor.py b/esphome/components/ezo_pmp/text_sensor.py index f8f133e316..afae1e5188 100644 --- a/esphome/components/ezo_pmp/text_sensor.py +++ b/esphome/components/ezo_pmp/text_sensor.py @@ -1,11 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor -from esphome.const import ( - ENTITY_CATEGORY_NONE, - ENTITY_CATEGORY_DIAGNOSTIC, - CONF_ID, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID, ENTITY_CATEGORY_DIAGNOSTIC, ENTITY_CATEGORY_NONE from . import EzoPMP diff --git a/esphome/components/factory_reset/button/__init__.py b/esphome/components/factory_reset/button/__init__.py index 010691ac7f..61df5f297b 100644 --- a/esphome/components/factory_reset/button/__init__.py +++ b/esphome/components/factory_reset/button/__init__.py @@ -1,12 +1,13 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import button +import esphome.config_validation as cv from esphome.const import ( CONF_ID, DEVICE_CLASS_RESTART, ENTITY_CATEGORY_CONFIG, ICON_RESTART_ALERT, ) + from .. import factory_reset_ns FactoryResetButton = factory_reset_ns.class_( diff --git a/esphome/components/factory_reset/switch/__init__.py b/esphome/components/factory_reset/switch/__init__.py index 3cc19a35a3..17f4587e5d 100644 --- a/esphome/components/factory_reset/switch/__init__.py +++ b/esphome/components/factory_reset/switch/__init__.py @@ -1,14 +1,15 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import switch +import esphome.config_validation as cv from esphome.const import ( CONF_ENTITY_CATEGORY, + CONF_ICON, CONF_ID, CONF_INVERTED, - CONF_ICON, ENTITY_CATEGORY_CONFIG, ICON_RESTART_ALERT, ) + from .. import factory_reset_ns FactoryResetSwitch = factory_reset_ns.class_( diff --git a/esphome/components/fastled_base/__init__.py b/esphome/components/fastled_base/__init__.py index 62de036e62..1e70e14f10 100644 --- a/esphome/components/fastled_base/__init__.py +++ b/esphome/components/fastled_base/__init__.py @@ -1,11 +1,11 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import light +import esphome.config_validation as cv from esphome.const import ( - CONF_OUTPUT_ID, - CONF_NUM_LEDS, - CONF_RGB_ORDER, CONF_MAX_REFRESH_RATE, + CONF_NUM_LEDS, + CONF_OUTPUT_ID, + CONF_RGB_ORDER, ) CODEOWNERS = ["@OttoWinter"] diff --git a/esphome/components/fastled_clockless/light.py b/esphome/components/fastled_clockless/light.py index dc456d4959..49a6d390be 100644 --- a/esphome/components/fastled_clockless/light.py +++ b/esphome/components/fastled_clockless/light.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import fastled_base +import esphome.config_validation as cv from esphome.const import CONF_CHIPSET, CONF_NUM_LEDS, CONF_PIN, CONF_RGB_ORDER AUTO_LOAD = ["fastled_base"] diff --git a/esphome/components/fastled_spi/light.py b/esphome/components/fastled_spi/light.py index b3ce1722ee..ac30721eb4 100644 --- a/esphome/components/fastled_spi/light.py +++ b/esphome/components/fastled_spi/light.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import fastled_base +import esphome.config_validation as cv from esphome.const import ( CONF_CHIPSET, CONF_CLOCK_PIN, diff --git a/esphome/components/feedback/cover.py b/esphome/components/feedback/cover.py index 450eb967b1..b90374f6e8 100644 --- a/esphome/components/feedback/cover.py +++ b/esphome/components/feedback/cover.py @@ -1,18 +1,18 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import binary_sensor, cover +import esphome.config_validation as cv from esphome.const import ( CONF_ASSUMED_STATE, CONF_CLOSE_ACTION, CONF_CLOSE_DURATION, CONF_CLOSE_ENDSTOP, CONF_ID, + CONF_MAX_DURATION, CONF_OPEN_ACTION, CONF_OPEN_DURATION, CONF_OPEN_ENDSTOP, CONF_STOP_ACTION, - CONF_MAX_DURATION, CONF_UPDATE_INTERVAL, ) diff --git a/esphome/components/fingerprint_grow/__init__.py b/esphome/components/fingerprint_grow/__init__.py index 23651bd049..115b89433b 100644 --- a/esphome/components/fingerprint_grow/__init__.py +++ b/esphome/components/fingerprint_grow/__init__.py @@ -1,8 +1,7 @@ +from esphome import automation, pins import esphome.codegen as cg -import esphome.config_validation as cv -from esphome import automation -from esphome import pins from esphome.components import uart +import esphome.config_validation as cv from esphome.const import ( CONF_COLOR, CONF_COUNT, @@ -13,11 +12,11 @@ from esphome.const import ( CONF_ON_ENROLLMENT_DONE, CONF_ON_ENROLLMENT_FAILED, CONF_ON_ENROLLMENT_SCAN, - CONF_ON_FINGER_SCAN_START, - CONF_ON_FINGER_SCAN_MATCHED, - CONF_ON_FINGER_SCAN_UNMATCHED, - CONF_ON_FINGER_SCAN_MISPLACED, CONF_ON_FINGER_SCAN_INVALID, + CONF_ON_FINGER_SCAN_MATCHED, + CONF_ON_FINGER_SCAN_MISPLACED, + CONF_ON_FINGER_SCAN_START, + CONF_ON_FINGER_SCAN_UNMATCHED, CONF_PASSWORD, CONF_SENSING_PIN, CONF_SPEED, diff --git a/esphome/components/fingerprint_grow/binary_sensor.py b/esphome/components/fingerprint_grow/binary_sensor.py index 8572919e36..5b8441ddfe 100644 --- a/esphome/components/fingerprint_grow/binary_sensor.py +++ b/esphome/components/fingerprint_grow/binary_sensor.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_ICON, ICON_KEY_PLUS + from . import CONF_FINGERPRINT_GROW_ID, FingerprintGrowComponent DEPENDENCIES = ["fingerprint_grow"] diff --git a/esphome/components/fingerprint_grow/sensor.py b/esphome/components/fingerprint_grow/sensor.py index ed4e431dcc..d1655a6be1 100644 --- a/esphome/components/fingerprint_grow/sensor.py +++ b/esphome/components/fingerprint_grow/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_CAPACITY, CONF_FINGERPRINT_COUNT, @@ -15,6 +15,7 @@ from esphome.const import ( ICON_FINGERPRINT, ICON_SECURITY, ) + from . import CONF_FINGERPRINT_GROW_ID, FingerprintGrowComponent DEPENDENCIES = ["fingerprint_grow"] diff --git a/esphome/components/fs3000/sensor.py b/esphome/components/fs3000/sensor.py index 0c50f52979..a168a36c31 100644 --- a/esphome/components/fs3000/sensor.py +++ b/esphome/components/fs3000/sensor.py @@ -1,13 +1,9 @@ # initially based off of TMP117 component import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor -from esphome.const import ( - CONF_MODEL, - DEVICE_CLASS_WIND_SPEED, - STATE_CLASS_MEASUREMENT, -) +import esphome.config_validation as cv +from esphome.const import CONF_MODEL, DEVICE_CLASS_WIND_SPEED, STATE_CLASS_MEASUREMENT DEPENDENCIES = ["i2c"] CODEOWNERS = ["@kahrendt"] diff --git a/esphome/components/ft5x06/touchscreen/__init__.py b/esphome/components/ft5x06/touchscreen/__init__.py index 4ceb50c709..e94791da4e 100644 --- a/esphome/components/ft5x06/touchscreen/__init__.py +++ b/esphome/components/ft5x06/touchscreen/__init__.py @@ -1,9 +1,9 @@ from esphome import pins import esphome.codegen as cg -import esphome.config_validation as cv - from esphome.components import i2c, touchscreen +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_INTERRUPT_PIN + from .. import ft5x06_ns FT5x06ButtonListener = ft5x06_ns.class_("FT5x06ButtonListener") diff --git a/esphome/components/ft63x6/touchscreen.py b/esphome/components/ft63x6/touchscreen.py index 95fa371433..7615b3046f 100644 --- a/esphome/components/ft63x6/touchscreen.py +++ b/esphome/components/ft63x6/touchscreen.py @@ -1,8 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv - from esphome import pins +import esphome.codegen as cg from esphome.components import i2c, touchscreen +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_INTERRUPT_PIN, CONF_RESET_PIN, CONF_THRESHOLD CODEOWNERS = ["@gpambrozio"] diff --git a/esphome/components/fujitsu_general/climate.py b/esphome/components/fujitsu_general/climate.py index 427721f2db..6d2e46512e 100644 --- a/esphome/components/fujitsu_general/climate.py +++ b/esphome/components/fujitsu_general/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/gcja5/sensor.py b/esphome/components/gcja5/sensor.py index 5bcdc572ff..ec26447ccb 100644 --- a/esphome/components/gcja5/sensor.py +++ b/esphome/components/gcja5/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import sensor, uart import esphome.config_validation as cv -from esphome.components import uart, sensor from esphome.const import ( CONF_ID, CONF_PM_1_0, @@ -10,13 +10,13 @@ from esphome.const import ( CONF_PMC_1_0, CONF_PMC_2_5, CONF_PMC_10_0, - UNIT_MICROGRAMS_PER_CUBIC_METER, - ICON_CHEMICAL_WEAPON, - ICON_COUNTER, DEVICE_CLASS_PM1, DEVICE_CLASS_PM10, DEVICE_CLASS_PM25, + ICON_CHEMICAL_WEAPON, + ICON_COUNTER, STATE_CLASS_MEASUREMENT, + UNIT_MICROGRAMS_PER_CUBIC_METER, ) CODEOWNERS = ["@gcormier"] diff --git a/esphome/components/gdk101/__init__.py b/esphome/components/gdk101/__init__.py index 0d90257964..878f27bc44 100644 --- a/esphome/components/gdk101/__init__.py +++ b/esphome/components/gdk101/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@Szewcson"] diff --git a/esphome/components/gdk101/binary_sensor.py b/esphome/components/gdk101/binary_sensor.py index 2a3d6f07eb..a80487977f 100644 --- a/esphome/components/gdk101/binary_sensor.py +++ b/esphome/components/gdk101/binary_sensor.py @@ -1,12 +1,13 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import ( CONF_VIBRATIONS, DEVICE_CLASS_VIBRATION, ENTITY_CATEGORY_DIAGNOSTIC, ICON_VIBRATE, ) + from . import CONF_GDK101_ID, GDK101Component DEPENDENCIES = ["gdk101"] diff --git a/esphome/components/gdk101/sensor.py b/esphome/components/gdk101/sensor.py index f782264615..d04e0b8367 100644 --- a/esphome/components/gdk101/sensor.py +++ b/esphome/components/gdk101/sensor.py @@ -1,13 +1,13 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( - DEVICE_CLASS_DURATION, - DEVICE_CLASS_EMPTY, - ENTITY_CATEGORY_DIAGNOSTIC, CONF_MEASUREMENT_DURATION, CONF_STATUS, CONF_VERSION, + DEVICE_CLASS_DURATION, + DEVICE_CLASS_EMPTY, + ENTITY_CATEGORY_DIAGNOSTIC, ICON_RADIOACTIVE, ICON_TIMER, STATE_CLASS_MEASUREMENT, @@ -15,6 +15,7 @@ from esphome.const import ( UNIT_MICROSILVERTS_PER_HOUR, UNIT_SECOND, ) + from . import CONF_GDK101_ID, GDK101Component CONF_RADIATION_DOSE_PER_1M = "radiation_dose_per_1m" diff --git a/esphome/components/globals/__init__.py b/esphome/components/globals/__init__.py index 8defa4ac24..e4bce99b0b 100644 --- a/esphome/components/globals/__init__.py +++ b/esphome/components/globals/__init__.py @@ -1,7 +1,6 @@ import hashlib -from esphome import config_validation as cv, automation -from esphome import codegen as cg +from esphome import automation, codegen as cg, config_validation as cv from esphome.const import ( CONF_ID, CONF_INITIAL_VALUE, diff --git a/esphome/components/gp2y1010au0f/sensor.py b/esphome/components/gp2y1010au0f/sensor.py index 7e1bd277a6..4ff8a38226 100644 --- a/esphome/components/gp2y1010au0f/sensor.py +++ b/esphome/components/gp2y1010au0f/sensor.py @@ -1,13 +1,13 @@ import esphome.codegen as cg +from esphome.components import output, sensor, voltage_sampler import esphome.config_validation as cv -from esphome.components import sensor, voltage_sampler, output from esphome.const import ( - CONF_SENSOR, CONF_OUTPUT, + CONF_SENSOR, DEVICE_CLASS_PM25, + ICON_CHEMICAL_WEAPON, STATE_CLASS_MEASUREMENT, UNIT_MICROGRAMS_PER_CUBIC_METER, - ICON_CHEMICAL_WEAPON, ) DEPENDENCIES = ["output"] diff --git a/esphome/components/gp8403/__init__.py b/esphome/components/gp8403/__init__.py index a7a2b46f58..96f1807688 100644 --- a/esphome/components/gp8403/__init__.py +++ b/esphome/components/gp8403/__init__.py @@ -1,7 +1,6 @@ -import esphome.config_validation as cv import esphome.codegen as cg - from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_VOLTAGE CODEOWNERS = ["@jesserockz"] diff --git a/esphome/components/gp8403/output/__init__.py b/esphome/components/gp8403/output/__init__.py index 7f17faa1b1..dc57833f4a 100644 --- a/esphome/components/gp8403/output/__init__.py +++ b/esphome/components/gp8403/output/__init__.py @@ -1,10 +1,9 @@ -import esphome.config_validation as cv import esphome.codegen as cg - from esphome.components import i2c, output -from esphome.const import CONF_ID, CONF_CHANNEL +import esphome.config_validation as cv +from esphome.const import CONF_CHANNEL, CONF_ID -from .. import gp8403_ns, GP8403, CONF_GP8403_ID +from .. import CONF_GP8403_ID, GP8403, gp8403_ns DEPENDENCIES = ["gp8403"] diff --git a/esphome/components/gpio/binary_sensor/__init__.py b/esphome/components/gpio/binary_sensor/__init__.py index 786c3f4b96..23f2781095 100644 --- a/esphome/components/gpio/binary_sensor/__init__.py +++ b/esphome/components/gpio/binary_sensor/__init__.py @@ -1,8 +1,9 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_PIN + from .. import gpio_ns GPIOBinarySensor = gpio_ns.class_( diff --git a/esphome/components/gpio/one_wire/__init__.py b/esphome/components/gpio/one_wire/__init__.py index 2166e92083..e2bb94dd66 100644 --- a/esphome/components/gpio/one_wire/__init__.py +++ b/esphome/components/gpio/one_wire/__init__.py @@ -1,8 +1,9 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins -from esphome.const import CONF_ID, CONF_PIN +import esphome.codegen as cg from esphome.components.one_wire import OneWireBus +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_PIN + from .. import gpio_ns CODEOWNERS = ["@ssieb"] diff --git a/esphome/components/gpio/output/__init__.py b/esphome/components/gpio/output/__init__.py index 2fa9f4dc78..786e04bac0 100644 --- a/esphome/components/gpio/output/__init__.py +++ b/esphome/components/gpio/output/__init__.py @@ -1,8 +1,9 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_PIN + from .. import gpio_ns GPIOBinaryOutput = gpio_ns.class_("GPIOBinaryOutput", output.BinaryOutput, cg.Component) diff --git a/esphome/components/gpio/switch/__init__.py b/esphome/components/gpio/switch/__init__.py index 9da6870a46..604de6d809 100644 --- a/esphome/components/gpio/switch/__init__.py +++ b/esphome/components/gpio/switch/__init__.py @@ -1,8 +1,9 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import switch +import esphome.config_validation as cv from esphome.const import CONF_INTERLOCK, CONF_PIN + from .. import gpio_ns GPIOSwitch = gpio_ns.class_("GPIOSwitch", switch.Switch, cg.Component) diff --git a/esphome/components/gps/__init__.py b/esphome/components/gps/__init__.py index d4cf79b49e..51288ccc30 100644 --- a/esphome/components/gps/__init__.py +++ b/esphome/components/gps/__init__.py @@ -1,15 +1,14 @@ import esphome.codegen as cg +from esphome.components import sensor, uart import esphome.config_validation as cv -from esphome.components import uart -from esphome.components import sensor from esphome.const import ( + CONF_ALTITUDE, + CONF_COURSE, CONF_ID, CONF_LATITUDE, CONF_LONGITUDE, - CONF_SPEED, - CONF_COURSE, - CONF_ALTITUDE, CONF_SATELLITES, + CONF_SPEED, STATE_CLASS_MEASUREMENT, UNIT_DEGREES, UNIT_KILOMETER_PER_HOUR, diff --git a/esphome/components/gps/time/__init__.py b/esphome/components/gps/time/__init__.py index 1dae22a2b2..bdeeb86e00 100644 --- a/esphome/components/gps/time/__init__.py +++ b/esphome/components/gps/time/__init__.py @@ -1,8 +1,9 @@ +import esphome.codegen as cg from esphome.components import time as time_ import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import CONF_ID -from .. import gps_ns, GPSListener, CONF_GPS_ID, GPS + +from .. import CONF_GPS_ID, GPS, GPSListener, gps_ns DEPENDENCIES = ["gps"] diff --git a/esphome/components/graph/__init__.py b/esphome/components/graph/__init__.py index 0b83b71fe4..254294619e 100644 --- a/esphome/components/graph/__init__.py +++ b/esphome/components/graph/__init__.py @@ -1,32 +1,32 @@ -from esphome.components.font import Font -from esphome.components import sensor, color -import esphome.config_validation as cv import esphome.codegen as cg +from esphome.components import color, sensor +from esphome.components.font import Font +import esphome.config_validation as cv from esphome.const import ( + CONF_BORDER, CONF_COLOR, CONF_DIRECTION, CONF_DURATION, + CONF_HEIGHT, CONF_ID, CONF_LEGEND, + CONF_LINE_THICKNESS, + CONF_LINE_TYPE, + CONF_MAX_RANGE, + CONF_MAX_VALUE, + CONF_MIN_RANGE, + CONF_MIN_VALUE, CONF_NAME, CONF_NAME_FONT, + CONF_SENSOR, CONF_SHOW_LINES, CONF_SHOW_UNITS, CONF_SHOW_VALUES, + CONF_TRACES, CONF_VALUE_FONT, CONF_WIDTH, - CONF_SENSOR, - CONF_HEIGHT, - CONF_MIN_VALUE, - CONF_MAX_VALUE, - CONF_MIN_RANGE, - CONF_MAX_RANGE, - CONF_LINE_THICKNESS, - CONF_LINE_TYPE, CONF_X_GRID, CONF_Y_GRID, - CONF_BORDER, - CONF_TRACES, ) CODEOWNERS = ["@synco"] diff --git a/esphome/components/grove_tb6612fng/__init__.py b/esphome/components/grove_tb6612fng/__init__.py index 7db0198a89..869c05387f 100644 --- a/esphome/components/grove_tb6612fng/__init__.py +++ b/esphome/components/grove_tb6612fng/__init__.py @@ -1,14 +1,13 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import i2c - +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, - CONF_CHANNEL, - CONF_SPEED, - CONF_DIRECTION, CONF_ADDRESS, + CONF_CHANNEL, + CONF_DIRECTION, + CONF_ID, + CONF_SPEED, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/growatt_solar/sensor.py b/esphome/components/growatt_solar/sensor.py index 0db15ae53e..19f3adfd0e 100644 --- a/esphome/components/growatt_solar/sensor.py +++ b/esphome/components/growatt_solar/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import modbus, sensor import esphome.config_validation as cv -from esphome.components import sensor, modbus from esphome.const import ( CONF_ACTIVE_POWER, CONF_CURRENT, diff --git a/esphome/components/gt911/binary_sensor/__init__.py b/esphome/components/gt911/binary_sensor/__init__.py index 18f5c49dbd..941b7bb847 100644 --- a/esphome/components/gt911/binary_sensor/__init__.py +++ b/esphome/components/gt911/binary_sensor/__init__.py @@ -1,10 +1,10 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_INDEX from .. import gt911_ns -from ..touchscreen import GT911Touchscreen, GT911ButtonListener +from ..touchscreen import GT911ButtonListener, GT911Touchscreen CONF_GT911_ID = "gt911_id" diff --git a/esphome/components/haier/binary_sensor/__init__.py b/esphome/components/haier/binary_sensor/__init__.py index 3a4935b22d..2486b63155 100644 --- a/esphome/components/haier/binary_sensor/__init__.py +++ b/esphome/components/haier/binary_sensor/__init__.py @@ -1,15 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor -from esphome.const import ( - ENTITY_CATEGORY_DIAGNOSTIC, - ICON_FAN, - ICON_RADIATOR, -) -from ..climate import ( - CONF_HAIER_ID, - HonClimate, -) +import esphome.config_validation as cv +from esphome.const import ENTITY_CATEGORY_DIAGNOSTIC, ICON_FAN, ICON_RADIATOR + +from ..climate import CONF_HAIER_ID, HonClimate CODEOWNERS = ["@paveldn"] BinarySensorTypeEnum = HonClimate.enum("SubBinarySensorType", True) diff --git a/esphome/components/haier/button/__init__.py b/esphome/components/haier/button/__init__.py index 745ad95fb6..28bb5045c3 100644 --- a/esphome/components/haier/button/__init__.py +++ b/esphome/components/haier/button/__init__.py @@ -1,11 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import button -from ..climate import ( - CONF_HAIER_ID, - HonClimate, - haier_ns, -) +import esphome.config_validation as cv + +from ..climate import CONF_HAIER_ID, HonClimate, haier_ns CODEOWNERS = ["@paveldn"] SelfCleaningButton = haier_ns.class_("SelfCleaningButton", button.Button) diff --git a/esphome/components/haier/sensor/__init__.py b/esphome/components/haier/sensor/__init__.py index 23c1d6f008..e9025b560e 100644 --- a/esphome/components/haier/sensor/__init__.py +++ b/esphome/components/haier/sensor/__init__.py @@ -1,10 +1,10 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_HUMIDITY, CONF_OUTDOOR_TEMPERATURE, CONF_POWER, - CONF_HUMIDITY, DEVICE_CLASS_CURRENT, DEVICE_CLASS_FREQUENCY, DEVICE_CLASS_HUMIDITY, @@ -26,10 +26,8 @@ from esphome.const import ( UNIT_PERCENT, UNIT_WATT, ) -from ..climate import ( - CONF_HAIER_ID, - HonClimate, -) + +from ..climate import CONF_HAIER_ID, HonClimate CODEOWNERS = ["@paveldn"] SensorTypeEnum = HonClimate.enum("SubSensorType", True) diff --git a/esphome/components/haier/switch/__init__.py b/esphome/components/haier/switch/__init__.py index 6076cb0bd5..acff0cf265 100644 --- a/esphome/components/haier/switch/__init__.py +++ b/esphome/components/haier/switch/__init__.py @@ -1,18 +1,15 @@ import esphome.codegen as cg -import esphome.config_validation as cv -import esphome.final_validate as fv from esphome.components import switch -from esphome.const import ( - CONF_BEEPER, - CONF_DISPLAY, - ENTITY_CATEGORY_CONFIG, -) +import esphome.config_validation as cv +from esphome.const import CONF_BEEPER, CONF_DISPLAY, ENTITY_CATEGORY_CONFIG +import esphome.final_validate as fv + from ..climate import ( CONF_HAIER_ID, CONF_PROTOCOL, + PROTOCOL_HON, HaierClimateBase, haier_ns, - PROTOCOL_HON, ) CODEOWNERS = ["@paveldn"] diff --git a/esphome/components/haier/text_sensor/__init__.py b/esphome/components/haier/text_sensor/__init__.py index d28c5a8c0e..67f9fe1224 100644 --- a/esphome/components/haier/text_sensor/__init__.py +++ b/esphome/components/haier/text_sensor/__init__.py @@ -1,14 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor -from esphome.const import ( - ENTITY_CATEGORY_DIAGNOSTIC, - ENTITY_CATEGORY_NONE, -) -from ..climate import ( - CONF_HAIER_ID, - HonClimate, -) +import esphome.config_validation as cv +from esphome.const import ENTITY_CATEGORY_DIAGNOSTIC, ENTITY_CATEGORY_NONE + +from ..climate import CONF_HAIER_ID, HonClimate CODEOWNERS = ["@paveldn"] TextSensorTypeEnum = HonClimate.enum("SubTextSensorType", True) diff --git a/esphome/components/havells_solar/sensor.py b/esphome/components/havells_solar/sensor.py index 66b72f9e3e..532315a1d1 100644 --- a/esphome/components/havells_solar/sensor.py +++ b/esphome/components/havells_solar/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import modbus, sensor import esphome.config_validation as cv -from esphome.components import sensor, modbus from esphome.const import ( CONF_ACTIVE_POWER, CONF_CURRENT, diff --git a/esphome/components/hbridge/fan/__init__.py b/esphome/components/hbridge/fan/__init__.py index 424e944290..4309a64359 100644 --- a/esphome/components/hbridge/fan/__init__.py +++ b/esphome/components/hbridge/fan/__init__.py @@ -1,20 +1,20 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation from esphome.automation import maybe_simple_id +import esphome.codegen as cg from esphome.components import fan, output from esphome.components.fan import validate_preset_modes +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_DECAY_MODE, - CONF_SPEED_COUNT, + CONF_ENABLE_PIN, + CONF_ID, CONF_PIN_A, CONF_PIN_B, - CONF_ENABLE_PIN, CONF_PRESET_MODES, + CONF_SPEED_COUNT, ) -from .. import hbridge_ns +from .. import hbridge_ns CODEOWNERS = ["@WeekendWarrior"] diff --git a/esphome/components/hbridge/light/__init__.py b/esphome/components/hbridge/light/__init__.py index fe5c3e9845..65dd3196df 100644 --- a/esphome/components/hbridge/light/__init__.py +++ b/esphome/components/hbridge/light/__init__.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import light, output +import esphome.config_validation as cv from esphome.const import CONF_OUTPUT_ID, CONF_PIN_A, CONF_PIN_B + from .. import hbridge_ns CODEOWNERS = ["@DotNetDann"] diff --git a/esphome/components/hdc1080/sensor.py b/esphome/components/hdc1080/sensor.py index 39727f7159..e47a88545b 100644 --- a/esphome/components/hdc1080/sensor.py +++ b/esphome/components/hdc1080/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_HUMIDITY, CONF_ID, diff --git a/esphome/components/he60r/cover.py b/esphome/components/he60r/cover.py index fd4c746016..a483d2a571 100644 --- a/esphome/components/he60r/cover.py +++ b/esphome/components/he60r/cover.py @@ -1,11 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import cover, uart -from esphome.const import ( - CONF_CLOSE_DURATION, - CONF_ID, - CONF_OPEN_DURATION, -) +import esphome.config_validation as cv +from esphome.const import CONF_CLOSE_DURATION, CONF_ID, CONF_OPEN_DURATION he60r_ns = cg.esphome_ns.namespace("he60r") HE60rCover = he60r_ns.class_("HE60rCover", cover.Cover, cg.Component) diff --git a/esphome/components/heatpumpir/climate.py b/esphome/components/heatpumpir/climate.py index 598071590b..612b0d6123 100644 --- a/esphome/components/heatpumpir/climate.py +++ b/esphome/components/heatpumpir/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_MAX_TEMPERATURE, diff --git a/esphome/components/hitachi_ac344/climate.py b/esphome/components/hitachi_ac344/climate.py index 94b34eb955..0988d63995 100644 --- a/esphome/components/hitachi_ac344/climate.py +++ b/esphome/components/hitachi_ac344/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/hitachi_ac424/climate.py b/esphome/components/hitachi_ac424/climate.py index 33532230df..74f3c2fa14 100644 --- a/esphome/components/hitachi_ac424/climate.py +++ b/esphome/components/hitachi_ac424/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/hlw8012/sensor.py b/esphome/components/hlw8012/sensor.py index 2687edaca2..201ea4451f 100644 --- a/esphome/components/hlw8012/sensor.py +++ b/esphome/components/hlw8012/sensor.py @@ -1,17 +1,17 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_CHANGE_MODE_EVERY, - CONF_INITIAL_MODE, CONF_CURRENT, CONF_CURRENT_RESISTOR, - CONF_ID, - CONF_POWER, CONF_ENERGY, - CONF_SEL_PIN, + CONF_ID, + CONF_INITIAL_MODE, CONF_MODEL, + CONF_POWER, + CONF_SEL_PIN, CONF_VOLTAGE, CONF_VOLTAGE_DIVIDER, DEVICE_CLASS_CURRENT, @@ -20,8 +20,8 @@ from esphome.const import ( DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, STATE_CLASS_TOTAL_INCREASING, - UNIT_VOLT, UNIT_AMPERE, + UNIT_VOLT, UNIT_WATT, UNIT_WATT_HOURS, ) diff --git a/esphome/components/hm3301/sensor.py b/esphome/components/hm3301/sensor.py index 27af0b5b6b..5eb1773518 100644 --- a/esphome/components/hm3301/sensor.py +++ b/esphome/components/hm3301/sensor.py @@ -1,18 +1,18 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, + CONF_PM_1_0, CONF_PM_2_5, CONF_PM_10_0, - CONF_PM_1_0, DEVICE_CLASS_AQI, DEVICE_CLASS_PM1, DEVICE_CLASS_PM10, DEVICE_CLASS_PM25, + ICON_CHEMICAL_WEAPON, STATE_CLASS_MEASUREMENT, UNIT_MICROGRAMS_PER_CUBIC_METER, - ICON_CHEMICAL_WEAPON, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/hmc5883l/sensor.py b/esphome/components/hmc5883l/sensor.py index f2decea150..96d0313008 100644 --- a/esphome/components/hmc5883l/sensor.py +++ b/esphome/components/hmc5883l/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ADDRESS, CONF_FIELD_STRENGTH_X, @@ -10,12 +10,12 @@ from esphome.const import ( CONF_ID, CONF_OVERSAMPLING, CONF_RANGE, - ICON_MAGNET, - STATE_CLASS_MEASUREMENT, - UNIT_MICROTESLA, - UNIT_DEGREES, - ICON_SCREEN_ROTATION, CONF_UPDATE_INTERVAL, + ICON_MAGNET, + ICON_SCREEN_ROTATION, + STATE_CLASS_MEASUREMENT, + UNIT_DEGREES, + UNIT_MICROTESLA, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/homeassistant/time/__init__.py b/esphome/components/homeassistant/time/__init__.py index 0040988794..62cb96a25a 100644 --- a/esphome/components/homeassistant/time/__init__.py +++ b/esphome/components/homeassistant/time/__init__.py @@ -1,7 +1,8 @@ +import esphome.codegen as cg from esphome.components import time as time_ import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import CONF_ID + from .. import homeassistant_ns DEPENDENCIES = ["api"] diff --git a/esphome/components/honeywell_hih_i2c/sensor.py b/esphome/components/honeywell_hih_i2c/sensor.py index f5a6ad2398..93ae2b6056 100644 --- a/esphome/components/honeywell_hih_i2c/sensor.py +++ b/esphome/components/honeywell_hih_i2c/sensor.py @@ -1,15 +1,15 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_HUMIDITY, CONF_ID, CONF_TEMPERATURE, + DEVICE_CLASS_HUMIDITY, + DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_HUMIDITY, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/honeywellabp/sensor.py b/esphome/components/honeywellabp/sensor.py index ed8bff6e9b..25d03d31a6 100644 --- a/esphome/components/honeywellabp/sensor.py +++ b/esphome/components/honeywellabp/sensor.py @@ -1,7 +1,6 @@ import esphome.codegen as cg +from esphome.components import sensor, spi import esphome.config_validation as cv -from esphome.components import sensor -from esphome.components import spi from esphome.const import ( CONF_ID, CONF_PRESSURE, diff --git a/esphome/components/honeywellabp2_i2c/sensor.py b/esphome/components/honeywellabp2_i2c/sensor.py index c38a380127..2708e5d423 100644 --- a/esphome/components/honeywellabp2_i2c/sensor.py +++ b/esphome/components/honeywellabp2_i2c/sensor.py @@ -1,7 +1,6 @@ import esphome.codegen as cg +from esphome.components import i2c, sensor import esphome.config_validation as cv -from esphome.components import sensor -from esphome.components import i2c from esphome.const import ( CONF_ID, CONF_PRESSURE, diff --git a/esphome/components/host/time/__init__.py b/esphome/components/host/time/__init__.py index 76a88d98a1..d9a2f1207c 100644 --- a/esphome/components/host/time/__init__.py +++ b/esphome/components/host/time/__init__.py @@ -1,7 +1,7 @@ import esphome.codegen as cg -from esphome.const import CONF_ID -import esphome.config_validation as cv from esphome.components import time as time_ +import esphome.config_validation as cv +from esphome.const import CONF_ID CODEOWNERS = ["@clydebarrow"] diff --git a/esphome/components/hrxl_maxsonar_wr/sensor.py b/esphome/components/hrxl_maxsonar_wr/sensor.py index a78ae574b1..d335d76dfa 100644 --- a/esphome/components/hrxl_maxsonar_wr/sensor.py +++ b/esphome/components/hrxl_maxsonar_wr/sensor.py @@ -1,9 +1,9 @@ import esphome.codegen as cg from esphome.components import sensor, uart from esphome.const import ( + ICON_ARROW_EXPAND_VERTICAL, STATE_CLASS_MEASUREMENT, UNIT_METER, - ICON_ARROW_EXPAND_VERTICAL, ) CODEOWNERS = ["@netmikey"] diff --git a/esphome/components/hte501/sensor.py b/esphome/components/hte501/sensor.py index 8bd6160038..7eef641c4a 100644 --- a/esphome/components/hte501/sensor.py +++ b/esphome/components/hte501/sensor.py @@ -1,12 +1,12 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_HUMIDITY, + CONF_ID, CONF_TEMPERATURE, - DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_HUMIDITY, + DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, diff --git a/esphome/components/http_request/ota/__init__.py b/esphome/components/http_request/ota/__init__.py index 0ef1fc2348..a3f6d5840c 100644 --- a/esphome/components/http_request/ota/__init__.py +++ b/esphome/components/http_request/ota/__init__.py @@ -1,15 +1,11 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation -from esphome.const import ( - CONF_ID, - CONF_PASSWORD, - CONF_URL, - CONF_USERNAME, -) -from esphome.components.ota import BASE_OTA_SCHEMA, ota_to_code, OTAComponent +import esphome.codegen as cg +from esphome.components.ota import BASE_OTA_SCHEMA, OTAComponent, ota_to_code +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_PASSWORD, CONF_URL, CONF_USERNAME from esphome.core import coroutine_with_priority -from .. import CONF_HTTP_REQUEST_ID, http_request_ns, HttpRequestComponent + +from .. import CONF_HTTP_REQUEST_ID, HttpRequestComponent, http_request_ns CODEOWNERS = ["@oarcher"] diff --git a/esphome/components/http_request/update/__init__.py b/esphome/components/http_request/update/__init__.py index 356afa1432..f1b282d891 100644 --- a/esphome/components/http_request/update/__init__.py +++ b/esphome/components/http_request/update/__init__.py @@ -1,15 +1,11 @@ -import esphome.config_validation as cv import esphome.codegen as cg - from esphome.components import update -from esphome.const import ( - CONF_SOURCE, -) +import esphome.config_validation as cv +from esphome.const import CONF_SOURCE -from .. import http_request_ns, CONF_HTTP_REQUEST_ID, HttpRequestComponent +from .. import CONF_HTTP_REQUEST_ID, HttpRequestComponent, http_request_ns from ..ota import OtaHttpRequestComponent - AUTO_LOAD = ["json"] CODEOWNERS = ["@jesserockz"] DEPENDENCIES = ["ota.http_request"] diff --git a/esphome/components/htu21d/sensor.py b/esphome/components/htu21d/sensor.py index bf0b9a23fb..a578670e37 100644 --- a/esphome/components/htu21d/sensor.py +++ b/esphome/components/htu21d/sensor.py @@ -1,21 +1,21 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import i2c, sensor from esphome import automation +import esphome.codegen as cg +from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_HEATER, CONF_HUMIDITY, CONF_ID, + CONF_LEVEL, CONF_MODEL, + CONF_STATUS, CONF_TEMPERATURE, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, - UNIT_PERCENT, - CONF_HEATER, UNIT_EMPTY, - CONF_LEVEL, - CONF_STATUS, + UNIT_PERCENT, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/htu31d/sensor.py b/esphome/components/htu31d/sensor.py index fe53aa376e..638a8d77c5 100644 --- a/esphome/components/htu31d/sensor.py +++ b/esphome/components/htu31d/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_HUMIDITY, CONF_ID, diff --git a/esphome/components/hx711/sensor.py b/esphome/components/hx711/sensor.py index 88a0bb85b7..a5d11e9241 100644 --- a/esphome/components/hx711/sensor.py +++ b/esphome/components/hx711/sensor.py @@ -1,13 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import sensor -from esphome.const import ( - CONF_CLK_PIN, - CONF_GAIN, - ICON_SCALE, - STATE_CLASS_MEASUREMENT, -) +import esphome.config_validation as cv +from esphome.const import CONF_CLK_PIN, CONF_GAIN, ICON_SCALE, STATE_CLASS_MEASUREMENT hx711_ns = cg.esphome_ns.namespace("hx711") HX711Sensor = hx711_ns.class_("HX711Sensor", sensor.Sensor, cg.PollingComponent) diff --git a/esphome/components/hydreon_rgxx/binary_sensor.py b/esphome/components/hydreon_rgxx/binary_sensor.py index 776be8a5d8..f899ce71ce 100644 --- a/esphome/components/hydreon_rgxx/binary_sensor.py +++ b/esphome/components/hydreon_rgxx/binary_sensor.py @@ -1,13 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor -from esphome.const import ( - CONF_ID, - DEVICE_CLASS_COLD, - DEVICE_CLASS_PROBLEM, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID, DEVICE_CLASS_COLD, DEVICE_CLASS_PROBLEM -from . import hydreon_rgxx_ns, HydreonRGxxComponent +from . import HydreonRGxxComponent, hydreon_rgxx_ns CONF_HYDREON_RGXX_ID = "hydreon_rgxx_id" CONF_TOO_COLD = "too_cold" diff --git a/esphome/components/hydreon_rgxx/sensor.py b/esphome/components/hydreon_rgxx/sensor.py index fb2099c85e..f81703c087 100644 --- a/esphome/components/hydreon_rgxx/sensor.py +++ b/esphome/components/hydreon_rgxx/sensor.py @@ -1,22 +1,22 @@ import esphome.codegen as cg +from esphome.components import sensor, uart import esphome.config_validation as cv -from esphome.components import uart, sensor from esphome.const import ( CONF_ID, CONF_MODEL, CONF_MOISTURE, CONF_RESOLUTION, CONF_TEMPERATURE, - DEVICE_CLASS_PRECIPITATION_INTENSITY, DEVICE_CLASS_PRECIPITATION, + DEVICE_CLASS_PRECIPITATION_INTENSITY, + ICON_THERMOMETER, STATE_CLASS_MEASUREMENT, STATE_CLASS_TOTAL_INCREASING, UNIT_CELSIUS, UNIT_MILLIMETER, - ICON_THERMOMETER, ) -from . import RGModel, RG15Resolution, HydreonRGxxComponent +from . import HydreonRGxxComponent, RG15Resolution, RGModel UNIT_INTENSITY = "intensity" UNIT_MILLIMETERS_PER_HOUR = "mm/h" diff --git a/esphome/components/hyt271/sensor.py b/esphome/components/hyt271/sensor.py index 2ec2836461..22364ce854 100644 --- a/esphome/components/hyt271/sensor.py +++ b/esphome/components/hyt271/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_HUMIDITY, CONF_ID, diff --git a/esphome/components/i2c_device/__init__.py b/esphome/components/i2c_device/__init__.py index e145ba56f8..531c363bd1 100644 --- a/esphome/components/i2c_device/__init__.py +++ b/esphome/components/i2c_device/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["i2c"] diff --git a/esphome/components/i2s_audio/media_player/__init__.py b/esphome/components/i2s_audio/media_player/__init__.py index dfa69ecadd..2882729b1e 100644 --- a/esphome/components/i2s_audio/media_player/__init__.py +++ b/esphome/components/i2s_audio/media_player/__init__.py @@ -1,21 +1,19 @@ -import esphome.codegen as cg -from esphome.components import media_player, esp32 -import esphome.config_validation as cv - from esphome import pins - +import esphome.codegen as cg +from esphome.components import esp32, media_player +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_MODE from .. import ( - i2s_audio_ns, - I2SAudioComponent, - I2SAudioOut, CONF_I2S_AUDIO_ID, CONF_I2S_DOUT_PIN, CONF_LEFT, - CONF_RIGHT, CONF_MONO, + CONF_RIGHT, CONF_STEREO, + I2SAudioComponent, + I2SAudioOut, + i2s_audio_ns, ) CODEOWNERS = ["@jesserockz"] diff --git a/esphome/components/iaqcore/sensor.py b/esphome/components/iaqcore/sensor.py index 51c5b283b7..d3306fd0f8 100644 --- a/esphome/components/iaqcore/sensor.py +++ b/esphome/components/iaqcore/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_CO2, CONF_ID, @@ -8,8 +8,8 @@ from esphome.const import ( DEVICE_CLASS_CARBON_DIOXIDE, DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, STATE_CLASS_MEASUREMENT, - UNIT_PARTS_PER_MILLION, UNIT_PARTS_PER_BILLION, + UNIT_PARTS_PER_MILLION, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/ina219/sensor.py b/esphome/components/ina219/sensor.py index 020be9bc6e..621fd62e82 100644 --- a/esphome/components/ina219/sensor.py +++ b/esphome/components/ina219/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_BUS_VOLTAGE, CONF_CURRENT, @@ -14,8 +14,8 @@ from esphome.const import ( DEVICE_CLASS_POWER, DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, - UNIT_VOLT, UNIT_AMPERE, + UNIT_VOLT, UNIT_WATT, ) diff --git a/esphome/components/ina226/sensor.py b/esphome/components/ina226/sensor.py index 0accc58c00..2a7b3fc212 100644 --- a/esphome/components/ina226/sensor.py +++ b/esphome/components/ina226/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_BUS_VOLTAGE, CONF_CURRENT, @@ -9,14 +9,14 @@ from esphome.const import ( CONF_POWER, CONF_SHUNT_RESISTANCE, CONF_SHUNT_VOLTAGE, - DEVICE_CLASS_VOLTAGE, + CONF_VOLTAGE, DEVICE_CLASS_CURRENT, DEVICE_CLASS_POWER, + DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, - UNIT_VOLT, UNIT_AMPERE, + UNIT_VOLT, UNIT_WATT, - CONF_VOLTAGE, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/ina260/sensor.py b/esphome/components/ina260/sensor.py index 732d15d9ca..b98b4ce6cb 100644 --- a/esphome/components/ina260/sensor.py +++ b/esphome/components/ina260/sensor.py @@ -1,17 +1,17 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_BUS_VOLTAGE, CONF_CURRENT, + CONF_ID, CONF_POWER, - DEVICE_CLASS_VOLTAGE, DEVICE_CLASS_CURRENT, DEVICE_CLASS_POWER, + DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, - UNIT_VOLT, UNIT_AMPERE, + UNIT_VOLT, UNIT_WATT, ) diff --git a/esphome/components/ina2xx_base/__init__.py b/esphome/components/ina2xx_base/__init__.py index 35b5baa83e..7c3d3c8899 100644 --- a/esphome/components/ina2xx_base/__init__.py +++ b/esphome/components/ina2xx_base/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_BUS_VOLTAGE, CONF_CURRENT, @@ -21,8 +21,8 @@ from esphome.const import ( UNIT_AMPERE, UNIT_CELSIUS, UNIT_VOLT, - UNIT_WATT_HOURS, UNIT_WATT, + UNIT_WATT_HOURS, ) CODEOWNERS = ["@latonita"] diff --git a/esphome/components/ina2xx_i2c/sensor.py b/esphome/components/ina2xx_i2c/sensor.py index 57ddcef17a..1a470aa628 100644 --- a/esphome/components/ina2xx_i2c/sensor.py +++ b/esphome/components/ina2xx_i2c/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import i2c, ina2xx_base import esphome.config_validation as cv -from esphome.components import ina2xx_base, i2c from esphome.const import CONF_ID, CONF_MODEL AUTO_LOAD = ["ina2xx_base"] diff --git a/esphome/components/ina2xx_spi/sensor.py b/esphome/components/ina2xx_spi/sensor.py index e7ae51d516..3ebe2cac73 100644 --- a/esphome/components/ina2xx_spi/sensor.py +++ b/esphome/components/ina2xx_spi/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import ina2xx_base, spi +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_MODEL AUTO_LOAD = ["ina2xx_base"] diff --git a/esphome/components/ina3221/sensor.py b/esphome/components/ina3221/sensor.py index 9c42ecbb9d..acf7d7cdf0 100644 --- a/esphome/components/ina3221/sensor.py +++ b/esphome/components/ina3221/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_BUS_VOLTAGE, CONF_CURRENT, @@ -8,12 +8,12 @@ from esphome.const import ( CONF_POWER, CONF_SHUNT_RESISTANCE, CONF_SHUNT_VOLTAGE, - DEVICE_CLASS_VOLTAGE, DEVICE_CLASS_CURRENT, DEVICE_CLASS_POWER, + DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, - UNIT_VOLT, UNIT_AMPERE, + UNIT_VOLT, UNIT_WATT, ) diff --git a/esphome/components/inkbird_ibsth1_mini/sensor.py b/esphome/components/inkbird_ibsth1_mini/sensor.py index cdd0b5ade5..b446c9f1e2 100644 --- a/esphome/components/inkbird_ibsth1_mini/sensor.py +++ b/esphome/components/inkbird_ibsth1_mini/sensor.py @@ -1,10 +1,11 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, CONF_EXTERNAL_TEMPERATURE, CONF_HUMIDITY, + CONF_ID, CONF_MAC_ADDRESS, CONF_TEMPERATURE, DEVICE_CLASS_BATTERY, @@ -14,7 +15,6 @@ from esphome.const import ( STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - CONF_ID, ) CODEOWNERS = ["@fkirill"] diff --git a/esphome/components/inkplate6/display.py b/esphome/components/inkplate6/display.py index 8fe7f7d41d..56d20508ec 100644 --- a/esphome/components/inkplate6/display.py +++ b/esphome/components/inkplate6/display.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import display, i2c +import esphome.config_validation as cv from esphome.const import ( CONF_FULL_UPDATE_EVERY, CONF_ID, diff --git a/esphome/components/integration/sensor.py b/esphome/components/integration/sensor.py index d57f909662..3c04a338dd 100644 --- a/esphome/components/integration/sensor.py +++ b/esphome/components/integration/sensor.py @@ -1,14 +1,14 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_ACCURACY_DECIMALS, CONF_ICON, CONF_ID, - CONF_SENSOR, CONF_RESTORE, + CONF_SENSOR, CONF_UNIT_OF_MEASUREMENT, - CONF_ACCURACY_DECIMALS, ) from esphome.core.entity_helpers import inherit_property_from diff --git a/esphome/components/internal_temperature/sensor.py b/esphome/components/internal_temperature/sensor.py index 809d7a40b9..9bfa3739c8 100644 --- a/esphome/components/internal_temperature/sensor.py +++ b/esphome/components/internal_temperature/sensor.py @@ -1,20 +1,18 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor from esphome.components.esp32 import get_esp32_variant -from esphome.components.esp32.const import ( - VARIANT_ESP32S3, -) +from esphome.components.esp32.const import VARIANT_ESP32S3 +import esphome.config_validation as cv from esphome.const import ( - STATE_CLASS_MEASUREMENT, - UNIT_CELSIUS, DEVICE_CLASS_TEMPERATURE, ENTITY_CATEGORY_DIAGNOSTIC, KEY_CORE, KEY_FRAMEWORK_VERSION, + PLATFORM_BK72XX, PLATFORM_ESP32, PLATFORM_RP2040, - PLATFORM_BK72XX, + STATE_CLASS_MEASUREMENT, + UNIT_CELSIUS, ) from esphome.core import CORE diff --git a/esphome/components/interval/__init__.py b/esphome/components/interval/__init__.py index db3232c4b0..ac9219ff6a 100644 --- a/esphome/components/interval/__init__.py +++ b/esphome/components/interval/__init__.py @@ -1,6 +1,6 @@ +from esphome import automation import esphome.codegen as cg import esphome.config_validation as cv -from esphome import automation from esphome.const import CONF_ID, CONF_INTERVAL, CONF_STARTUP_DELAY CODEOWNERS = ["@esphome/core"] diff --git a/esphome/components/jsn_sr04t/sensor.py b/esphome/components/jsn_sr04t/sensor.py index 682cf06570..214724aa3f 100644 --- a/esphome/components/jsn_sr04t/sensor.py +++ b/esphome/components/jsn_sr04t/sensor.py @@ -1,11 +1,11 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( + CONF_MODEL, + ICON_ARROW_EXPAND_VERTICAL, STATE_CLASS_MEASUREMENT, UNIT_METER, - ICON_ARROW_EXPAND_VERTICAL, - CONF_MODEL, ) CODEOWNERS = ["@Mafus1"] diff --git a/esphome/components/kamstrup_kmp/sensor.py b/esphome/components/kamstrup_kmp/sensor.py index c9024e4a2b..fb37ac2c8d 100644 --- a/esphome/components/kamstrup_kmp/sensor.py +++ b/esphome/components/kamstrup_kmp/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( CONF_COMMAND, CONF_CUSTOM, diff --git a/esphome/components/key_collector/__init__.py b/esphome/components/key_collector/__init__.py index fd142b3cd7..5750812f5c 100644 --- a/esphome/components/key_collector/__init__.py +++ b/esphome/components/key_collector/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import key_provider +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_MAX_LENGTH, diff --git a/esphome/components/kmeteriso/sensor.py b/esphome/components/kmeteriso/sensor.py index 082a055701..4f6cb7d091 100644 --- a/esphome/components/kmeteriso/sensor.py +++ b/esphome/components/kmeteriso/sensor.py @@ -1,14 +1,14 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_INTERNAL_TEMPERATURE, CONF_TEMPERATURE, DEVICE_CLASS_TEMPERATURE, + ENTITY_CATEGORY_DIAGNOSTIC, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, - ENTITY_CATEGORY_DIAGNOSTIC, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/kuntze/sensor.py b/esphome/components/kuntze/sensor.py index 96c874fa5c..96b6334730 100644 --- a/esphome/components/kuntze/sensor.py +++ b/esphome/components/kuntze/sensor.py @@ -1,19 +1,19 @@ import esphome.codegen as cg +from esphome.components import modbus, sensor import esphome.config_validation as cv -from esphome.components import sensor, modbus from esphome.const import ( - CONF_ID, CONF_EC, + CONF_ID, CONF_PH, CONF_TEMPERATURE, + DEVICE_CLASS_EMPTY, + DEVICE_CLASS_TEMPERATURE, ICON_EMPTY, ICON_THERMOMETER, + STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_EMPTY, UNIT_PH, - STATE_CLASS_MEASUREMENT, - DEVICE_CLASS_EMPTY, - DEVICE_CLASS_TEMPERATURE, ) CODEOWNERS = ["@ssieb"] diff --git a/esphome/components/lcd_base/__init__.py b/esphome/components/lcd_base/__init__.py index 693211c6fe..bf1072ce66 100644 --- a/esphome/components/lcd_base/__init__.py +++ b/esphome/components/lcd_base/__init__.py @@ -1,7 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import display -from esphome.const import CONF_DIMENSIONS, CONF_POSITION, CONF_DATA +import esphome.config_validation as cv +from esphome.const import CONF_DATA, CONF_DIMENSIONS, CONF_POSITION CONF_USER_CHARACTERS = "user_characters" diff --git a/esphome/components/lcd_gpio/display.py b/esphome/components/lcd_gpio/display.py index bfef402058..caa73194c9 100644 --- a/esphome/components/lcd_gpio/display.py +++ b/esphome/components/lcd_gpio/display.py @@ -1,14 +1,14 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import lcd_base +import esphome.config_validation as cv from esphome.const import ( CONF_DATA_PINS, CONF_ENABLE_PIN, - CONF_RS_PIN, - CONF_RW_PIN, CONF_ID, CONF_LAMBDA, + CONF_RS_PIN, + CONF_RW_PIN, ) AUTO_LOAD = ["lcd_base"] diff --git a/esphome/components/lcd_menu/__init__.py b/esphome/components/lcd_menu/__init__.py index b57a4a0f6c..3f3162e31e 100644 --- a/esphome/components/lcd_menu/__init__.py +++ b/esphome/components/lcd_menu/__init__.py @@ -1,17 +1,13 @@ import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.const import ( - CONF_ID, - CONF_DIMENSIONS, - CONF_DISPLAY_ID, -) -from esphome.core.entity_helpers import inherit_property_from from esphome.components import lcd_base from esphome.components.display_menu_base import ( DISPLAY_MENU_BASE_SCHEMA, DisplayMenuComponent, display_menu_to_code, ) +import esphome.config_validation as cv +from esphome.const import CONF_DIMENSIONS, CONF_DISPLAY_ID, CONF_ID +from esphome.core.entity_helpers import inherit_property_from CODEOWNERS = ["@numo68"] diff --git a/esphome/components/lcd_pcf8574/display.py b/esphome/components/lcd_pcf8574/display.py index 5d9dd7adba..410c7f81b7 100644 --- a/esphome/components/lcd_pcf8574/display.py +++ b/esphome/components/lcd_pcf8574/display.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import i2c, lcd_base import esphome.config_validation as cv -from esphome.components import lcd_base, i2c from esphome.const import CONF_ID, CONF_LAMBDA DEPENDENCIES = ["i2c"] diff --git a/esphome/components/ld2410/__init__.py b/esphome/components/ld2410/__init__.py index 2b30b65f46..c58b9a4017 100644 --- a/esphome/components/ld2410/__init__.py +++ b/esphome/components/ld2410/__init__.py @@ -1,9 +1,9 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import uart -from esphome.const import CONF_ID, CONF_THROTTLE, CONF_TIMEOUT, CONF_PASSWORD from esphome import automation from esphome.automation import maybe_simple_id +import esphome.codegen as cg +from esphome.components import uart +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_PASSWORD, CONF_THROTTLE, CONF_TIMEOUT DEPENDENCIES = ["uart"] CODEOWNERS = ["@sebcaps", "@regevbr"] diff --git a/esphome/components/ld2410/binary_sensor.py b/esphome/components/ld2410/binary_sensor.py index e00ab93be2..d2938754e9 100644 --- a/esphome/components/ld2410/binary_sensor.py +++ b/esphome/components/ld2410/binary_sensor.py @@ -2,16 +2,17 @@ import esphome.codegen as cg from esphome.components import binary_sensor import esphome.config_validation as cv from esphome.const import ( + CONF_HAS_MOVING_TARGET, + CONF_HAS_STILL_TARGET, + CONF_HAS_TARGET, DEVICE_CLASS_MOTION, DEVICE_CLASS_OCCUPANCY, DEVICE_CLASS_PRESENCE, ENTITY_CATEGORY_DIAGNOSTIC, - ICON_MOTION_SENSOR, ICON_ACCOUNT, - CONF_HAS_TARGET, - CONF_HAS_MOVING_TARGET, - CONF_HAS_STILL_TARGET, + ICON_MOTION_SENSOR, ) + from . import CONF_LD2410_ID, LD2410Component DEPENDENCIES = ["ld2410"] diff --git a/esphome/components/ld2410/button/__init__.py b/esphome/components/ld2410/button/__init__.py index 34b18e8bdd..4cb50d707b 100644 --- a/esphome/components/ld2410/button/__init__.py +++ b/esphome/components/ld2410/button/__init__.py @@ -5,12 +5,13 @@ from esphome.const import ( CONF_FACTORY_RESET, CONF_RESTART, DEVICE_CLASS_RESTART, - ENTITY_CATEGORY_DIAGNOSTIC, ENTITY_CATEGORY_CONFIG, + ENTITY_CATEGORY_DIAGNOSTIC, + ICON_DATABASE, ICON_RESTART, ICON_RESTART_ALERT, - ICON_DATABASE, ) + from .. import CONF_LD2410_ID, LD2410Component, ld2410_ns QueryButton = ld2410_ns.class_("QueryButton", button.Button) diff --git a/esphome/components/ld2410/number/__init__.py b/esphome/components/ld2410/number/__init__.py index 557b226dfe..1f9c50db1f 100644 --- a/esphome/components/ld2410/number/__init__.py +++ b/esphome/components/ld2410/number/__init__.py @@ -5,15 +5,16 @@ from esphome.const import ( CONF_ID, CONF_TIMEOUT, DEVICE_CLASS_DISTANCE, - DEVICE_CLASS_SIGNAL_STRENGTH, DEVICE_CLASS_ILLUMINANCE, - UNIT_SECOND, - UNIT_PERCENT, + DEVICE_CLASS_SIGNAL_STRENGTH, ENTITY_CATEGORY_CONFIG, + ICON_LIGHTBULB, ICON_MOTION_SENSOR, ICON_TIMELAPSE, - ICON_LIGHTBULB, + UNIT_PERCENT, + UNIT_SECOND, ) + from .. import CONF_LD2410_ID, LD2410Component, ld2410_ns GateThresholdNumber = ld2410_ns.class_("GateThresholdNumber", number.Number) diff --git a/esphome/components/ld2410/select/__init__.py b/esphome/components/ld2410/select/__init__.py index 6c34a85ac6..686afdef14 100644 --- a/esphome/components/ld2410/select/__init__.py +++ b/esphome/components/ld2410/select/__init__.py @@ -2,13 +2,14 @@ import esphome.codegen as cg from esphome.components import select import esphome.config_validation as cv from esphome.const import ( - ENTITY_CATEGORY_CONFIG, CONF_BAUD_RATE, - ICON_THERMOMETER, - ICON_SCALE, + ENTITY_CATEGORY_CONFIG, ICON_LIGHTBULB, ICON_RULER, + ICON_SCALE, + ICON_THERMOMETER, ) + from .. import CONF_LD2410_ID, LD2410Component, ld2410_ns BaudRateSelect = ld2410_ns.class_("BaudRateSelect", select.Select) diff --git a/esphome/components/ld2410/sensor.py b/esphome/components/ld2410/sensor.py index 83361db58a..38de1799cc 100644 --- a/esphome/components/ld2410/sensor.py +++ b/esphome/components/ld2410/sensor.py @@ -2,17 +2,18 @@ import esphome.codegen as cg from esphome.components import sensor import esphome.config_validation as cv from esphome.const import ( - DEVICE_CLASS_DISTANCE, - UNIT_CENTIMETER, - UNIT_PERCENT, CONF_LIGHT, + DEVICE_CLASS_DISTANCE, DEVICE_CLASS_ILLUMINANCE, ENTITY_CATEGORY_DIAGNOSTIC, - ICON_SIGNAL, ICON_FLASH, - ICON_MOTION_SENSOR, ICON_LIGHTBULB, + ICON_MOTION_SENSOR, + ICON_SIGNAL, + UNIT_CENTIMETER, + UNIT_PERCENT, ) + from . import CONF_LD2410_ID, LD2410Component DEPENDENCIES = ["ld2410"] diff --git a/esphome/components/ld2410/switch/__init__.py b/esphome/components/ld2410/switch/__init__.py index 096cb5f67a..aecad606be 100644 --- a/esphome/components/ld2410/switch/__init__.py +++ b/esphome/components/ld2410/switch/__init__.py @@ -3,10 +3,11 @@ from esphome.components import switch import esphome.config_validation as cv from esphome.const import ( DEVICE_CLASS_SWITCH, - ICON_BLUETOOTH, ENTITY_CATEGORY_CONFIG, + ICON_BLUETOOTH, ICON_PULSE, ) + from .. import CONF_LD2410_ID, LD2410Component, ld2410_ns BluetoothSwitch = ld2410_ns.class_("BluetoothSwitch", switch.Switch) diff --git a/esphome/components/ld2410/text_sensor.py b/esphome/components/ld2410/text_sensor.py index d64472a7d3..5a021d9163 100644 --- a/esphome/components/ld2410/text_sensor.py +++ b/esphome/components/ld2410/text_sensor.py @@ -2,12 +2,13 @@ import esphome.codegen as cg from esphome.components import text_sensor import esphome.config_validation as cv from esphome.const import ( - ENTITY_CATEGORY_DIAGNOSTIC, - CONF_VERSION, CONF_MAC_ADDRESS, + CONF_VERSION, + ENTITY_CATEGORY_DIAGNOSTIC, ICON_BLUETOOTH, ICON_CHIP, ) + from . import CONF_LD2410_ID, LD2410Component DEPENDENCIES = ["ld2410"] diff --git a/esphome/components/ld2420/__init__.py b/esphome/components/ld2420/__init__.py index c701423081..71a5fa13e4 100644 --- a/esphome/components/ld2420/__init__.py +++ b/esphome/components/ld2420/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import uart +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@descipher"] diff --git a/esphome/components/ld2420/binary_sensor/__init__.py b/esphome/components/ld2420/binary_sensor/__init__.py index 43e22d0348..5ebc4a9f63 100644 --- a/esphome/components/ld2420/binary_sensor/__init__.py +++ b/esphome/components/ld2420/binary_sensor/__init__.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor -from esphome.const import CONF_ID, DEVICE_CLASS_OCCUPANCY, CONF_HAS_TARGET -from .. import ld2420_ns, LD2420Component, CONF_LD2420_ID +import esphome.config_validation as cv +from esphome.const import CONF_HAS_TARGET, CONF_ID, DEVICE_CLASS_OCCUPANCY + +from .. import CONF_LD2420_ID, LD2420Component, ld2420_ns LD2420BinarySensor = ld2420_ns.class_( "LD2420BinarySensor", binary_sensor.BinarySensor, cg.Component diff --git a/esphome/components/ld2420/button/__init__.py b/esphome/components/ld2420/button/__init__.py index df774ad7bc..dfeb121c91 100644 --- a/esphome/components/ld2420/button/__init__.py +++ b/esphome/components/ld2420/button/__init__.py @@ -4,12 +4,13 @@ import esphome.config_validation as cv from esphome.const import ( CONF_FACTORY_RESET, DEVICE_CLASS_RESTART, - ENTITY_CATEGORY_DIAGNOSTIC, ENTITY_CATEGORY_CONFIG, + ENTITY_CATEGORY_DIAGNOSTIC, + ICON_DATABASE, ICON_RESTART, ICON_RESTART_ALERT, - ICON_DATABASE, ) + from .. import CONF_LD2420_ID, LD2420Component, ld2420_ns LD2420ApplyConfigButton = ld2420_ns.class_("LD2420ApplyConfigButton", button.Button) diff --git a/esphome/components/ld2420/number/__init__.py b/esphome/components/ld2420/number/__init__.py index 4ae08356fc..1558243cc2 100644 --- a/esphome/components/ld2420/number/__init__.py +++ b/esphome/components/ld2420/number/__init__.py @@ -4,12 +4,13 @@ import esphome.config_validation as cv from esphome.const import ( CONF_ID, DEVICE_CLASS_DISTANCE, - UNIT_SECOND, ENTITY_CATEGORY_CONFIG, ICON_MOTION_SENSOR, - ICON_TIMELAPSE, ICON_SCALE, + ICON_TIMELAPSE, + UNIT_SECOND, ) + from .. import CONF_LD2420_ID, LD2420Component, ld2420_ns LD2420TimeoutNumber = ld2420_ns.class_("LD2420TimeoutNumber", number.Number) diff --git a/esphome/components/ld2420/select/__init__.py b/esphome/components/ld2420/select/__init__.py index 554bd4147d..6ccc00b41c 100644 --- a/esphome/components/ld2420/select/__init__.py +++ b/esphome/components/ld2420/select/__init__.py @@ -2,6 +2,7 @@ import esphome.codegen as cg from esphome.components import select import esphome.config_validation as cv from esphome.const import ENTITY_CATEGORY_CONFIG + from .. import CONF_LD2420_ID, LD2420Component, ld2420_ns CONF_OPERATING_MODE = "operating_mode" diff --git a/esphome/components/ld2420/sensor/__init__.py b/esphome/components/ld2420/sensor/__init__.py index 6a67d1fc41..e39ca99ae1 100644 --- a/esphome/components/ld2420/sensor/__init__.py +++ b/esphome/components/ld2420/sensor/__init__.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import CONF_ID, DEVICE_CLASS_DISTANCE, UNIT_CENTIMETER -from .. import ld2420_ns, LD2420Component, CONF_LD2420_ID + +from .. import CONF_LD2420_ID, LD2420Component, ld2420_ns LD2420Sensor = ld2420_ns.class_("LD2420Sensor", sensor.Sensor, cg.Component) diff --git a/esphome/components/ld2420/text_sensor/__init__.py b/esphome/components/ld2420/text_sensor/__init__.py index b6d8c7c0e4..14d982e5fb 100644 --- a/esphome/components/ld2420/text_sensor/__init__.py +++ b/esphome/components/ld2420/text_sensor/__init__.py @@ -1,13 +1,9 @@ import esphome.codegen as cg from esphome.components import text_sensor import esphome.config_validation as cv -from esphome.const import ( - CONF_ID, - ENTITY_CATEGORY_DIAGNOSTIC, - ICON_CHIP, -) +from esphome.const import CONF_ID, ENTITY_CATEGORY_DIAGNOSTIC, ICON_CHIP -from .. import ld2420_ns, LD2420Component, CONF_LD2420_ID +from .. import CONF_LD2420_ID, LD2420Component, ld2420_ns LD2420TextSensor = ld2420_ns.class_( "LD2420TextSensor", text_sensor.TextSensor, cg.Component diff --git a/esphome/components/ld2450/__init__.py b/esphome/components/ld2450/__init__.py index 37f68a8f3e..442fdaa125 100644 --- a/esphome/components/ld2450/__init__.py +++ b/esphome/components/ld2450/__init__.py @@ -1,10 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import uart -from esphome.const import ( - CONF_ID, - CONF_THROTTLE, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_THROTTLE DEPENDENCIES = ["uart"] CODEOWNERS = ["@hareeshmu"] diff --git a/esphome/components/ledc/output.py b/esphome/components/ledc/output.py index 32c68f8d24..2133c4daf9 100644 --- a/esphome/components/ledc/output.py +++ b/esphome/components/ledc/output.py @@ -1,12 +1,12 @@ -from esphome import pins, automation +from esphome import automation, pins +import esphome.codegen as cg from esphome.components import output import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import ( - CONF_PHASE_ANGLE, CONF_CHANNEL, CONF_FREQUENCY, CONF_ID, + CONF_PHASE_ANGLE, CONF_PIN, ) diff --git a/esphome/components/libretiny/text_sensor.py b/esphome/components/libretiny/text_sensor.py index df10ee7229..fa33fb6c02 100644 --- a/esphome/components/libretiny/text_sensor.py +++ b/esphome/components/libretiny/text_sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor +import esphome.config_validation as cv from esphome.const import ( CONF_VERSION, ENTITY_CATEGORY_DIAGNOSTIC, diff --git a/esphome/components/libretiny_pwm/output.py b/esphome/components/libretiny_pwm/output.py index e74bc8f129..1eb4869da3 100644 --- a/esphome/components/libretiny_pwm/output.py +++ b/esphome/components/libretiny_pwm/output.py @@ -1,12 +1,8 @@ -from esphome import pins, automation +from esphome import automation, pins +import esphome.codegen as cg from esphome.components import output import esphome.config_validation as cv -import esphome.codegen as cg -from esphome.const import ( - CONF_FREQUENCY, - CONF_ID, - CONF_PIN, -) +from esphome.const import CONF_FREQUENCY, CONF_ID, CONF_PIN DEPENDENCIES = ["libretiny"] diff --git a/esphome/components/lightwaverf/__init__.py b/esphome/components/lightwaverf/__init__.py index 4e96dda663..802b341601 100644 --- a/esphome/components/lightwaverf/__init__.py +++ b/esphome/components/lightwaverf/__init__.py @@ -1,17 +1,15 @@ +from esphome import automation, pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins -from esphome import automation - from esphome.const import ( - CONF_READ_PIN, - CONF_ID, - CONF_NAME, - CONF_WRITE_PIN, - CONF_REPEAT, - CONF_INVERTED, - CONF_PULSE_LENGTH, CONF_CODE, + CONF_ID, + CONF_INVERTED, + CONF_NAME, + CONF_PULSE_LENGTH, + CONF_READ_PIN, + CONF_REPEAT, + CONF_WRITE_PIN, ) from esphome.cpp_helpers import gpio_pin_expression diff --git a/esphome/components/lilygo_t5_47/touchscreen/__init__.py b/esphome/components/lilygo_t5_47/touchscreen/__init__.py index 17f7262785..93687846e2 100644 --- a/esphome/components/lilygo_t5_47/touchscreen/__init__.py +++ b/esphome/components/lilygo_t5_47/touchscreen/__init__.py @@ -1,8 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv - from esphome import pins +import esphome.codegen as cg from esphome.components import i2c, touchscreen +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_INTERRUPT_PIN from .. import lilygo_t5_47_ns diff --git a/esphome/components/ltr390/sensor.py b/esphome/components/ltr390/sensor.py index 62c3edf8cb..579adb9051 100644 --- a/esphome/components/ltr390/sensor.py +++ b/esphome/components/ltr390/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_AMBIENT_LIGHT, CONF_GAIN, diff --git a/esphome/components/ltr501/sensor.py b/esphome/components/ltr501/sensor.py index 153d1b3ad1..adaf669a72 100644 --- a/esphome/components/ltr501/sensor.py +++ b/esphome/components/ltr501/sensor.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ACTUAL_GAIN, CONF_ACTUAL_INTEGRATION_TIME, diff --git a/esphome/components/ltr_als_ps/sensor.py b/esphome/components/ltr_als_ps/sensor.py index e9a5264941..27263d0bff 100644 --- a/esphome/components/ltr_als_ps/sensor.py +++ b/esphome/components/ltr_als_ps/sensor.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ACTUAL_GAIN, CONF_ACTUAL_INTEGRATION_TIME, diff --git a/esphome/components/m5stack_8angle/__init__.py b/esphome/components/m5stack_8angle/__init__.py index 1aaa86a6fd..a1c197b381 100644 --- a/esphome/components/m5stack_8angle/__init__.py +++ b/esphome/components/m5stack_8angle/__init__.py @@ -1,9 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import CONF_ID - DEPENDENCIES = ["i2c"] CODEOWNERS = ["@rnauber"] MULTI_CONF = True diff --git a/esphome/components/m5stack_8angle/binary_sensor/__init__.py b/esphome/components/m5stack_8angle/binary_sensor/__init__.py index a8b2690083..22ab73e901 100644 --- a/esphome/components/m5stack_8angle/binary_sensor/__init__.py +++ b/esphome/components/m5stack_8angle/binary_sensor/__init__.py @@ -1,9 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv -from .. import M5Stack8AngleComponent, m5stack_8angle_ns, CONF_M5STACK_8ANGLE_ID - +from .. import CONF_M5STACK_8ANGLE_ID, M5Stack8AngleComponent, m5stack_8angle_ns M5Stack8AngleSwitchBinarySensor = m5stack_8angle_ns.class_( "M5Stack8AngleSwitchBinarySensor", diff --git a/esphome/components/m5stack_8angle/light/__init__.py b/esphome/components/m5stack_8angle/light/__init__.py index 07384ecd61..806ecaabf4 100644 --- a/esphome/components/m5stack_8angle/light/__init__.py +++ b/esphome/components/m5stack_8angle/light/__init__.py @@ -1,11 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import light - +import esphome.config_validation as cv from esphome.const import CONF_OUTPUT_ID -from .. import M5Stack8AngleComponent, m5stack_8angle_ns, CONF_M5STACK_8ANGLE_ID - +from .. import CONF_M5STACK_8ANGLE_ID, M5Stack8AngleComponent, m5stack_8angle_ns M5Stack8AngleLightsComponent = m5stack_8angle_ns.class_( "M5Stack8AngleLightOutput", diff --git a/esphome/components/m5stack_8angle/sensor/__init__.py b/esphome/components/m5stack_8angle/sensor/__init__.py index 70744a59e6..2132eaa4c2 100644 --- a/esphome/components/m5stack_8angle/sensor/__init__.py +++ b/esphome/components/m5stack_8angle/sensor/__init__.py @@ -1,7 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor - +import esphome.config_validation as cv from esphome.const import ( CONF_BIT_DEPTH, CONF_CHANNEL, @@ -11,13 +10,12 @@ from esphome.const import ( ) from .. import ( + CONF_M5STACK_8ANGLE_ID, AnalogBits, M5Stack8AngleComponent, m5stack_8angle_ns, - CONF_M5STACK_8ANGLE_ID, ) - M5Stack8AngleKnobSensor = m5stack_8angle_ns.class_( "M5Stack8AngleKnobSensor", sensor.Sensor, diff --git a/esphome/components/matrix_keypad/binary_sensor/__init__.py b/esphome/components/matrix_keypad/binary_sensor/__init__.py index edebf7b772..8e63ed43ce 100644 --- a/esphome/components/matrix_keypad/binary_sensor/__init__.py +++ b/esphome/components/matrix_keypad/binary_sensor/__init__.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor -from esphome.const import CONF_ID, CONF_KEY, CONF_ROW, CONF_COL -from .. import MatrixKeypad, matrix_keypad_ns, CONF_KEYPAD_ID +import esphome.config_validation as cv +from esphome.const import CONF_COL, CONF_ID, CONF_KEY, CONF_ROW + +from .. import CONF_KEYPAD_ID, MatrixKeypad, matrix_keypad_ns DEPENDENCIES = ["matrix_keypad"] diff --git a/esphome/components/max31855/sensor.py b/esphome/components/max31855/sensor.py index 0cdedb5464..93e48beee0 100644 --- a/esphome/components/max31855/sensor.py +++ b/esphome/components/max31855/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, spi +import esphome.config_validation as cv from esphome.const import ( CONF_REFERENCE_TEMPERATURE, DEVICE_CLASS_TEMPERATURE, diff --git a/esphome/components/max31865/sensor.py b/esphome/components/max31865/sensor.py index 704f945171..d4498b062f 100644 --- a/esphome/components/max31865/sensor.py +++ b/esphome/components/max31865/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, spi +import esphome.config_validation as cv from esphome.const import ( CONF_MAINS_FILTER, CONF_REFERENCE_RESISTANCE, diff --git a/esphome/components/max44009/sensor.py b/esphome/components/max44009/sensor.py index 498cccb77b..5aea7f0be2 100644 --- a/esphome/components/max44009/sensor.py +++ b/esphome/components/max44009/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import i2c, sensor import esphome.config_validation as cv -from esphome.components import sensor, i2c from esphome.const import ( CONF_ID, CONF_MODE, diff --git a/esphome/components/max6675/sensor.py b/esphome/components/max6675/sensor.py index 23fc86d2c2..e42abb68d1 100644 --- a/esphome/components/max6675/sensor.py +++ b/esphome/components/max6675/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, spi +import esphome.config_validation as cv from esphome.const import ( DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, diff --git a/esphome/components/max6956/__init__.py b/esphome/components/max6956/__init__.py index bb71dba8bf..0d2ff527c7 100644 --- a/esphome/components/max6956/__init__.py +++ b/esphome/components/max6956/__init__.py @@ -1,13 +1,13 @@ +from esphome import automation, pins import esphome.codegen as cg -import esphome.config_validation as cv -from esphome import pins, automation from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import ( CONF_ID, - CONF_NUMBER, - CONF_MODE, - CONF_INVERTED, CONF_INPUT, + CONF_INVERTED, + CONF_MODE, + CONF_NUMBER, CONF_OUTPUT, CONF_PULLUP, ) diff --git a/esphome/components/max6956/output/__init__.py b/esphome/components/max6956/output/__init__.py index 1caf8c8a44..352ba04a95 100644 --- a/esphome/components/max6956/output/__init__.py +++ b/esphome/components/max6956/output/__init__.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output -from esphome.const import CONF_PIN, CONF_ID -from .. import MAX6956, max6956_ns, CONF_MAX6956 +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_PIN + +from .. import CONF_MAX6956, MAX6956, max6956_ns DEPENDENCIES = ["max6956"] diff --git a/esphome/components/max7219/display.py b/esphome/components/max7219/display.py index 13807b0dbd..c9d10f3c45 100644 --- a/esphome/components/max7219/display.py +++ b/esphome/components/max7219/display.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import display, spi +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_INTENSITY, CONF_LAMBDA, CONF_NUM_CHIPS DEPENDENCIES = ["spi"] diff --git a/esphome/components/max7219digit/display.py b/esphome/components/max7219digit/display.py index 779e385ab1..582d11bf4f 100644 --- a/esphome/components/max7219digit/display.py +++ b/esphome/components/max7219digit/display.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import display, spi +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_INTENSITY, CONF_LAMBDA, CONF_NUM_CHIPS CODEOWNERS = ["@rspaargaren"] diff --git a/esphome/components/max9611/sensor.py b/esphome/components/max9611/sensor.py index 246d332a86..8405a3f75a 100644 --- a/esphome/components/max9611/sensor.py +++ b/esphome/components/max9611/sensor.py @@ -1,23 +1,23 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, - CONF_SHUNT_RESISTANCE, - CONF_GAIN, - CONF_VOLTAGE, CONF_CURRENT, + CONF_GAIN, + CONF_ID, CONF_POWER, + CONF_SHUNT_RESISTANCE, CONF_TEMPERATURE, - UNIT_VOLT, - UNIT_AMPERE, - UNIT_WATT, - UNIT_CELSIUS, - DEVICE_CLASS_VOLTAGE, + CONF_VOLTAGE, DEVICE_CLASS_CURRENT, DEVICE_CLASS_POWER, DEVICE_CLASS_TEMPERATURE, + DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, + UNIT_AMPERE, + UNIT_CELSIUS, + UNIT_VOLT, + UNIT_WATT, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/mcp23008/__init__.py b/esphome/components/mcp23008/__init__.py index a534c9f87f..ed48eb06a6 100644 --- a/esphome/components/mcp23008/__init__.py +++ b/esphome/components/mcp23008/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, mcp23x08_base, mcp23xxx_base +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["mcp23x08_base"] diff --git a/esphome/components/mcp23016/__init__.py b/esphome/components/mcp23016/__init__.py index 55722e3ae0..e15c643349 100644 --- a/esphome/components/mcp23016/__init__.py +++ b/esphome/components/mcp23016/__init__.py @@ -1,13 +1,13 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_INPUT, - CONF_NUMBER, - CONF_MODE, CONF_INVERTED, + CONF_MODE, + CONF_NUMBER, CONF_OUTPUT, ) diff --git a/esphome/components/mcp23017/__init__.py b/esphome/components/mcp23017/__init__.py index 42fc37dd1d..33b8a680cf 100644 --- a/esphome/components/mcp23017/__init__.py +++ b/esphome/components/mcp23017/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, mcp23x17_base, mcp23xxx_base +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["mcp23x17_base"] diff --git a/esphome/components/mcp23s08/__init__.py b/esphome/components/mcp23s08/__init__.py index 4d3998def8..c6152d58c0 100644 --- a/esphome/components/mcp23s08/__init__.py +++ b/esphome/components/mcp23s08/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import mcp23x08_base, mcp23xxx_base, spi import esphome.config_validation as cv -from esphome.components import spi, mcp23x08_base, mcp23xxx_base from esphome.const import CONF_ID AUTO_LOAD = ["mcp23x08_base"] diff --git a/esphome/components/mcp23s17/__init__.py b/esphome/components/mcp23s17/__init__.py index 9e199f79c4..9a763d09b0 100644 --- a/esphome/components/mcp23s17/__init__.py +++ b/esphome/components/mcp23s17/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import mcp23x17_base, mcp23xxx_base, spi import esphome.config_validation as cv -from esphome.components import spi, mcp23x17_base, mcp23xxx_base from esphome.const import CONF_ID AUTO_LOAD = ["mcp23x17_base"] diff --git a/esphome/components/mcp23xxx_base/__init__.py b/esphome/components/mcp23xxx_base/__init__.py index 1e41a8ddff..c0e44d72de 100644 --- a/esphome/components/mcp23xxx_base/__init__.py +++ b/esphome/components/mcp23xxx_base/__init__.py @@ -1,13 +1,13 @@ +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins from esphome.const import ( CONF_ID, CONF_INPUT, - CONF_NUMBER, - CONF_MODE, - CONF_INVERTED, CONF_INTERRUPT, + CONF_INVERTED, + CONF_MODE, + CONF_NUMBER, CONF_OPEN_DRAIN_INTERRUPT, CONF_OUTPUT, CONF_PULLUP, diff --git a/esphome/components/mcp2515/canbus.py b/esphome/components/mcp2515/canbus.py index 4353cd7bc6..d34a77248c 100644 --- a/esphome/components/mcp2515/canbus.py +++ b/esphome/components/mcp2515/canbus.py @@ -1,8 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import spi, canbus -from esphome.const import CONF_ID, CONF_MODE +from esphome.components import canbus, spi from esphome.components.canbus import CanbusComponent +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_MODE CODEOWNERS = ["@mvturnho", "@danielschramm"] DEPENDENCIES = ["spi"] diff --git a/esphome/components/mcp3008/__init__.py b/esphome/components/mcp3008/__init__.py index 24a48664c1..41ccdd403a 100644 --- a/esphome/components/mcp3008/__init__.py +++ b/esphome/components/mcp3008/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import spi +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["spi"] diff --git a/esphome/components/mcp3008/sensor/__init__.py b/esphome/components/mcp3008/sensor/__init__.py index 8ae00ef29e..e85ce2955d 100644 --- a/esphome/components/mcp3008/sensor/__init__.py +++ b/esphome/components/mcp3008/sensor/__init__.py @@ -1,16 +1,16 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, voltage_sampler +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_NUMBER, CONF_REFERENCE_VOLTAGE, - UNIT_VOLT, - STATE_CLASS_MEASUREMENT, DEVICE_CLASS_VOLTAGE, + STATE_CLASS_MEASUREMENT, + UNIT_VOLT, ) -from .. import mcp3008_ns, MCP3008 +from .. import MCP3008, mcp3008_ns AUTO_LOAD = ["voltage_sampler"] diff --git a/esphome/components/mcp3204/__init__.py b/esphome/components/mcp3204/__init__.py index 98129fc389..612297f934 100644 --- a/esphome/components/mcp3204/__init__.py +++ b/esphome/components/mcp3204/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import spi +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_REFERENCE_VOLTAGE DEPENDENCIES = ["spi"] diff --git a/esphome/components/mcp3204/sensor/__init__.py b/esphome/components/mcp3204/sensor/__init__.py index 6a81c6ec84..a4b177cbcf 100644 --- a/esphome/components/mcp3204/sensor/__init__.py +++ b/esphome/components/mcp3204/sensor/__init__.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, voltage_sampler +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_NUMBER -from .. import mcp3204_ns, MCP3204 + +from .. import MCP3204, mcp3204_ns AUTO_LOAD = ["voltage_sampler"] diff --git a/esphome/components/mcp4725/output.py b/esphome/components/mcp4725/output.py index 8f8b80d927..5ec6a9d686 100644 --- a/esphome/components/mcp4725/output.py +++ b/esphome/components/mcp4725/output.py @@ -1,6 +1,6 @@ -import esphome.config_validation as cv import esphome.codegen as cg -from esphome.components import output, i2c +from esphome.components import i2c, output +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["i2c"] diff --git a/esphome/components/mcp4728/__init__.py b/esphome/components/mcp4728/__init__.py index a0702c415c..da3244be84 100644 --- a/esphome/components/mcp4728/__init__.py +++ b/esphome/components/mcp4728/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@berfenger"] diff --git a/esphome/components/mcp4728/output/__init__.py b/esphome/components/mcp4728/output/__init__.py index 20b196ca2c..6f4a41510f 100644 --- a/esphome/components/mcp4728/output/__init__.py +++ b/esphome/components/mcp4728/output/__init__.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output -from esphome.const import CONF_CHANNEL, CONF_ID, CONF_GAIN -from .. import MCP4728Component, CONF_MCP4728_ID, mcp4728_ns +import esphome.config_validation as cv +from esphome.const import CONF_CHANNEL, CONF_GAIN, CONF_ID + +from .. import CONF_MCP4728_ID, MCP4728Component, mcp4728_ns DEPENDENCIES = ["mcp4728"] diff --git a/esphome/components/mcp47a1/output.py b/esphome/components/mcp47a1/output.py index 60235107e9..ebd597cfeb 100644 --- a/esphome/components/mcp47a1/output.py +++ b/esphome/components/mcp47a1/output.py @@ -1,6 +1,6 @@ -import esphome.config_validation as cv import esphome.codegen as cg -from esphome.components import output, i2c +from esphome.components import i2c, output +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@jesserockz"] diff --git a/esphome/components/mcp9808/sensor.py b/esphome/components/mcp9808/sensor.py index 2d7874fe20..ba6718ca56 100644 --- a/esphome/components/mcp9808/sensor.py +++ b/esphome/components/mcp9808/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, diff --git a/esphome/components/mhz19/sensor.py b/esphome/components/mhz19/sensor.py index 3956727981..10428b1e4a 100644 --- a/esphome/components/mhz19/sensor.py +++ b/esphome/components/mhz19/sensor.py @@ -1,18 +1,18 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation from esphome.automation import maybe_simple_id +import esphome.codegen as cg from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( CONF_CO2, CONF_ID, CONF_TEMPERATURE, - DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_CARBON_DIOXIDE, + DEVICE_CLASS_TEMPERATURE, ICON_MOLECULE_CO2, STATE_CLASS_MEASUREMENT, - UNIT_PARTS_PER_MILLION, UNIT_CELSIUS, + UNIT_PARTS_PER_MILLION, ) DEPENDENCIES = ["uart"] diff --git a/esphome/components/micronova/__init__.py b/esphome/components/micronova/__init__.py index bd253f8ebd..31abc11abf 100644 --- a/esphome/components/micronova/__init__.py +++ b/esphome/components/micronova/__init__.py @@ -1,10 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import uart -from esphome.const import ( - CONF_ID, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID CODEOWNERS = ["@jorre05"] diff --git a/esphome/components/micronova/button/__init__.py b/esphome/components/micronova/button/__init__.py index 442f69c08b..813d24efef 100644 --- a/esphome/components/micronova/button/__init__.py +++ b/esphome/components/micronova/button/__init__.py @@ -1,14 +1,14 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import button +import esphome.config_validation as cv from .. import ( + CONF_MEMORY_ADDRESS, + CONF_MEMORY_LOCATION, + CONF_MICRONOVA_ID, + MICRONOVA_LISTENER_SCHEMA, MicroNova, MicroNovaFunctions, - CONF_MICRONOVA_ID, - CONF_MEMORY_LOCATION, - CONF_MEMORY_ADDRESS, - MICRONOVA_LISTENER_SCHEMA, micronova_ns, ) diff --git a/esphome/components/micronova/number/__init__.py b/esphome/components/micronova/number/__init__.py index 7124bf50d0..b0eeaf8dd1 100644 --- a/esphome/components/micronova/number/__init__.py +++ b/esphome/components/micronova/number/__init__.py @@ -1,19 +1,15 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import number -from esphome.const import ( - DEVICE_CLASS_TEMPERATURE, - UNIT_CELSIUS, - CONF_STEP, -) +import esphome.config_validation as cv +from esphome.const import CONF_STEP, DEVICE_CLASS_TEMPERATURE, UNIT_CELSIUS from .. import ( + CONF_MEMORY_ADDRESS, + CONF_MEMORY_LOCATION, + CONF_MICRONOVA_ID, + MICRONOVA_LISTENER_SCHEMA, MicroNova, MicroNovaFunctions, - CONF_MICRONOVA_ID, - CONF_MEMORY_LOCATION, - CONF_MEMORY_ADDRESS, - MICRONOVA_LISTENER_SCHEMA, micronova_ns, ) diff --git a/esphome/components/micronova/sensor/__init__.py b/esphome/components/micronova/sensor/__init__.py index 32e42f3888..ceb4a9ef77 100644 --- a/esphome/components/micronova/sensor/__init__.py +++ b/esphome/components/micronova/sensor/__init__.py @@ -1,21 +1,21 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( - DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_PRESSURE, + DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_REVOLUTIONS_PER_MINUTE, ) from .. import ( + CONF_MEMORY_ADDRESS, + CONF_MEMORY_LOCATION, + CONF_MICRONOVA_ID, + MICRONOVA_LISTENER_SCHEMA, MicroNova, MicroNovaFunctions, - CONF_MICRONOVA_ID, - CONF_MEMORY_LOCATION, - CONF_MEMORY_ADDRESS, - MICRONOVA_LISTENER_SCHEMA, micronova_ns, ) diff --git a/esphome/components/micronova/switch/__init__.py b/esphome/components/micronova/switch/__init__.py index 9846d46cc6..43e5c9d844 100644 --- a/esphome/components/micronova/switch/__init__.py +++ b/esphome/components/micronova/switch/__init__.py @@ -1,17 +1,15 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import switch -from esphome.const import ( - ICON_POWER, -) +import esphome.config_validation as cv +from esphome.const import ICON_POWER from .. import ( + CONF_MEMORY_ADDRESS, + CONF_MEMORY_LOCATION, + CONF_MICRONOVA_ID, + MICRONOVA_LISTENER_SCHEMA, MicroNova, MicroNovaFunctions, - CONF_MICRONOVA_ID, - CONF_MEMORY_LOCATION, - CONF_MEMORY_ADDRESS, - MICRONOVA_LISTENER_SCHEMA, micronova_ns, ) diff --git a/esphome/components/micronova/text_sensor/__init__.py b/esphome/components/micronova/text_sensor/__init__.py index dc27c4f32c..474c30e13b 100644 --- a/esphome/components/micronova/text_sensor/__init__.py +++ b/esphome/components/micronova/text_sensor/__init__.py @@ -1,14 +1,14 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor +import esphome.config_validation as cv from .. import ( + CONF_MEMORY_ADDRESS, + CONF_MEMORY_LOCATION, + CONF_MICRONOVA_ID, + MICRONOVA_LISTENER_SCHEMA, MicroNova, MicroNovaFunctions, - CONF_MICRONOVA_ID, - CONF_MEMORY_LOCATION, - CONF_MEMORY_ADDRESS, - MICRONOVA_LISTENER_SCHEMA, micronova_ns, ) diff --git a/esphome/components/microphone/__init__.py b/esphome/components/microphone/__init__.py index d99500bbed..4e5471b117 100644 --- a/esphome/components/microphone/__init__.py +++ b/esphome/components/microphone/__init__.py @@ -1,13 +1,11 @@ from esphome import automation -import esphome.config_validation as cv -import esphome.codegen as cg - from esphome.automation import maybe_simple_id +import esphome.codegen as cg +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_TRIGGER_ID from esphome.core import CORE from esphome.coroutine import coroutine_with_priority - CODEOWNERS = ["@jesserockz"] IS_PLATFORM_COMPONENT = True diff --git a/esphome/components/midea/climate.py b/esphome/components/midea/climate.py index b7fef5e1ab..1d3cac66ba 100644 --- a/esphome/components/midea/climate.py +++ b/esphome/components/midea/climate.py @@ -1,9 +1,9 @@ -from esphome.core import coroutine from esphome import automation -from esphome.components import climate, sensor, uart, remote_transmitter +import esphome.codegen as cg +from esphome.components import climate, remote_transmitter, sensor, uart +from esphome.components.climate import ClimateMode, ClimatePreset, ClimateSwingMode from esphome.components.remote_base import CONF_TRANSMITTER_ID import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import ( CONF_AUTOCONF, CONF_BEEPER, @@ -16,12 +16,12 @@ from esphome.const import ( CONF_SUPPORTED_MODES, CONF_SUPPORTED_PRESETS, CONF_SUPPORTED_SWING_MODES, - CONF_TIMEOUT, CONF_TEMPERATURE, + CONF_TIMEOUT, CONF_USE_FAHRENHEIT, + DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_POWER, DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_HUMIDITY, ICON_POWER, ICON_THERMOMETER, ICON_WATER_PERCENT, @@ -30,11 +30,7 @@ from esphome.const import ( UNIT_PERCENT, UNIT_WATT, ) -from esphome.components.climate import ( - ClimateMode, - ClimatePreset, - ClimateSwingMode, -) +from esphome.core import coroutine CODEOWNERS = ["@dudanov"] DEPENDENCIES = ["climate", "uart"] diff --git a/esphome/components/midea_ir/climate.py b/esphome/components/midea_ir/climate.py index 8fea6b192b..21fa5f4f56 100644 --- a/esphome/components/midea_ir/climate.py +++ b/esphome/components/midea_ir/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_USE_FAHRENHEIT AUTO_LOAD = ["climate_ir", "coolix"] diff --git a/esphome/components/mitsubishi/climate.py b/esphome/components/mitsubishi/climate.py index 5e865c636f..23f8ed21fa 100644 --- a/esphome/components/mitsubishi/climate.py +++ b/esphome/components/mitsubishi/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@RubyBailey"] diff --git a/esphome/components/mlx90614/sensor.py b/esphome/components/mlx90614/sensor.py index 3e90d19e45..6a34c4bdc0 100644 --- a/esphome/components/mlx90614/sensor.py +++ b/esphome/components/mlx90614/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, DEVICE_CLASS_TEMPERATURE, diff --git a/esphome/components/mmc5603/sensor.py b/esphome/components/mmc5603/sensor.py index cf16132470..3223225271 100644 --- a/esphome/components/mmc5603/sensor.py +++ b/esphome/components/mmc5603/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ADDRESS, CONF_FIELD_STRENGTH_X, @@ -8,12 +8,12 @@ from esphome.const import ( CONF_FIELD_STRENGTH_Z, CONF_HEADING, CONF_ID, - ICON_MAGNET, - STATE_CLASS_MEASUREMENT, - UNIT_MICROTESLA, - UNIT_DEGREES, - ICON_SCREEN_ROTATION, CONF_UPDATE_INTERVAL, + ICON_MAGNET, + ICON_SCREEN_ROTATION, + STATE_CLASS_MEASUREMENT, + UNIT_DEGREES, + UNIT_MICROTESLA, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/mmc5983/sensor.py b/esphome/components/mmc5983/sensor.py index e3f4209cf9..aaff2946f2 100644 --- a/esphome/components/mmc5983/sensor.py +++ b/esphome/components/mmc5983/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_FIELD_STRENGTH_X, CONF_FIELD_STRENGTH_Y, diff --git a/esphome/components/modbus/__init__.py b/esphome/components/modbus/__init__.py index ae0c818c28..2bd85c6121 100644 --- a/esphome/components/modbus/__init__.py +++ b/esphome/components/modbus/__init__.py @@ -1,18 +1,14 @@ from __future__ import annotations + from typing import Literal -import esphome.codegen as cg -import esphome.config_validation as cv -import esphome.final_validate as fv -from esphome.cpp_helpers import gpio_pin_expression -from esphome.components import uart -from esphome.const import ( - CONF_FLOW_CONTROL_PIN, - CONF_ID, - CONF_ADDRESS, - CONF_DISABLE_CRC, -) from esphome import pins +import esphome.codegen as cg +from esphome.components import uart +import esphome.config_validation as cv +from esphome.const import CONF_ADDRESS, CONF_DISABLE_CRC, CONF_FLOW_CONTROL_PIN, CONF_ID +from esphome.cpp_helpers import gpio_pin_expression +import esphome.final_validate as fv DEPENDENCIES = ["uart"] diff --git a/esphome/components/modbus_controller/__init__.py b/esphome/components/modbus_controller/__init__.py index 2a08075831..61b60498d0 100644 --- a/esphome/components/modbus_controller/__init__.py +++ b/esphome/components/modbus_controller/__init__.py @@ -25,8 +25,8 @@ from .const import ( CONF_MODBUS_CONTROLLER_ID, CONF_OFFLINE_SKIP_UPDATES, CONF_ON_COMMAND_SENT, - CONF_ON_ONLINE, CONF_ON_OFFLINE, + CONF_ON_ONLINE, CONF_REGISTER_COUNT, CONF_REGISTER_TYPE, CONF_RESPONSE_SIZE, diff --git a/esphome/components/monochromatic/light.py b/esphome/components/monochromatic/light.py index 8f13f58f89..4ce0202d25 100644 --- a/esphome/components/monochromatic/light.py +++ b/esphome/components/monochromatic/light.py @@ -1,7 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import light, output -from esphome.const import CONF_OUTPUT_ID, CONF_OUTPUT +import esphome.config_validation as cv +from esphome.const import CONF_OUTPUT, CONF_OUTPUT_ID monochromatic_ns = cg.esphome_ns.namespace("monochromatic") MonochromaticLightOutput = monochromatic_ns.class_( diff --git a/esphome/components/mopeka_ble/__init__.py b/esphome/components/mopeka_ble/__init__.py index c89eae7933..c8648cbc63 100644 --- a/esphome/components/mopeka_ble/__init__.py +++ b/esphome/components/mopeka_ble/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import esp32_ble_tracker +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@spbrogan", "@Fabian-Schmidt"] diff --git a/esphome/components/mopeka_pro_check/sensor.py b/esphome/components/mopeka_pro_check/sensor.py index 95ade53013..4e84fb708c 100644 --- a/esphome/components/mopeka_pro_check/sensor.py +++ b/esphome/components/mopeka_pro_check/sensor.py @@ -1,25 +1,25 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( + CONF_BATTERY_LEVEL, CONF_DISTANCE, - CONF_MAC_ADDRESS, CONF_ID, + CONF_LEVEL, + CONF_MAC_ADDRESS, + CONF_TEMPERATURE, + DEVICE_CLASS_BATTERY, + DEVICE_CLASS_TEMPERATURE, + ENTITY_CATEGORY_DIAGNOSTIC, ICON_COUNTER, - ICON_THERMOMETER, ICON_RULER, ICON_SIGNAL, - UNIT_PERCENT, - UNIT_EMPTY, - CONF_LEVEL, - CONF_TEMPERATURE, - DEVICE_CLASS_TEMPERATURE, - UNIT_CELSIUS, - UNIT_MILLIMETER, + ICON_THERMOMETER, STATE_CLASS_MEASUREMENT, - CONF_BATTERY_LEVEL, - DEVICE_CLASS_BATTERY, - ENTITY_CATEGORY_DIAGNOSTIC, + UNIT_CELSIUS, + UNIT_EMPTY, + UNIT_MILLIMETER, + UNIT_PERCENT, ) CONF_TANK_TYPE = "tank_type" diff --git a/esphome/components/mopeka_std_check/sensor.py b/esphome/components/mopeka_std_check/sensor.py index ac745cf3d5..d4535d9671 100644 --- a/esphome/components/mopeka_std_check/sensor.py +++ b/esphome/components/mopeka_std_check/sensor.py @@ -1,21 +1,21 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( + CONF_BATTERY_LEVEL, CONF_DISTANCE, - CONF_MAC_ADDRESS, CONF_ID, - ICON_THERMOMETER, - ICON_RULER, - UNIT_PERCENT, CONF_LEVEL, + CONF_MAC_ADDRESS, CONF_TEMPERATURE, + DEVICE_CLASS_BATTERY, DEVICE_CLASS_TEMPERATURE, + ICON_RULER, + ICON_THERMOMETER, + STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_MILLIMETER, - STATE_CLASS_MEASUREMENT, - CONF_BATTERY_LEVEL, - DEVICE_CLASS_BATTERY, + UNIT_PERCENT, ) CONF_TANK_TYPE = "tank_type" diff --git a/esphome/components/mpl3115a2/sensor.py b/esphome/components/mpl3115a2/sensor.py index 68ed0e08a8..b2cd1fb535 100644 --- a/esphome/components/mpl3115a2/sensor.py +++ b/esphome/components/mpl3115a2/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ALTITUDE, CONF_ID, diff --git a/esphome/components/mpr121/__init__.py b/esphome/components/mpr121/__init__.py index 1f8e804e88..b736a7e4f0 100644 --- a/esphome/components/mpr121/__init__.py +++ b/esphome/components/mpr121/__init__.py @@ -1,8 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -import esphome.final_validate as fv from esphome import pins +import esphome.codegen as cg from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import ( CONF_BINARY_SENSOR, CONF_CHANNEL, @@ -13,6 +12,7 @@ from esphome.const import ( CONF_NUMBER, CONF_OUTPUT, ) +import esphome.final_validate as fv CONF_TOUCH_THRESHOLD = "touch_threshold" CONF_RELEASE_THRESHOLD = "release_threshold" diff --git a/esphome/components/mpr121/binary_sensor/__init__.py b/esphome/components/mpr121/binary_sensor/__init__.py index dfae92a9af..1252a65a84 100644 --- a/esphome/components/mpr121/binary_sensor/__init__.py +++ b/esphome/components/mpr121/binary_sensor/__init__.py @@ -1,13 +1,14 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL + from .. import ( - mpr121_ns, - MPR121Component, CONF_MPR121_ID, - CONF_TOUCH_THRESHOLD, CONF_RELEASE_THRESHOLD, + CONF_TOUCH_THRESHOLD, + MPR121Component, + mpr121_ns, ) DEPENDENCIES = ["mpr121"] diff --git a/esphome/components/mpu6050/sensor.py b/esphome/components/mpu6050/sensor.py index f9b61dcadc..377958fbe7 100644 --- a/esphome/components/mpu6050/sensor.py +++ b/esphome/components/mpu6050/sensor.py @@ -1,16 +1,16 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_TEMPERATURE, DEVICE_CLASS_TEMPERATURE, ICON_BRIEFCASE_DOWNLOAD, - STATE_CLASS_MEASUREMENT, - UNIT_METER_PER_SECOND_SQUARED, ICON_SCREEN_ROTATION, - UNIT_DEGREE_PER_SECOND, + STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, + UNIT_DEGREE_PER_SECOND, + UNIT_METER_PER_SECOND_SQUARED, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/mpu6886/sensor.py b/esphome/components/mpu6886/sensor.py index 535007d008..580fad7c23 100644 --- a/esphome/components/mpu6886/sensor.py +++ b/esphome/components/mpu6886/sensor.py @@ -1,16 +1,16 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_TEMPERATURE, DEVICE_CLASS_TEMPERATURE, ICON_BRIEFCASE_DOWNLOAD, - STATE_CLASS_MEASUREMENT, - UNIT_METER_PER_SECOND_SQUARED, ICON_SCREEN_ROTATION, - UNIT_DEGREE_PER_SECOND, + STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, + UNIT_DEGREE_PER_SECOND, + UNIT_METER_PER_SECOND_SQUARED, ) CODEOWNERS = ["@fabaff"] diff --git a/esphome/components/mqtt_subscribe/sensor/__init__.py b/esphome/components/mqtt_subscribe/sensor/__init__.py index 6fe0c48ae0..56efb3f67e 100644 --- a/esphome/components/mqtt_subscribe/sensor/__init__.py +++ b/esphome/components/mqtt_subscribe/sensor/__init__.py @@ -1,10 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import mqtt, sensor -from esphome.const import ( - CONF_QOS, - CONF_TOPIC, -) +import esphome.config_validation as cv +from esphome.const import CONF_QOS, CONF_TOPIC + from .. import mqtt_subscribe_ns DEPENDENCIES = ["mqtt"] diff --git a/esphome/components/mqtt_subscribe/text_sensor/__init__.py b/esphome/components/mqtt_subscribe/text_sensor/__init__.py index 5b5c0ae17f..9c5d3a81eb 100644 --- a/esphome/components/mqtt_subscribe/text_sensor/__init__.py +++ b/esphome/components/mqtt_subscribe/text_sensor/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import mqtt, text_sensor import esphome.config_validation as cv -from esphome.components import text_sensor, mqtt from esphome.const import CONF_QOS, CONF_TOPIC from .. import mqtt_subscribe_ns diff --git a/esphome/components/ms5611/sensor.py b/esphome/components/ms5611/sensor.py index 5decb13436..168ca0c5c8 100644 --- a/esphome/components/ms5611/sensor.py +++ b/esphome/components/ms5611/sensor.py @@ -1,15 +1,15 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_PRESSURE, CONF_TEMPERATURE, DEVICE_CLASS_PRESSURE, DEVICE_CLASS_TEMPERATURE, + ICON_GAUGE, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, - ICON_GAUGE, UNIT_HECTOPASCAL, ) diff --git a/esphome/components/ms8607/sensor.py b/esphome/components/ms8607/sensor.py index 1113e14af2..7ed7c61750 100644 --- a/esphome/components/ms8607/sensor.py +++ b/esphome/components/ms8607/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_HUMIDITY, CONF_ID, diff --git a/esphome/components/my9231/__init__.py b/esphome/components/my9231/__init__.py index 58419450cd..e5a879a0f0 100644 --- a/esphome/components/my9231/__init__.py +++ b/esphome/components/my9231/__init__.py @@ -1,6 +1,6 @@ +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins from esphome.const import ( CONF_BIT_DEPTH, CONF_CLOCK_PIN, diff --git a/esphome/components/my9231/output.py b/esphome/components/my9231/output.py index a3c16fd49a..b4fad82c5f 100644 --- a/esphome/components/my9231/output.py +++ b/esphome/components/my9231/output.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL, CONF_ID + from . import MY9231OutputComponent DEPENDENCIES = ["my9231"] diff --git a/esphome/components/neopixelbus/_methods.py b/esphome/components/neopixelbus/_methods.py index 4059d040d0..5a00fa2804 100644 --- a/esphome/components/neopixelbus/_methods.py +++ b/esphome/components/neopixelbus/_methods.py @@ -1,6 +1,14 @@ from dataclasses import dataclass from typing import Any + import esphome.codegen as cg +from esphome.components.esp32 import get_esp32_variant +from esphome.components.esp32.const import ( + VARIANT_ESP32, + VARIANT_ESP32C3, + VARIANT_ESP32S2, + VARIANT_ESP32S3, +) import esphome.config_validation as cv from esphome.const import ( CONF_CHANNEL, @@ -10,17 +18,9 @@ from esphome.const import ( CONF_PIN, CONF_SPEED, ) -from esphome.components.esp32 import get_esp32_variant -from esphome.components.esp32.const import ( - VARIANT_ESP32, - VARIANT_ESP32C3, - VARIANT_ESP32S2, - VARIANT_ESP32S3, -) from esphome.core import CORE + from .const import ( - CONF_ASYNC, - CONF_BUS, CHIP_400KBPS, CHIP_800KBPS, CHIP_APA106, @@ -38,6 +38,8 @@ from .const import ( CHIP_WS2812, CHIP_WS2812X, CHIP_WS2813, + CONF_ASYNC, + CONF_BUS, ONE_WIRE_CHIPS, TWO_WIRE_CHIPS, ) diff --git a/esphome/components/neopixelbus/light.py b/esphome/components/neopixelbus/light.py index 9bd9215936..affeb2de8f 100644 --- a/esphome/components/neopixelbus/light.py +++ b/esphome/components/neopixelbus/light.py @@ -1,40 +1,33 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import light +from esphome.components.esp32 import get_esp32_variant +from esphome.components.esp32.const import VARIANT_ESP32C3, VARIANT_ESP32S3 +import esphome.config_validation as cv from esphome.const import ( CONF_CHANNEL, CONF_CLOCK_PIN, CONF_DATA_PIN, + CONF_INVERT, CONF_METHOD, CONF_NUM_LEDS, + CONF_OUTPUT_ID, CONF_PIN, CONF_TYPE, CONF_VARIANT, - CONF_OUTPUT_ID, - CONF_INVERT, -) -from esphome.components.esp32 import get_esp32_variant -from esphome.components.esp32.const import ( - VARIANT_ESP32C3, - VARIANT_ESP32S3, ) from esphome.core import CORE + from ._methods import ( - METHODS, - METHOD_SPI, - METHOD_ESP8266_UART, METHOD_BIT_BANG, METHOD_ESP32_I2S, METHOD_ESP32_RMT, METHOD_ESP8266_DMA, + METHOD_ESP8266_UART, + METHOD_SPI, + METHODS, ) -from .const import ( - CHIP_TYPES, - CONF_ASYNC, - CONF_BUS, - ONE_WIRE_CHIPS, -) +from .const import CHIP_TYPES, CONF_ASYNC, CONF_BUS, ONE_WIRE_CHIPS neopixelbus_ns = cg.esphome_ns.namespace("neopixelbus") NeoPixelBusLightOutputBase = neopixelbus_ns.class_( diff --git a/esphome/components/nextion/binary_sensor/__init__.py b/esphome/components/nextion/binary_sensor/__init__.py index a257587e13..7ef72c6491 100644 --- a/esphome/components/nextion/binary_sensor/__init__.py +++ b/esphome/components/nextion/binary_sensor/__init__.py @@ -1,23 +1,15 @@ from esphome import automation import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv +from esphome.const import CONF_COMPONENT_ID, CONF_ID, CONF_PAGE_ID, CONF_STATE -from esphome.const import ( - CONF_ID, - CONF_STATE, - CONF_COMPONENT_ID, - CONF_PAGE_ID, -) - -from .. import nextion_ns, CONF_NEXTION_ID, CONF_PUBLISH_STATE, CONF_SEND_TO_NEXTION - - +from .. import CONF_NEXTION_ID, CONF_PUBLISH_STATE, CONF_SEND_TO_NEXTION, nextion_ns from ..base_component import ( - setup_component_core_, - CONFIG_BINARY_SENSOR_SCHEMA, - CONF_VARIABLE_NAME, CONF_COMPONENT_NAME, + CONF_VARIABLE_NAME, + CONFIG_BINARY_SENSOR_SCHEMA, + setup_component_core_, ) CODEOWNERS = ["@senexcrenshaw"] diff --git a/esphome/components/nextion/sensor/__init__.py b/esphome/components/nextion/sensor/__init__.py index 1058c2a04b..9802762ff3 100644 --- a/esphome/components/nextion/sensor/__init__.py +++ b/esphome/components/nextion/sensor/__init__.py @@ -1,25 +1,22 @@ from esphome import automation import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv +from esphome.const import CONF_COMPONENT_ID, CONF_ID, CONF_STATE -from esphome.const import CONF_ID, CONF_COMPONENT_ID, CONF_STATE - -from .. import nextion_ns, CONF_NEXTION_ID, CONF_PUBLISH_STATE, CONF_SEND_TO_NEXTION - +from .. import CONF_NEXTION_ID, CONF_PUBLISH_STATE, CONF_SEND_TO_NEXTION, nextion_ns from ..base_component import ( - setup_component_core_, - CONFIG_SENSOR_COMPONENT_SCHEMA, - CONF_VARIABLE_NAME, CONF_COMPONENT_NAME, CONF_PRECISION, + CONF_VARIABLE_NAME, CONF_WAVE_CHANNEL_ID, + CONF_WAVE_MAX_LENGTH, CONF_WAVE_MAX_VALUE, CONF_WAVEFORM_SEND_LAST_VALUE, - CONF_WAVE_MAX_LENGTH, + CONFIG_SENSOR_COMPONENT_SCHEMA, + setup_component_core_, ) - CODEOWNERS = ["@senexcrenshaw"] NextionSensor = nextion_ns.class_("NextionSensor", sensor.Sensor, cg.PollingComponent) diff --git a/esphome/components/nextion/switch/__init__.py b/esphome/components/nextion/switch/__init__.py index de1a061478..1974ff3b9e 100644 --- a/esphome/components/nextion/switch/__init__.py +++ b/esphome/components/nextion/switch/__init__.py @@ -1,17 +1,15 @@ from esphome import automation import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import switch - +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_STATE -from .. import nextion_ns, CONF_NEXTION_ID, CONF_PUBLISH_STATE, CONF_SEND_TO_NEXTION - +from .. import CONF_NEXTION_ID, CONF_PUBLISH_STATE, CONF_SEND_TO_NEXTION, nextion_ns from ..base_component import ( - setup_component_core_, CONF_COMPONENT_NAME, CONF_VARIABLE_NAME, CONFIG_SWITCH_COMPONENT_SCHEMA, + setup_component_core_, ) CODEOWNERS = ["@senexcrenshaw"] diff --git a/esphome/components/nextion/text_sensor/__init__.py b/esphome/components/nextion/text_sensor/__init__.py index 793397b1f4..8fc0a8ceaf 100644 --- a/esphome/components/nextion/text_sensor/__init__.py +++ b/esphome/components/nextion/text_sensor/__init__.py @@ -1,15 +1,11 @@ from esphome import automation +import esphome.codegen as cg from esphome.components import text_sensor import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import CONF_ID, CONF_STATE -from .. import nextion_ns, CONF_NEXTION_ID, CONF_PUBLISH_STATE, CONF_SEND_TO_NEXTION - -from ..base_component import ( - setup_component_core_, - CONFIG_TEXT_COMPONENT_SCHEMA, -) +from .. import CONF_NEXTION_ID, CONF_PUBLISH_STATE, CONF_SEND_TO_NEXTION, nextion_ns +from ..base_component import CONFIG_TEXT_COMPONENT_SCHEMA, setup_component_core_ CODEOWNERS = ["@senexcrenshaw"] diff --git a/esphome/components/noblex/climate.py b/esphome/components/noblex/climate.py index 2025cb5d9e..7f4e8e6488 100644 --- a/esphome/components/noblex/climate.py +++ b/esphome/components/noblex/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/ntc/sensor.py b/esphome/components/ntc/sensor.py index bd5f4a1841..d47052cac6 100644 --- a/esphome/components/ntc/sensor.py +++ b/esphome/components/ntc/sensor.py @@ -1,8 +1,8 @@ from math import log -import esphome.config_validation as cv import esphome.codegen as cg from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_CALIBRATION, CONF_REFERENCE_RESISTANCE, diff --git a/esphome/components/opentherm/__init__.py b/esphome/components/opentherm/__init__.py index 42b476eb87..8cbee1eed2 100644 --- a/esphome/components/opentherm/__init__.py +++ b/esphome/components/opentherm/__init__.py @@ -1,13 +1,13 @@ +import logging from typing import Any -import logging -from esphome import automation +from esphome import automation, pins import esphome.codegen as cg -import esphome.config_validation as cv -from esphome import pins from esphome.components import sensor -from esphome.const import CONF_ID, PLATFORM_ESP32, PLATFORM_ESP8266, CONF_TRIGGER_ID -from . import const, schema, validate, generate +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_TRIGGER_ID, PLATFORM_ESP32, PLATFORM_ESP8266 + +from . import const, generate, schema, validate CODEOWNERS = ["@olegtarasov"] MULTI_CONF = True diff --git a/esphome/components/opentherm/input.py b/esphome/components/opentherm/input.py index 7897747be1..c5814f74e2 100644 --- a/esphome/components/opentherm/input.py +++ b/esphome/components/opentherm/input.py @@ -2,7 +2,8 @@ from typing import Any import esphome.codegen as cg import esphome.config_validation as cv -from . import schema, generate + +from . import generate, schema CONF_min_value = "min_value" CONF_max_value = "max_value" diff --git a/esphome/components/opentherm/number/__init__.py b/esphome/components/opentherm/number/__init__.py index bbf3e87586..00aa62483c 100644 --- a/esphome/components/opentherm/number/__init__.py +++ b/esphome/components/opentherm/number/__init__.py @@ -1,16 +1,17 @@ from typing import Any import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import number +import esphome.config_validation as cv from esphome.const import ( CONF_ID, - CONF_UNIT_OF_MEASUREMENT, - CONF_STEP, CONF_INITIAL_VALUE, CONF_RESTORE_VALUE, + CONF_STEP, + CONF_UNIT_OF_MEASUREMENT, ) -from .. import const, schema, validate, input, generate + +from .. import const, generate, input, schema, validate DEPENDENCIES = [const.OPENTHERM] COMPONENT_TYPE = const.NUMBER diff --git a/esphome/components/opentherm/output/__init__.py b/esphome/components/opentherm/output/__init__.py index 3a53c9d4f4..87307eb051 100644 --- a/esphome/components/opentherm/output/__init__.py +++ b/esphome/components/opentherm/output/__init__.py @@ -1,10 +1,11 @@ from typing import Any import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_ID -from .. import const, schema, validate, input, generate + +from .. import const, generate, input, schema, validate DEPENDENCIES = [const.OPENTHERM] COMPONENT_TYPE = const.OUTPUT diff --git a/esphome/components/opentherm/schema.py b/esphome/components/opentherm/schema.py index a58de8e2da..791ba215e0 100644 --- a/esphome/components/opentherm/schema.py +++ b/esphome/components/opentherm/schema.py @@ -2,16 +2,10 @@ # inputs of the OpenTherm component. from dataclasses import dataclass -from typing import Optional, TypeVar, Any +from typing import Any, Optional, TypeVar import esphome.config_validation as cv from esphome.const import ( - UNIT_CELSIUS, - UNIT_EMPTY, - UNIT_KILOWATT, - UNIT_MICROAMP, - UNIT_PERCENT, - UNIT_REVOLUTIONS_PER_MINUTE, DEVICE_CLASS_COLD, DEVICE_CLASS_CURRENT, DEVICE_CLASS_EMPTY, @@ -22,6 +16,12 @@ from esphome.const import ( STATE_CLASS_MEASUREMENT, STATE_CLASS_NONE, STATE_CLASS_TOTAL_INCREASING, + UNIT_CELSIUS, + UNIT_EMPTY, + UNIT_KILOWATT, + UNIT_MICROAMP, + UNIT_PERCENT, + UNIT_REVOLUTIONS_PER_MINUTE, ) diff --git a/esphome/components/opentherm/switch/__init__.py b/esphome/components/opentherm/switch/__init__.py index 94ec25e36c..ead086d24b 100644 --- a/esphome/components/opentherm/switch/__init__.py +++ b/esphome/components/opentherm/switch/__init__.py @@ -1,10 +1,11 @@ from typing import Any import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import switch +import esphome.config_validation as cv from esphome.const import CONF_ID -from .. import const, schema, validate, generate + +from .. import const, generate, schema, validate DEPENDENCIES = [const.OPENTHERM] COMPONENT_TYPE = const.SWITCH diff --git a/esphome/components/opentherm/validate.py b/esphome/components/opentherm/validate.py index 055cbfa827..2b80e59f7b 100644 --- a/esphome/components/opentherm/validate.py +++ b/esphome/components/opentherm/validate.py @@ -4,7 +4,7 @@ from voluptuous import Schema import esphome.config_validation as cv -from . import const, schema, generate +from . import const, generate, schema from .schema import TSchema diff --git a/esphome/components/output/__init__.py b/esphome/components/output/__init__.py index 726d1ac084..78bfa045e1 100644 --- a/esphome/components/output/__init__.py +++ b/esphome/components/output/__init__.py @@ -1,8 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation from esphome.automation import maybe_simple_id +import esphome.codegen as cg from esphome.components import power_supply +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_INVERTED, @@ -13,7 +13,6 @@ from esphome.const import ( ) from esphome.core import CORE - CODEOWNERS = ["@esphome/core"] IS_PLATFORM_COMPONENT = True diff --git a/esphome/components/output/button/__init__.py b/esphome/components/output/button/__init__.py index c31865ccfb..1d14fa5755 100644 --- a/esphome/components/output/button/__init__.py +++ b/esphome/components/output/button/__init__.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import button, output -from esphome.const import CONF_ID, CONF_OUTPUT, CONF_DURATION +import esphome.config_validation as cv +from esphome.const import CONF_DURATION, CONF_ID, CONF_OUTPUT + from .. import output_ns OutputButton = output_ns.class_("OutputButton", button.Button, cg.Component) diff --git a/esphome/components/output/lock/__init__.py b/esphome/components/output/lock/__init__.py index 3be2cb09aa..c9bdba0f75 100644 --- a/esphome/components/output/lock/__init__.py +++ b/esphome/components/output/lock/__init__.py @@ -1,7 +1,8 @@ import esphome.codegen as cg +from esphome.components import lock, output import esphome.config_validation as cv -from esphome.components import output, lock from esphome.const import CONF_ID, CONF_OUTPUT + from .. import output_ns OutputLock = output_ns.class_("OutputLock", lock.Lock, cg.Component) diff --git a/esphome/components/output/switch/__init__.py b/esphome/components/output/switch/__init__.py index f5325643a7..e896b183ca 100644 --- a/esphome/components/output/switch/__init__.py +++ b/esphome/components/output/switch/__init__.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output, switch +import esphome.config_validation as cv from esphome.const import CONF_OUTPUT + from .. import output_ns OutputSwitch = output_ns.class_("OutputSwitch", switch.Switch, cg.Component) diff --git a/esphome/components/partition/light.py b/esphome/components/partition/light.py index 8e45915cf3..58de1183ff 100644 --- a/esphome/components/partition/light.py +++ b/esphome/components/partition/light.py @@ -1,19 +1,19 @@ import esphome.codegen as cg -import esphome.config_validation as cv -import esphome.final_validate as fv from esphome.components import light +import esphome.config_validation as cv from esphome.const import ( CONF_ADDRESSABLE_LIGHT_ID, CONF_FROM, CONF_ID, CONF_LIGHT_ID, CONF_NUM_LEDS, + CONF_OUTPUT_ID, + CONF_REVERSED, CONF_SEGMENTS, CONF_SINGLE_LIGHT_ID, CONF_TO, - CONF_OUTPUT_ID, - CONF_REVERSED, ) +import esphome.final_validate as fv partitions_ns = cg.esphome_ns.namespace("partition") AddressableSegment = partitions_ns.class_("AddressableSegment") diff --git a/esphome/components/pca6416a/__init__.py b/esphome/components/pca6416a/__init__.py index 93be148169..da6c4623c9 100644 --- a/esphome/components/pca6416a/__init__.py +++ b/esphome/components/pca6416a/__init__.py @@ -1,13 +1,13 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_INPUT, - CONF_NUMBER, - CONF_MODE, CONF_INVERTED, + CONF_MODE, + CONF_NUMBER, CONF_OUTPUT, CONF_PULLUP, ) diff --git a/esphome/components/pca9554/__init__.py b/esphome/components/pca9554/__init__.py index da31dbd9d9..05713cccda 100644 --- a/esphome/components/pca9554/__init__.py +++ b/esphome/components/pca9554/__init__.py @@ -1,13 +1,13 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_INPUT, - CONF_NUMBER, - CONF_MODE, CONF_INVERTED, + CONF_MODE, + CONF_NUMBER, CONF_OUTPUT, ) diff --git a/esphome/components/pca9685/__init__.py b/esphome/components/pca9685/__init__.py index b22577bf9f..50f58cdfb9 100644 --- a/esphome/components/pca9685/__init__.py +++ b/esphome/components/pca9685/__init__.py @@ -1,7 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c -from esphome.const import CONF_FREQUENCY, CONF_ID, CONF_EXTERNAL_CLOCK_INPUT +import esphome.config_validation as cv +from esphome.const import CONF_EXTERNAL_CLOCK_INPUT, CONF_FREQUENCY, CONF_ID DEPENDENCIES = ["i2c"] MULTI_CONF = True diff --git a/esphome/components/pca9685/output.py b/esphome/components/pca9685/output.py index b7681f9ba0..302c2f78c0 100644 --- a/esphome/components/pca9685/output.py +++ b/esphome/components/pca9685/output.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL, CONF_ID + from . import PCA9685Output, pca9685_ns DEPENDENCIES = ["pca9685"] diff --git a/esphome/components/pcf85063/time.py b/esphome/components/pcf85063/time.py index 67ec230b5f..f3c0c3230f 100644 --- a/esphome/components/pcf85063/time.py +++ b/esphome/components/pcf85063/time.py @@ -1,10 +1,9 @@ -import esphome.config_validation as cv -import esphome.codegen as cg from esphome import automation +import esphome.codegen as cg from esphome.components import i2c, time +import esphome.config_validation as cv from esphome.const import CONF_ID - CODEOWNERS = ["@brogon"] DEPENDENCIES = ["i2c"] pcf85063_ns = cg.esphome_ns.namespace("pcf85063") diff --git a/esphome/components/pcf8563/time.py b/esphome/components/pcf8563/time.py index 2e6456a72d..e3b3b572aa 100644 --- a/esphome/components/pcf8563/time.py +++ b/esphome/components/pcf8563/time.py @@ -1,7 +1,7 @@ -import esphome.config_validation as cv -import esphome.codegen as cg from esphome import automation +import esphome.codegen as cg from esphome.components import i2c, time +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@KoenBreeman"] diff --git a/esphome/components/pcf8574/__init__.py b/esphome/components/pcf8574/__init__.py index ebf112b85b..64bef86443 100644 --- a/esphome/components/pcf8574/__init__.py +++ b/esphome/components/pcf8574/__init__.py @@ -1,13 +1,13 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_INPUT, - CONF_NUMBER, - CONF_MODE, CONF_INVERTED, + CONF_MODE, + CONF_NUMBER, CONF_OUTPUT, ) diff --git a/esphome/components/pid/climate.py b/esphome/components/pid/climate.py index 2c4ef688a5..aab7ee5c00 100644 --- a/esphome/components/pid/climate.py +++ b/esphome/components/pid/climate.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation -from esphome.components import climate, sensor, output +import esphome.codegen as cg +from esphome.components import climate, output, sensor +import esphome.config_validation as cv from esphome.const import CONF_HUMIDITY_SENSOR, CONF_ID, CONF_SENSOR pid_ns = cg.esphome_ns.namespace("pid") diff --git a/esphome/components/pid/sensor/__init__.py b/esphome/components/pid/sensor/__init__.py index d1c65dfb39..4547f4d708 100644 --- a/esphome/components/pid/sensor/__init__.py +++ b/esphome/components/pid/sensor/__init__.py @@ -1,13 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor -from esphome.const import ( - STATE_CLASS_MEASUREMENT, - UNIT_PERCENT, - ICON_GAUGE, - CONF_TYPE, -) -from ..climate import pid_ns, PIDClimate +import esphome.config_validation as cv +from esphome.const import CONF_TYPE, ICON_GAUGE, STATE_CLASS_MEASUREMENT, UNIT_PERCENT + +from ..climate import PIDClimate, pid_ns PIDClimateSensor = pid_ns.class_("PIDClimateSensor", sensor.Sensor, cg.Component) PIDClimateSensorType = pid_ns.enum("PIDClimateSensorType") diff --git a/esphome/components/pipsolar/__init__.py b/esphome/components/pipsolar/__init__.py index 875de05713..1e4ea8492b 100644 --- a/esphome/components/pipsolar/__init__.py +++ b/esphome/components/pipsolar/__init__.py @@ -1,7 +1,7 @@ import esphome.codegen as cg +from esphome.components import uart import esphome.config_validation as cv from esphome.const import CONF_ID -from esphome.components import uart DEPENDENCIES = ["uart"] CODEOWNERS = ["@andreashergert1984"] diff --git a/esphome/components/pipsolar/binary_sensor/__init__.py b/esphome/components/pipsolar/binary_sensor/__init__.py index f4b34fd594..625c232ed5 100644 --- a/esphome/components/pipsolar/binary_sensor/__init__.py +++ b/esphome/components/pipsolar/binary_sensor/__init__.py @@ -1,8 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv -from .. import PIPSOLAR_COMPONENT_SCHEMA, CONF_PIPSOLAR_ID +from .. import CONF_PIPSOLAR_ID, PIPSOLAR_COMPONENT_SCHEMA DEPENDENCIES = ["uart"] diff --git a/esphome/components/pipsolar/output/__init__.py b/esphome/components/pipsolar/output/__init__.py index b518d485e7..1eb7249119 100644 --- a/esphome/components/pipsolar/output/__init__.py +++ b/esphome/components/pipsolar/output/__init__.py @@ -1,9 +1,10 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_VALUE -from .. import PIPSOLAR_COMPONENT_SCHEMA, CONF_PIPSOLAR_ID, pipsolar_ns + +from .. import CONF_PIPSOLAR_ID, PIPSOLAR_COMPONENT_SCHEMA, pipsolar_ns DEPENDENCIES = ["pipsolar"] diff --git a/esphome/components/pipsolar/sensor/__init__.py b/esphome/components/pipsolar/sensor/__init__.py index 3a6f94d6ac..0d00ba0083 100644 --- a/esphome/components/pipsolar/sensor/__init__.py +++ b/esphome/components/pipsolar/sensor/__init__.py @@ -1,7 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_BATTERY_VOLTAGE, + CONF_BUS_VOLTAGE, DEVICE_CLASS_CURRENT, DEVICE_CLASS_POWER, DEVICE_CLASS_TEMPERATURE, @@ -14,10 +16,9 @@ from esphome.const import ( UNIT_VOLT, UNIT_VOLT_AMPS, UNIT_WATT, - CONF_BUS_VOLTAGE, - CONF_BATTERY_VOLTAGE, ) -from .. import PIPSOLAR_COMPONENT_SCHEMA, CONF_PIPSOLAR_ID + +from .. import CONF_PIPSOLAR_ID, PIPSOLAR_COMPONENT_SCHEMA DEPENDENCIES = ["uart"] diff --git a/esphome/components/pipsolar/switch/__init__.py b/esphome/components/pipsolar/switch/__init__.py index 80bcdad62e..11dbc91110 100644 --- a/esphome/components/pipsolar/switch/__init__.py +++ b/esphome/components/pipsolar/switch/__init__.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import switch +import esphome.config_validation as cv from esphome.const import ICON_POWER + from .. import CONF_PIPSOLAR_ID, PIPSOLAR_COMPONENT_SCHEMA, pipsolar_ns DEPENDENCIES = ["uart"] diff --git a/esphome/components/pipsolar/text_sensor/__init__.py b/esphome/components/pipsolar/text_sensor/__init__.py index 856352f8cb..90ce3a7e55 100644 --- a/esphome/components/pipsolar/text_sensor/__init__.py +++ b/esphome/components/pipsolar/text_sensor/__init__.py @@ -1,6 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor +import esphome.config_validation as cv + from .. import CONF_PIPSOLAR_ID, PIPSOLAR_COMPONENT_SCHEMA DEPENDENCIES = ["uart"] diff --git a/esphome/components/pm1006/sensor.py b/esphome/components/pm1006/sensor.py index 2df9edbf45..c693cfea19 100644 --- a/esphome/components/pm1006/sensor.py +++ b/esphome/components/pm1006/sensor.py @@ -1,14 +1,14 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_PM_2_5, CONF_UPDATE_INTERVAL, DEVICE_CLASS_PM25, + ICON_BLUR, STATE_CLASS_MEASUREMENT, UNIT_MICROGRAMS_PER_CUBIC_METER, - ICON_BLUR, ) from esphome.core import TimePeriodMilliseconds diff --git a/esphome/components/pmsa003i/sensor.py b/esphome/components/pmsa003i/sensor.py index ef620614a2..2a5b9eeac0 100644 --- a/esphome/components/pmsa003i/sensor.py +++ b/esphome/components/pmsa003i/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_PM_1_0, @@ -10,13 +10,13 @@ from esphome.const import ( CONF_PMC_1_0, CONF_PMC_2_5, CONF_PMC_10_0, - UNIT_MICROGRAMS_PER_CUBIC_METER, - ICON_CHEMICAL_WEAPON, - ICON_COUNTER, DEVICE_CLASS_PM1, DEVICE_CLASS_PM10, DEVICE_CLASS_PM25, + ICON_CHEMICAL_WEAPON, + ICON_COUNTER, STATE_CLASS_MEASUREMENT, + UNIT_MICROGRAMS_PER_CUBIC_METER, ) CODEOWNERS = ["@sjtrny"] diff --git a/esphome/components/pmsx003/sensor.py b/esphome/components/pmsx003/sensor.py index 08ccd6096e..1556b3c983 100644 --- a/esphome/components/pmsx003/sensor.py +++ b/esphome/components/pmsx003/sensor.py @@ -1,36 +1,35 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart - +import esphome.config_validation as cv from esphome.const import ( CONF_FORMALDEHYDE, CONF_HUMIDITY, CONF_ID, - CONF_PM_10_0, - CONF_PM_1_0, - CONF_PM_2_5, - CONF_PM_10_0_STD, - CONF_PM_1_0_STD, - CONF_PM_2_5_STD, CONF_PM_0_3UM, CONF_PM_0_5UM, + CONF_PM_1_0, + CONF_PM_1_0_STD, CONF_PM_1_0UM, + CONF_PM_2_5, + CONF_PM_2_5_STD, CONF_PM_2_5UM, CONF_PM_5_0UM, + CONF_PM_10_0, + CONF_PM_10_0_STD, CONF_PM_10_0UM, - CONF_UPDATE_INTERVAL, CONF_TEMPERATURE, CONF_TYPE, + CONF_UPDATE_INTERVAL, + DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_PM1, DEVICE_CLASS_PM10, DEVICE_CLASS_PM25, - DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, ICON_CHEMICAL_WEAPON, STATE_CLASS_MEASUREMENT, - UNIT_MICROGRAMS_PER_CUBIC_METER, UNIT_CELSIUS, UNIT_COUNT_DECILITRE, + UNIT_MICROGRAMS_PER_CUBIC_METER, UNIT_PERCENT, ) diff --git a/esphome/components/pmwcs3/sensor.py b/esphome/components/pmwcs3/sensor.py index 81be327d14..d42338ab6f 100644 --- a/esphome/components/pmwcs3/sensor.py +++ b/esphome/components/pmwcs3/sensor.py @@ -1,14 +1,14 @@ -import esphome.codegen as cg from esphome import automation -import esphome.config_validation as cv +import esphome.codegen as cg from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_ADDRESS, - CONF_TEMPERATURE, CONF_EC, - STATE_CLASS_MEASUREMENT, + CONF_ID, + CONF_TEMPERATURE, ICON_THERMOMETER, + STATE_CLASS_MEASUREMENT, ) CODEOWNERS = ["@SeByDocKy"] diff --git a/esphome/components/pn532/__init__.py b/esphome/components/pn532/__init__.py index cdcaf4267c..3f04e8e1cc 100644 --- a/esphome/components/pn532/__init__.py +++ b/esphome/components/pn532/__init__.py @@ -1,12 +1,12 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import nfc +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_ON_FINISHED_WRITE, - CONF_ON_TAG_REMOVED, CONF_ON_TAG, + CONF_ON_TAG_REMOVED, CONF_TRIGGER_ID, ) diff --git a/esphome/components/pn532_i2c/__init__.py b/esphome/components/pn532_i2c/__init__.py index f7b8743967..7304f1b8ad 100644 --- a/esphome/components/pn532_i2c/__init__.py +++ b/esphome/components/pn532_i2c/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, pn532 +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["pn532"] diff --git a/esphome/components/pn532_spi/__init__.py b/esphome/components/pn532_spi/__init__.py index 8a8ab1b175..67ebc88872 100644 --- a/esphome/components/pn532_spi/__init__.py +++ b/esphome/components/pn532_spi/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import pn532, spi import esphome.config_validation as cv -from esphome.components import spi, pn532 from esphome.const import CONF_ID AUTO_LOAD = ["pn532"] diff --git a/esphome/components/pn7150/__init__.py b/esphome/components/pn7150/__init__.py index e3589ea449..131b56e30e 100644 --- a/esphome/components/pn7150/__init__.py +++ b/esphome/components/pn7150/__init__.py @@ -1,15 +1,15 @@ from esphome import automation, pins from esphome.automation import maybe_simple_id import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import nfc +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_IRQ_PIN, CONF_MESSAGE, CONF_ON_FINISHED_WRITE, - CONF_ON_TAG_REMOVED, CONF_ON_TAG, + CONF_ON_TAG_REMOVED, CONF_TRIGGER_ID, ) diff --git a/esphome/components/pn7150_i2c/__init__.py b/esphome/components/pn7150_i2c/__init__.py index 5f48a0f3cb..00a19ba03c 100644 --- a/esphome/components/pn7150_i2c/__init__.py +++ b/esphome/components/pn7150_i2c/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, pn7150 +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["pn7150"] diff --git a/esphome/components/pn7160/__init__.py b/esphome/components/pn7160/__init__.py index b102b38f98..899ecd595e 100644 --- a/esphome/components/pn7160/__init__.py +++ b/esphome/components/pn7160/__init__.py @@ -1,15 +1,15 @@ from esphome import automation, pins from esphome.automation import maybe_simple_id import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import nfc +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_IRQ_PIN, CONF_MESSAGE, CONF_ON_FINISHED_WRITE, - CONF_ON_TAG_REMOVED, CONF_ON_TAG, + CONF_ON_TAG_REMOVED, CONF_TRIGGER_ID, ) diff --git a/esphome/components/pn7160_i2c/__init__.py b/esphome/components/pn7160_i2c/__init__.py index 87c4719ca8..f8f8ebef98 100644 --- a/esphome/components/pn7160_i2c/__init__.py +++ b/esphome/components/pn7160_i2c/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, pn7160 +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["pn7160"] diff --git a/esphome/components/pn7160_spi/__init__.py b/esphome/components/pn7160_spi/__init__.py index ae1235655a..5498d0ac1b 100644 --- a/esphome/components/pn7160_spi/__init__.py +++ b/esphome/components/pn7160_spi/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import pn7160, spi import esphome.config_validation as cv -from esphome.components import spi, pn7160 from esphome.const import CONF_ID AUTO_LOAD = ["pn7160"] diff --git a/esphome/components/power_supply/__init__.py b/esphome/components/power_supply/__init__.py index 01b541e4b5..851c136493 100644 --- a/esphome/components/power_supply/__init__.py +++ b/esphome/components/power_supply/__init__.py @@ -1,6 +1,6 @@ +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins from esphome.const import ( CONF_ENABLE_ON_BOOT, CONF_ENABLE_TIME, diff --git a/esphome/components/prometheus/__init__.py b/esphome/components/prometheus/__init__.py index 5b63710c6a..b899fe7642 100644 --- a/esphome/components/prometheus/__init__.py +++ b/esphome/components/prometheus/__init__.py @@ -1,13 +1,8 @@ -import esphome.config_validation as cv import esphome.codegen as cg -from esphome.const import ( - CONF_ID, - CONF_NAME, - CONF_INCLUDE_INTERNAL, - CONF_RELABEL, -) -from esphome.components.web_server_base import CONF_WEB_SERVER_BASE_ID from esphome.components import web_server_base +from esphome.components.web_server_base import CONF_WEB_SERVER_BASE_ID +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_INCLUDE_INTERNAL, CONF_NAME, CONF_RELABEL from esphome.cpp_types import EntityBase AUTO_LOAD = ["web_server_base"] diff --git a/esphome/components/psram/__init__.py b/esphome/components/psram/__init__.py index 796957c315..437ee1a21a 100644 --- a/esphome/components/psram/__init__.py +++ b/esphome/components/psram/__init__.py @@ -1,12 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components.esp32 import add_idf_sdkconfig_option, get_esp32_variant +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_MODE, CONF_SPEED from esphome.core import CORE -from esphome.const import ( - CONF_ID, - CONF_MODE, - CONF_SPEED, -) CODEOWNERS = ["@esphome/core"] diff --git a/esphome/components/pulse_counter/sensor.py b/esphome/components/pulse_counter/sensor.py index 27364a34b3..b330758000 100644 --- a/esphome/components/pulse_counter/sensor.py +++ b/esphome/components/pulse_counter/sensor.py @@ -1,22 +1,22 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation, pins +import esphome.codegen as cg from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_COUNT_MODE, CONF_FALLING_EDGE, CONF_ID, CONF_INTERNAL_FILTER, + CONF_NUMBER, CONF_PIN, CONF_RISING_EDGE, - CONF_NUMBER, CONF_TOTAL, CONF_VALUE, ICON_PULSE, STATE_CLASS_MEASUREMENT, STATE_CLASS_TOTAL_INCREASING, - UNIT_PULSES_PER_MINUTE, UNIT_PULSES, + UNIT_PULSES_PER_MINUTE, ) from esphome.core import CORE diff --git a/esphome/components/pulse_meter/sensor.py b/esphome/components/pulse_meter/sensor.py index 59ffa58c21..ca026eefa4 100644 --- a/esphome/components/pulse_meter/sensor.py +++ b/esphome/components/pulse_meter/sensor.py @@ -1,13 +1,13 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation, pins +import esphome.codegen as cg from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_INTERNAL_FILTER, CONF_INTERNAL_FILTER_MODE, - CONF_PIN, CONF_NUMBER, + CONF_PIN, CONF_TIMEOUT, CONF_TOTAL, CONF_VALUE, diff --git a/esphome/components/pulse_width/sensor.py b/esphome/components/pulse_width/sensor.py index 47d70166d3..120dc33b7b 100644 --- a/esphome/components/pulse_width/sensor.py +++ b/esphome/components/pulse_width/sensor.py @@ -1,13 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import sensor -from esphome.const import ( - CONF_PIN, - STATE_CLASS_MEASUREMENT, - UNIT_SECOND, - ICON_TIMER, -) +import esphome.config_validation as cv +from esphome.const import CONF_PIN, ICON_TIMER, STATE_CLASS_MEASUREMENT, UNIT_SECOND pulse_width_ns = cg.esphome_ns.namespace("pulse_width") diff --git a/esphome/components/pvvx_mithermometer/display/__init__.py b/esphome/components/pvvx_mithermometer/display/__init__.py index 70c568c1e3..0cf27b9f1c 100644 --- a/esphome/components/pvvx_mithermometer/display/__init__.py +++ b/esphome/components/pvvx_mithermometer/display/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import ble_client, display, time +import esphome.config_validation as cv from esphome.const import ( CONF_AUTO_CLEAR_ENABLED, CONF_DISCONNECT_DELAY, diff --git a/esphome/components/pvvx_mithermometer/sensor.py b/esphome/components/pvvx_mithermometer/sensor.py index aa4fc89727..da57c65341 100644 --- a/esphome/components/pvvx_mithermometer/sensor.py +++ b/esphome/components/pvvx_mithermometer/sensor.py @@ -1,14 +1,14 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, CONF_BATTERY_VOLTAGE, - CONF_MAC_ADDRESS, CONF_HUMIDITY, + CONF_ID, + CONF_MAC_ADDRESS, CONF_SIGNAL_STRENGTH, CONF_TEMPERATURE, - CONF_ID, DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_SIGNAL_STRENGTH, diff --git a/esphome/components/pylontech/__init__.py b/esphome/components/pylontech/__init__.py index 197f7e7904..82b98654a2 100644 --- a/esphome/components/pylontech/__init__.py +++ b/esphome/components/pylontech/__init__.py @@ -1,4 +1,5 @@ import logging + import esphome.codegen as cg from esphome.components import uart import esphome.config_validation as cv diff --git a/esphome/components/pylontech/sensor/__init__.py b/esphome/components/pylontech/sensor/__init__.py index a1477c627f..716cc1001a 100644 --- a/esphome/components/pylontech/sensor/__init__.py +++ b/esphome/components/pylontech/sensor/__init__.py @@ -1,27 +1,22 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_VOLTAGE, CONF_CURRENT, + CONF_ID, CONF_TEMPERATURE, - UNIT_VOLT, - UNIT_AMPERE, - DEVICE_CLASS_VOLTAGE, + CONF_VOLTAGE, + DEVICE_CLASS_BATTERY, DEVICE_CLASS_CURRENT, DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_BATTERY, + DEVICE_CLASS_VOLTAGE, + UNIT_AMPERE, UNIT_CELSIUS, UNIT_PERCENT, - CONF_ID, + UNIT_VOLT, ) -from .. import ( - CONF_PYLONTECH_ID, - PYLONTECH_COMPONENT_SCHEMA, - CONF_BATTERY, - pylontech_ns, -) +from .. import CONF_BATTERY, CONF_PYLONTECH_ID, PYLONTECH_COMPONENT_SCHEMA, pylontech_ns PylontechSensor = pylontech_ns.class_("PylontechSensor", cg.Component) diff --git a/esphome/components/pylontech/text_sensor/__init__.py b/esphome/components/pylontech/text_sensor/__init__.py index d6ccc678f8..15741ea9d1 100644 --- a/esphome/components/pylontech/text_sensor/__init__.py +++ b/esphome/components/pylontech/text_sensor/__init__.py @@ -1,14 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor +import esphome.config_validation as cv from esphome.const import CONF_ID -from .. import ( - CONF_PYLONTECH_ID, - PYLONTECH_COMPONENT_SCHEMA, - CONF_BATTERY, - pylontech_ns, -) +from .. import CONF_BATTERY, CONF_PYLONTECH_ID, PYLONTECH_COMPONENT_SCHEMA, pylontech_ns PylontechTextSensor = pylontech_ns.class_("PylontechTextSensor", cg.Component) diff --git a/esphome/components/pzem004t/sensor.py b/esphome/components/pzem004t/sensor.py index 70dec82c3f..51b1ab2d80 100644 --- a/esphome/components/pzem004t/sensor.py +++ b/esphome/components/pzem004t/sensor.py @@ -1,20 +1,20 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( CONF_CURRENT, + CONF_ENERGY, CONF_ID, CONF_POWER, CONF_VOLTAGE, - CONF_ENERGY, DEVICE_CLASS_CURRENT, DEVICE_CLASS_ENERGY, DEVICE_CLASS_POWER, DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, STATE_CLASS_TOTAL_INCREASING, - UNIT_VOLT, UNIT_AMPERE, + UNIT_VOLT, UNIT_WATT, UNIT_WATT_HOURS, ) diff --git a/esphome/components/pzemac/sensor.py b/esphome/components/pzemac/sensor.py index ab7dd3e202..3af73b8695 100644 --- a/esphome/components/pzemac/sensor.py +++ b/esphome/components/pzemac/sensor.py @@ -1,27 +1,27 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation from esphome.automation import maybe_simple_id -from esphome.components import sensor, modbus +import esphome.codegen as cg +from esphome.components import modbus, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_CURRENT, CONF_ENERGY, + CONF_FREQUENCY, CONF_ID, CONF_POWER, - CONF_VOLTAGE, - CONF_FREQUENCY, CONF_POWER_FACTOR, + CONF_VOLTAGE, + DEVICE_CLASS_CURRENT, + DEVICE_CLASS_ENERGY, + DEVICE_CLASS_POWER, DEVICE_CLASS_POWER_FACTOR, DEVICE_CLASS_VOLTAGE, - DEVICE_CLASS_CURRENT, - DEVICE_CLASS_POWER, - DEVICE_CLASS_ENERGY, ICON_CURRENT_AC, STATE_CLASS_MEASUREMENT, STATE_CLASS_TOTAL_INCREASING, + UNIT_AMPERE, UNIT_HERTZ, UNIT_VOLT, - UNIT_AMPERE, UNIT_WATT, UNIT_WATT_HOURS, ) diff --git a/esphome/components/pzemdc/sensor.py b/esphome/components/pzemdc/sensor.py index 097b1c1cfd..383a9dbb2c 100644 --- a/esphome/components/pzemdc/sensor.py +++ b/esphome/components/pzemdc/sensor.py @@ -1,13 +1,13 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation from esphome.automation import maybe_simple_id -from esphome.components import sensor, modbus +import esphome.codegen as cg +from esphome.components import modbus, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_CURRENT, + CONF_ENERGY, CONF_ID, CONF_POWER, - CONF_ENERGY, CONF_VOLTAGE, DEVICE_CLASS_CURRENT, DEVICE_CLASS_ENERGY, @@ -15,10 +15,10 @@ from esphome.const import ( DEVICE_CLASS_VOLTAGE, STATE_CLASS_MEASUREMENT, STATE_CLASS_TOTAL_INCREASING, - UNIT_VOLT, UNIT_AMPERE, - UNIT_WATT, UNIT_KILOWATT_HOURS, + UNIT_VOLT, + UNIT_WATT, ) AUTO_LOAD = ["modbus"] diff --git a/esphome/components/qmc5883l/sensor.py b/esphome/components/qmc5883l/sensor.py index 341c0c3f8a..ade286cb9e 100644 --- a/esphome/components/qmc5883l/sensor.py +++ b/esphome/components/qmc5883l/sensor.py @@ -1,24 +1,24 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ADDRESS, CONF_FIELD_STRENGTH_X, CONF_FIELD_STRENGTH_Y, CONF_FIELD_STRENGTH_Z, CONF_HEADING, - CONF_TEMPERATURE, CONF_ID, CONF_OVERSAMPLING, CONF_RANGE, + CONF_TEMPERATURE, + CONF_UPDATE_INTERVAL, DEVICE_CLASS_TEMPERATURE, ICON_MAGNET, + ICON_SCREEN_ROTATION, STATE_CLASS_MEASUREMENT, - UNIT_MICROTESLA, UNIT_CELSIUS, UNIT_DEGREES, - ICON_SCREEN_ROTATION, - CONF_UPDATE_INTERVAL, + UNIT_MICROTESLA, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/qmp6988/sensor.py b/esphome/components/qmp6988/sensor.py index fdcfd4e66b..05eb7efa27 100644 --- a/esphome/components/qmp6988/sensor.py +++ b/esphome/components/qmp6988/sensor.py @@ -1,8 +1,10 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, + CONF_IIR_FILTER, + CONF_OVERSAMPLING, CONF_PRESSURE, CONF_TEMPERATURE, DEVICE_CLASS_PRESSURE, @@ -10,8 +12,6 @@ from esphome.const import ( STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_HECTOPASCAL, - CONF_IIR_FILTER, - CONF_OVERSAMPLING, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/qr_code/__init__.py b/esphome/components/qr_code/__init__.py index 855db86335..1c5e0471b0 100644 --- a/esphome/components/qr_code/__init__.py +++ b/esphome/components/qr_code/__init__.py @@ -1,5 +1,5 @@ -import esphome.config_validation as cv import esphome.codegen as cg +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_VALUE CONF_SCALE = "scale" diff --git a/esphome/components/qwiic_pir/binary_sensor.py b/esphome/components/qwiic_pir/binary_sensor.py index 360f8b506a..0a549ccb32 100644 --- a/esphome/components/qwiic_pir/binary_sensor.py +++ b/esphome/components/qwiic_pir/binary_sensor.py @@ -1,11 +1,8 @@ from esphome import core import esphome.codegen as cg +from esphome.components import binary_sensor, i2c import esphome.config_validation as cv -from esphome.components import i2c, binary_sensor -from esphome.const import ( - CONF_DEBOUNCE, - DEVICE_CLASS_MOTION, -) +from esphome.const import CONF_DEBOUNCE, DEVICE_CLASS_MOTION DEPENDENCIES = ["i2c"] CODEOWNERS = ["@kahrendt"] diff --git a/esphome/components/radon_eye_ble/__init__.py b/esphome/components/radon_eye_ble/__init__.py index ffe434d19b..01910c81a8 100644 --- a/esphome/components/radon_eye_ble/__init__.py +++ b/esphome/components/radon_eye_ble/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import esp32_ble_tracker +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/radon_eye_rd200/sensor.py b/esphome/components/radon_eye_rd200/sensor.py index a9667869b8..da04328218 100644 --- a/esphome/components/radon_eye_rd200/sensor.py +++ b/esphome/components/radon_eye_rd200/sensor.py @@ -1,14 +1,13 @@ import esphome.codegen as cg +from esphome.components import ble_client, sensor import esphome.config_validation as cv -from esphome.components import sensor, ble_client - from esphome.const import ( - STATE_CLASS_MEASUREMENT, - UNIT_BECQUEREL_PER_CUBIC_METER, CONF_ID, CONF_RADON, CONF_RADON_LONG_TERM, ICON_RADIOACTIVE, + STATE_CLASS_MEASUREMENT, + UNIT_BECQUEREL_PER_CUBIC_METER, ) DEPENDENCIES = ["ble_client"] diff --git a/esphome/components/rc522/__init__.py b/esphome/components/rc522/__init__.py index 1a1e641623..ce0d408c04 100644 --- a/esphome/components/rc522/__init__.py +++ b/esphome/components/rc522/__init__.py @@ -1,12 +1,12 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation, pins +import esphome.codegen as cg from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import ( CONF_ON_TAG, CONF_ON_TAG_REMOVED, - CONF_TRIGGER_ID, CONF_RESET_PIN, + CONF_TRIGGER_ID, ) CODEOWNERS = ["@glmnet"] diff --git a/esphome/components/rc522_i2c/__init__.py b/esphome/components/rc522_i2c/__init__.py index e42817352c..7c42a12429 100644 --- a/esphome/components/rc522_i2c/__init__.py +++ b/esphome/components/rc522_i2c/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, rc522 +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@glmnet"] diff --git a/esphome/components/rc522_spi/__init__.py b/esphome/components/rc522_spi/__init__.py index 77b0a99662..9ce94d7f31 100644 --- a/esphome/components/rc522_spi/__init__.py +++ b/esphome/components/rc522_spi/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import rc522, spi import esphome.config_validation as cv -from esphome.components import spi, rc522 from esphome.const import CONF_ID CODEOWNERS = ["@glmnet"] diff --git a/esphome/components/rdm6300/__init__.py b/esphome/components/rdm6300/__init__.py index f57eaaad6a..cbc54ad02b 100644 --- a/esphome/components/rdm6300/__init__.py +++ b/esphome/components/rdm6300/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import uart +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_ON_TAG, CONF_TRIGGER_ID DEPENDENCIES = ["uart"] diff --git a/esphome/components/rdm6300/binary_sensor.py b/esphome/components/rdm6300/binary_sensor.py index cd808b92cc..7eb20b1302 100644 --- a/esphome/components/rdm6300/binary_sensor.py +++ b/esphome/components/rdm6300/binary_sensor.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor, rdm6300 +import esphome.config_validation as cv from esphome.const import CONF_UID + from . import rdm6300_ns DEPENDENCIES = ["rdm6300"] diff --git a/esphome/components/resistance/sensor.py b/esphome/components/resistance/sensor.py index 3622799a07..1cb3c6020c 100644 --- a/esphome/components/resistance/sensor.py +++ b/esphome/components/resistance/sensor.py @@ -1,12 +1,12 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_REFERENCE_VOLTAGE, CONF_SENSOR, + ICON_FLASH, STATE_CLASS_MEASUREMENT, UNIT_OHM, - ICON_FLASH, ) resistance_ns = cg.esphome_ns.namespace("resistance") diff --git a/esphome/components/restart/button/__init__.py b/esphome/components/restart/button/__init__.py index 6aff8cb351..76757f7504 100644 --- a/esphome/components/restart/button/__init__.py +++ b/esphome/components/restart/button/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import button +import esphome.config_validation as cv from esphome.const import ( CONF_ID, DEVICE_CLASS_RESTART, diff --git a/esphome/components/restart/switch/__init__.py b/esphome/components/restart/switch/__init__.py index 89805b4246..e9283c9e41 100644 --- a/esphome/components/restart/switch/__init__.py +++ b/esphome/components/restart/switch/__init__.py @@ -1,10 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import switch -from esphome.const import ( - ENTITY_CATEGORY_CONFIG, - ICON_RESTART, -) +import esphome.config_validation as cv +from esphome.const import ENTITY_CATEGORY_CONFIG, ICON_RESTART restart_ns = cg.esphome_ns.namespace("restart") RestartSwitch = restart_ns.class_("RestartSwitch", switch.Switch, cg.Component) diff --git a/esphome/components/rf_bridge/__init__.py b/esphome/components/rf_bridge/__init__.py index 228e7d882b..5ccca823de 100644 --- a/esphome/components/rf_bridge/__init__.py +++ b/esphome/components/rf_bridge/__init__.py @@ -1,9 +1,10 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import uart +import esphome.config_validation as cv from esphome.const import ( CONF_CODE, + CONF_DURATION, CONF_HIGH, CONF_ID, CONF_LENGTH, @@ -12,7 +13,6 @@ from esphome.const import ( CONF_RAW, CONF_SYNC, CONF_TRIGGER_ID, - CONF_DURATION, ) DEPENDENCIES = ["uart"] diff --git a/esphome/components/rgb/light.py b/esphome/components/rgb/light.py index 3d07855b8e..b6daaaaa3c 100644 --- a/esphome/components/rgb/light.py +++ b/esphome/components/rgb/light.py @@ -1,7 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import light, output -from esphome.const import CONF_BLUE, CONF_GREEN, CONF_RED, CONF_OUTPUT_ID +import esphome.config_validation as cv +from esphome.const import CONF_BLUE, CONF_GREEN, CONF_OUTPUT_ID, CONF_RED rgb_ns = cg.esphome_ns.namespace("rgb") RGBLightOutput = rgb_ns.class_("RGBLightOutput", light.LightOutput) diff --git a/esphome/components/rgbct/light.py b/esphome/components/rgbct/light.py index 0565057316..dcd14310e3 100644 --- a/esphome/components/rgbct/light.py +++ b/esphome/components/rgbct/light.py @@ -1,14 +1,14 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import light, output +import esphome.config_validation as cv from esphome.const import ( CONF_BLUE, + CONF_COLD_WHITE_COLOR_TEMPERATURE, CONF_COLOR_INTERLOCK, CONF_COLOR_TEMPERATURE, CONF_GREEN, - CONF_RED, CONF_OUTPUT_ID, - CONF_COLD_WHITE_COLOR_TEMPERATURE, + CONF_RED, CONF_WARM_WHITE_COLOR_TEMPERATURE, ) diff --git a/esphome/components/rgbw/light.py b/esphome/components/rgbw/light.py index f747580f61..84425c23c2 100644 --- a/esphome/components/rgbw/light.py +++ b/esphome/components/rgbw/light.py @@ -1,12 +1,12 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import light, output +import esphome.config_validation as cv from esphome.const import ( CONF_BLUE, CONF_COLOR_INTERLOCK, CONF_GREEN, - CONF_RED, CONF_OUTPUT_ID, + CONF_RED, CONF_WHITE, ) diff --git a/esphome/components/rgbww/light.py b/esphome/components/rgbww/light.py index 35f77b154b..882ab0cdbc 100644 --- a/esphome/components/rgbww/light.py +++ b/esphome/components/rgbww/light.py @@ -1,16 +1,16 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import light, output +import esphome.config_validation as cv from esphome.const import ( CONF_BLUE, + CONF_COLD_WHITE, + CONF_COLD_WHITE_COLOR_TEMPERATURE, CONF_COLOR_INTERLOCK, CONF_CONSTANT_BRIGHTNESS, CONF_GREEN, - CONF_RED, CONF_OUTPUT_ID, - CONF_COLD_WHITE, + CONF_RED, CONF_WARM_WHITE, - CONF_COLD_WHITE_COLOR_TEMPERATURE, CONF_WARM_WHITE_COLOR_TEMPERATURE, ) diff --git a/esphome/components/rotary_encoder/sensor.py b/esphome/components/rotary_encoder/sensor.py index ae6b0ae3bf..645b4a81c5 100644 --- a/esphome/components/rotary_encoder/sensor.py +++ b/esphome/components/rotary_encoder/sensor.py @@ -1,19 +1,19 @@ +from esphome import automation, pins import esphome.codegen as cg -import esphome.config_validation as cv -from esphome import pins, automation from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, - CONF_RESOLUTION, - CONF_MIN_VALUE, CONF_MAX_VALUE, - UNIT_STEPS, - ICON_ROTATE_RIGHT, - CONF_VALUE, + CONF_MIN_VALUE, CONF_PIN_A, CONF_PIN_B, - CONF_TRIGGER_ID, + CONF_RESOLUTION, CONF_RESTORE_MODE, + CONF_TRIGGER_ID, + CONF_VALUE, + ICON_ROTATE_RIGHT, + UNIT_STEPS, ) rotary_encoder_ns = cg.esphome_ns.namespace("rotary_encoder") diff --git a/esphome/components/rp2040_pio/__init__.py b/esphome/components/rp2040_pio/__init__.py index af884d5ac2..4bd46731df 100644 --- a/esphome/components/rp2040_pio/__init__.py +++ b/esphome/components/rp2040_pio/__init__.py @@ -2,7 +2,6 @@ import platform import esphome.codegen as cg - DEPENDENCIES = ["rp2040"] diff --git a/esphome/components/rp2040_pio_led_strip/light.py b/esphome/components/rp2040_pio_led_strip/light.py index 8dd2549ad4..4b6a80e78b 100644 --- a/esphome/components/rp2040_pio_led_strip/light.py +++ b/esphome/components/rp2040_pio_led_strip/light.py @@ -1,7 +1,9 @@ from dataclasses import dataclass from esphome import pins +import esphome.codegen as cg from esphome.components import light, rp2040 +import esphome.config_validation as cv from esphome.const import ( CONF_CHIPSET, CONF_ID, @@ -11,10 +13,6 @@ from esphome.const import ( CONF_PIN, CONF_RGB_ORDER, ) - -import esphome.codegen as cg -import esphome.config_validation as cv - from esphome.util import _LOGGER diff --git a/esphome/components/rp2040_pwm/output.py b/esphome/components/rp2040_pwm/output.py index 8f2972d4a0..ac1892fa29 100644 --- a/esphome/components/rp2040_pwm/output.py +++ b/esphome/components/rp2040_pwm/output.py @@ -1,12 +1,8 @@ -from esphome import pins, automation +from esphome import automation, pins +import esphome.codegen as cg from esphome.components import output import esphome.config_validation as cv -import esphome.codegen as cg -from esphome.const import ( - CONF_FREQUENCY, - CONF_ID, - CONF_PIN, -) +from esphome.const import CONF_FREQUENCY, CONF_ID, CONF_PIN CODEOWNERS = ["@jesserockz"] DEPENDENCIES = ["rp2040"] diff --git a/esphome/components/rtttl/__init__.py b/esphome/components/rtttl/__init__.py index 10f1313408..0abd51a6f1 100644 --- a/esphome/components/rtttl/__init__.py +++ b/esphome/components/rtttl/__init__.py @@ -1,19 +1,19 @@ import logging -import esphome.codegen as cg -import esphome.config_validation as cv -import esphome.final_validate as fv + from esphome import automation +import esphome.codegen as cg from esphome.components.output import FloatOutput from esphome.components.speaker import Speaker - +import esphome.config_validation as cv from esphome.const import ( + CONF_GAIN, CONF_ID, CONF_OUTPUT, CONF_PLATFORM, - CONF_TRIGGER_ID, CONF_SPEAKER, - CONF_GAIN, + CONF_TRIGGER_ID, ) +import esphome.final_validate as fv _LOGGER = logging.getLogger(__name__) diff --git a/esphome/components/ruuvi_ble/__init__.py b/esphome/components/ruuvi_ble/__init__.py index 1e3fb4b003..13d49d3cfe 100644 --- a/esphome/components/ruuvi_ble/__init__.py +++ b/esphome/components/ruuvi_ble/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import esp32_ble_tracker +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/ruuvitag/sensor.py b/esphome/components/ruuvitag/sensor.py index a46daf88ac..af262b2950 100644 --- a/esphome/components/ruuvitag/sensor.py +++ b/esphome/components/ruuvitag/sensor.py @@ -1,38 +1,38 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( - CONF_HUMIDITY, - CONF_MAC_ADDRESS, - CONF_TEMPERATURE, - CONF_PRESSURE, CONF_ACCELERATION, CONF_ACCELERATION_X, CONF_ACCELERATION_Y, CONF_ACCELERATION_Z, CONF_BATTERY_VOLTAGE, - CONF_TX_POWER, + CONF_HUMIDITY, + CONF_ID, + CONF_MAC_ADDRESS, CONF_MEASUREMENT_SEQUENCE_NUMBER, CONF_MOVEMENT_COUNTER, + CONF_PRESSURE, + CONF_TEMPERATURE, + CONF_TX_POWER, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_PRESSURE, DEVICE_CLASS_SIGNAL_STRENGTH, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_VOLTAGE, ENTITY_CATEGORY_DIAGNOSTIC, - STATE_CLASS_MEASUREMENT, - UNIT_CELSIUS, - UNIT_PERCENT, - UNIT_VOLT, - UNIT_HECTOPASCAL, - UNIT_G, - UNIT_DECIBEL_MILLIWATT, - ICON_GAUGE, ICON_ACCELERATION, ICON_ACCELERATION_X, ICON_ACCELERATION_Y, ICON_ACCELERATION_Z, - CONF_ID, + ICON_GAUGE, + STATE_CLASS_MEASUREMENT, + UNIT_CELSIUS, + UNIT_DECIBEL_MILLIWATT, + UNIT_G, + UNIT_HECTOPASCAL, + UNIT_PERCENT, + UNIT_VOLT, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/safe_mode/__init__.py b/esphome/components/safe_mode/__init__.py index 185c0e70b1..991747b089 100644 --- a/esphome/components/safe_mode/__init__.py +++ b/esphome/components/safe_mode/__init__.py @@ -1,4 +1,4 @@ -from esphome.cpp_generator import RawExpression +from esphome import automation import esphome.codegen as cg import esphome.config_validation as cv from esphome.const import ( @@ -11,8 +11,7 @@ from esphome.const import ( KEY_PAST_SAFE_MODE, ) from esphome.core import CORE, coroutine_with_priority -from esphome import automation - +from esphome.cpp_generator import RawExpression CODEOWNERS = ["@paulmonigatti", "@jsuanet", "@kbx81"] diff --git a/esphome/components/safe_mode/button/__init__.py b/esphome/components/safe_mode/button/__init__.py index 5662db8f7e..0731ca50f5 100644 --- a/esphome/components/safe_mode/button/__init__.py +++ b/esphome/components/safe_mode/button/__init__.py @@ -1,13 +1,14 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import button +import esphome.config_validation as cv from esphome.const import ( CONF_SAFE_MODE, DEVICE_CLASS_RESTART, ENTITY_CATEGORY_CONFIG, ICON_RESTART_ALERT, ) -from .. import safe_mode_ns, SafeModeComponent + +from .. import SafeModeComponent, safe_mode_ns DEPENDENCIES = ["safe_mode"] diff --git a/esphome/components/safe_mode/switch/__init__.py b/esphome/components/safe_mode/switch/__init__.py index 7271358149..d656eee84a 100644 --- a/esphome/components/safe_mode/switch/__init__.py +++ b/esphome/components/safe_mode/switch/__init__.py @@ -1,12 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import switch -from esphome.const import ( - CONF_SAFE_MODE, - ENTITY_CATEGORY_CONFIG, - ICON_RESTART_ALERT, -) -from .. import safe_mode_ns, SafeModeComponent +import esphome.config_validation as cv +from esphome.const import CONF_SAFE_MODE, ENTITY_CATEGORY_CONFIG, ICON_RESTART_ALERT + +from .. import SafeModeComponent, safe_mode_ns DEPENDENCIES = ["safe_mode"] diff --git a/esphome/components/scd30/sensor.py b/esphome/components/scd30/sensor.py index cee8cc7b71..83fb9738ec 100644 --- a/esphome/components/scd30/sensor.py +++ b/esphome/components/scd30/sensor.py @@ -1,23 +1,22 @@ from esphome import automation, core import esphome.codegen as cg +from esphome.components import i2c, sensirion_common, sensor import esphome.config_validation as cv -from esphome.components import i2c, sensor -from esphome.components import sensirion_common from esphome.const import ( - CONF_ID, - CONF_HUMIDITY, - CONF_TEMPERATURE, CONF_CO2, + CONF_HUMIDITY, + CONF_ID, + CONF_TEMPERATURE, CONF_TEMPERATURE_OFFSET, CONF_UPDATE_INTERVAL, CONF_VALUE, DEVICE_CLASS_CARBON_DIOXIDE, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, - STATE_CLASS_MEASUREMENT, - UNIT_PARTS_PER_MILLION, ICON_MOLECULE_CO2, + STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, + UNIT_PARTS_PER_MILLION, UNIT_PERCENT, ) diff --git a/esphome/components/scd4x/sensor.py b/esphome/components/scd4x/sensor.py index 13027b6f88..f050c3ec34 100644 --- a/esphome/components/scd4x/sensor.py +++ b/esphome/components/scd4x/sensor.py @@ -1,26 +1,24 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import i2c, sensor -from esphome.components import sensirion_common from esphome import automation from esphome.automation import maybe_simple_id - +import esphome.codegen as cg +from esphome.components import i2c, sensirion_common, sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_CO2, CONF_HUMIDITY, + CONF_ID, CONF_TEMPERATURE, CONF_TEMPERATURE_OFFSET, CONF_VALUE, DEVICE_CLASS_CARBON_DIOXIDE, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, - STATE_CLASS_MEASUREMENT, - UNIT_PARTS_PER_MILLION, ICON_MOLECULE_CO2, ICON_THERMOMETER, ICON_WATER_PERCENT, + STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, + UNIT_PARTS_PER_MILLION, UNIT_PERCENT, ) diff --git a/esphome/components/script/__init__.py b/esphome/components/script/__init__.py index 16b1d4c54e..ee1f6a4ad0 100644 --- a/esphome/components/script/__init__.py +++ b/esphome/components/script/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation from esphome.automation import maybe_simple_id +import esphome.codegen as cg +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_MODE, CONF_PARAMETERS, CONF_RESTART from esphome.core import CORE, EsphomeError diff --git a/esphome/components/sdl/display.py b/esphome/components/sdl/display.py index 18dc570f88..66709cc834 100644 --- a/esphome/components/sdl/display.py +++ b/esphome/components/sdl/display.py @@ -1,14 +1,14 @@ import subprocess import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import display +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_DIMENSIONS, - CONF_WIDTH, CONF_HEIGHT, + CONF_ID, CONF_LAMBDA, + CONF_WIDTH, PLATFORM_HOST, ) diff --git a/esphome/components/sdl/touchscreen/__init__.py b/esphome/components/sdl/touchscreen/__init__.py index d6c0ed1c03..9f84f91c72 100644 --- a/esphome/components/sdl/touchscreen/__init__.py +++ b/esphome/components/sdl/touchscreen/__init__.py @@ -1,9 +1,9 @@ import esphome.codegen as cg +from esphome.components import touchscreen import esphome.config_validation as cv from esphome.const import CONF_ID -from esphome.components import touchscreen -from ..display import Sdl, sdl_ns, CONF_SDL_ID +from ..display import CONF_SDL_ID, Sdl, sdl_ns SdlTouchscreen = sdl_ns.class_("SdlTouchscreen", touchscreen.Touchscreen) diff --git a/esphome/components/sdm_meter/sensor.py b/esphome/components/sdm_meter/sensor.py index 4f439ac506..24ae32c7bc 100644 --- a/esphome/components/sdm_meter/sensor.py +++ b/esphome/components/sdm_meter/sensor.py @@ -1,14 +1,13 @@ -from esphome.components.atm90e32.sensor import CONF_PHASE_A, CONF_PHASE_B, CONF_PHASE_C import esphome.codegen as cg +from esphome.components import modbus, sensor +from esphome.components.atm90e32.sensor import CONF_PHASE_A, CONF_PHASE_B, CONF_PHASE_C import esphome.config_validation as cv -from esphome.components import sensor, modbus from esphome.const import ( CONF_ACTIVE_POWER, CONF_APPARENT_POWER, CONF_CURRENT, CONF_EXPORT_ACTIVE_ENERGY, CONF_EXPORT_REACTIVE_ENERGY, - CONF_TOTAL_POWER, CONF_FREQUENCY, CONF_ID, CONF_IMPORT_ACTIVE_ENERGY, @@ -16,6 +15,7 @@ from esphome.const import ( CONF_PHASE_ANGLE, CONF_POWER_FACTOR, CONF_REACTIVE_POWER, + CONF_TOTAL_POWER, CONF_VOLTAGE, DEVICE_CLASS_CURRENT, DEVICE_CLASS_ENERGY, diff --git a/esphome/components/sdp3x/sensor.py b/esphome/components/sdp3x/sensor.py index 60608818a2..67f3f9561f 100644 --- a/esphome/components/sdp3x/sensor.py +++ b/esphome/components/sdp3x/sensor.py @@ -1,7 +1,6 @@ import esphome.codegen as cg +from esphome.components import i2c, sensirion_common, sensor import esphome.config_validation as cv -from esphome.components import i2c, sensor -from esphome.components import sensirion_common from esphome.const import ( DEVICE_CLASS_PRESSURE, STATE_CLASS_MEASUREMENT, diff --git a/esphome/components/sds011/sensor.py b/esphome/components/sds011/sensor.py index 456d47ee91..ae1cc58a95 100644 --- a/esphome/components/sds011/sensor.py +++ b/esphome/components/sds011/sensor.py @@ -1,17 +1,17 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( CONF_ID, - CONF_PM_10_0, CONF_PM_2_5, + CONF_PM_10_0, CONF_RX_ONLY, CONF_UPDATE_INTERVAL, - DEVICE_CLASS_PM25, DEVICE_CLASS_PM10, + DEVICE_CLASS_PM25, + ICON_CHEMICAL_WEAPON, STATE_CLASS_MEASUREMENT, UNIT_MICROGRAMS_PER_CUBIC_METER, - ICON_CHEMICAL_WEAPON, ) DEPENDENCIES = ["uart"] diff --git a/esphome/components/seeed_mr24hpc1/__init__.py b/esphome/components/seeed_mr24hpc1/__init__.py index 52b971e7e4..e80470bde1 100644 --- a/esphome/components/seeed_mr24hpc1/__init__.py +++ b/esphome/components/seeed_mr24hpc1/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import uart +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["uart"] diff --git a/esphome/components/seeed_mr24hpc1/binary_sensor.py b/esphome/components/seeed_mr24hpc1/binary_sensor.py index 003db9f4a3..26de1e4ac1 100644 --- a/esphome/components/seeed_mr24hpc1/binary_sensor.py +++ b/esphome/components/seeed_mr24hpc1/binary_sensor.py @@ -1,12 +1,9 @@ import esphome.codegen as cg from esphome.components import binary_sensor import esphome.config_validation as cv -from esphome.const import ( - DEVICE_CLASS_OCCUPANCY, - CONF_HAS_TARGET, -) -from . import CONF_MR24HPC1_ID, MR24HPC1Component +from esphome.const import CONF_HAS_TARGET, DEVICE_CLASS_OCCUPANCY +from . import CONF_MR24HPC1_ID, MR24HPC1Component CONFIG_SCHEMA = { cv.GenerateID(CONF_MR24HPC1_ID): cv.use_id(MR24HPC1Component), diff --git a/esphome/components/seeed_mr24hpc1/button/__init__.py b/esphome/components/seeed_mr24hpc1/button/__init__.py index 59372e4100..1e68d7e071 100644 --- a/esphome/components/seeed_mr24hpc1/button/__init__.py +++ b/esphome/components/seeed_mr24hpc1/button/__init__.py @@ -7,6 +7,7 @@ from esphome.const import ( ENTITY_CATEGORY_CONFIG, ICON_RESTART_ALERT, ) + from .. import CONF_MR24HPC1_ID, MR24HPC1Component, mr24hpc1_ns RestartButton = mr24hpc1_ns.class_("RestartButton", button.Button) diff --git a/esphome/components/seeed_mr24hpc1/number/__init__.py b/esphome/components/seeed_mr24hpc1/number/__init__.py index 2055fc548c..4de3654e39 100644 --- a/esphome/components/seeed_mr24hpc1/number/__init__.py +++ b/esphome/components/seeed_mr24hpc1/number/__init__.py @@ -1,10 +1,8 @@ import esphome.codegen as cg from esphome.components import number import esphome.config_validation as cv -from esphome.const import ( - CONF_SENSITIVITY, - ENTITY_CATEGORY_CONFIG, -) +from esphome.const import CONF_SENSITIVITY, ENTITY_CATEGORY_CONFIG + from .. import CONF_MR24HPC1_ID, MR24HPC1Component, mr24hpc1_ns SensitivityNumber = mr24hpc1_ns.class_("SensitivityNumber", number.Number) diff --git a/esphome/components/seeed_mr24hpc1/select/__init__.py b/esphome/components/seeed_mr24hpc1/select/__init__.py index 7da83627b9..14854f0795 100644 --- a/esphome/components/seeed_mr24hpc1/select/__init__.py +++ b/esphome/components/seeed_mr24hpc1/select/__init__.py @@ -1,9 +1,8 @@ import esphome.codegen as cg from esphome.components import select import esphome.config_validation as cv -from esphome.const import ( - ENTITY_CATEGORY_CONFIG, -) +from esphome.const import ENTITY_CATEGORY_CONFIG + from .. import CONF_MR24HPC1_ID, MR24HPC1Component, mr24hpc1_ns SceneModeSelect = mr24hpc1_ns.class_("SceneModeSelect", select.Select) diff --git a/esphome/components/seeed_mr24hpc1/sensor.py b/esphome/components/seeed_mr24hpc1/sensor.py index d5eb09e265..7b20941aa4 100644 --- a/esphome/components/seeed_mr24hpc1/sensor.py +++ b/esphome/components/seeed_mr24hpc1/sensor.py @@ -7,6 +7,7 @@ from esphome.const import ( DEVICE_CLASS_SPEED, UNIT_METER, ) + from . import CONF_MR24HPC1_ID, MR24HPC1Component CONF_CUSTOM_PRESENCE_OF_DETECTION = "custom_presence_of_detection" diff --git a/esphome/components/seeed_mr24hpc1/switch/__init__.py b/esphome/components/seeed_mr24hpc1/switch/__init__.py index bbf5391a57..741e7de3ca 100644 --- a/esphome/components/seeed_mr24hpc1/switch/__init__.py +++ b/esphome/components/seeed_mr24hpc1/switch/__init__.py @@ -1,10 +1,8 @@ import esphome.codegen as cg from esphome.components import switch import esphome.config_validation as cv -from esphome.const import ( - DEVICE_CLASS_SWITCH, - ENTITY_CATEGORY_CONFIG, -) +from esphome.const import DEVICE_CLASS_SWITCH, ENTITY_CATEGORY_CONFIG + from .. import CONF_MR24HPC1_ID, MR24HPC1Component, mr24hpc1_ns UnderlyingOpenFuncSwitch = mr24hpc1_ns.class_( diff --git a/esphome/components/seeed_mr24hpc1/text_sensor.py b/esphome/components/seeed_mr24hpc1/text_sensor.py index aa50f577d4..fadd9c6dbc 100644 --- a/esphome/components/seeed_mr24hpc1/text_sensor.py +++ b/esphome/components/seeed_mr24hpc1/text_sensor.py @@ -2,6 +2,7 @@ import esphome.codegen as cg from esphome.components import text_sensor import esphome.config_validation as cv from esphome.const import ENTITY_CATEGORY_DIAGNOSTIC + from . import CONF_MR24HPC1_ID, MR24HPC1Component CONF_HEART_BEAT = "heart_beat" diff --git a/esphome/components/seeed_mr60bha2/binary_sensor.py b/esphome/components/seeed_mr60bha2/binary_sensor.py index ae9e1c23e6..99940ebf6d 100644 --- a/esphome/components/seeed_mr60bha2/binary_sensor.py +++ b/esphome/components/seeed_mr60bha2/binary_sensor.py @@ -1,10 +1,8 @@ import esphome.codegen as cg from esphome.components import binary_sensor import esphome.config_validation as cv -from esphome.const import ( - DEVICE_CLASS_OCCUPANCY, - CONF_HAS_TARGET, -) +from esphome.const import CONF_HAS_TARGET, DEVICE_CLASS_OCCUPANCY + from . import CONF_MR60BHA2_ID, MR60BHA2Component DEPENDENCIES = ["seeed_mr60bha2"] diff --git a/esphome/components/seeed_mr60bha2/sensor.py b/esphome/components/seeed_mr60bha2/sensor.py index 916d4b4ba2..d7f667d862 100644 --- a/esphome/components/seeed_mr60bha2/sensor.py +++ b/esphome/components/seeed_mr60bha2/sensor.py @@ -4,10 +4,10 @@ import esphome.config_validation as cv from esphome.const import ( CONF_DISTANCE, DEVICE_CLASS_DISTANCE, + ICON_COUNTER, ICON_HEART_PULSE, ICON_PULSE, ICON_SIGNAL, - ICON_COUNTER, STATE_CLASS_MEASUREMENT, UNIT_BEATS_PER_MINUTE, UNIT_CENTIMETER, diff --git a/esphome/components/seeed_mr60fda2/button/__init__.py b/esphome/components/seeed_mr60fda2/button/__init__.py index 1415dc27ca..8236248b8c 100644 --- a/esphome/components/seeed_mr60fda2/button/__init__.py +++ b/esphome/components/seeed_mr60fda2/button/__init__.py @@ -2,11 +2,11 @@ import esphome.codegen as cg from esphome.components import button import esphome.config_validation as cv from esphome.const import ( + CONF_FACTORY_RESET, DEVICE_CLASS_RESTART, DEVICE_CLASS_UPDATE, ENTITY_CATEGORY_DIAGNOSTIC, ENTITY_CATEGORY_NONE, - CONF_FACTORY_RESET, ) from .. import CONF_MR60FDA2_ID, MR60FDA2Component, mr60fda2_ns diff --git a/esphome/components/seeed_mr60fda2/select/__init__.py b/esphome/components/seeed_mr60fda2/select/__init__.py index a6f9eeb920..2fea150cd2 100644 --- a/esphome/components/seeed_mr60fda2/select/__init__.py +++ b/esphome/components/seeed_mr60fda2/select/__init__.py @@ -5,7 +5,6 @@ from esphome.const import CONF_SENSITIVITY, ENTITY_CATEGORY_CONFIG, ICON_ACCELER from .. import CONF_MR60FDA2_ID, MR60FDA2Component, mr60fda2_ns - DEPENDENCIES = ["seeed_mr60fda2"] InstallHeightSelect = mr60fda2_ns.class_("InstallHeightSelect", select.Select) diff --git a/esphome/components/selec_meter/sensor.py b/esphome/components/selec_meter/sensor.py index e698255c25..069b61af5a 100644 --- a/esphome/components/selec_meter/sensor.py +++ b/esphome/components/selec_meter/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import modbus, sensor import esphome.config_validation as cv -from esphome.components import sensor, modbus from esphome.const import ( CONF_ACTIVE_POWER, CONF_APPARENT_POWER, diff --git a/esphome/components/sen0321/sensor.py b/esphome/components/sen0321/sensor.py index ee613dc440..e1c1d4e94b 100644 --- a/esphome/components/sen0321/sensor.py +++ b/esphome/components/sen0321/sensor.py @@ -1,10 +1,10 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( ICON_CHEMICAL_WEAPON, - UNIT_PARTS_PER_BILLION, STATE_CLASS_MEASUREMENT, + UNIT_PARTS_PER_BILLION, ) CODEOWNERS = ["@notjj"] diff --git a/esphome/components/sen21231/sensor.py b/esphome/components/sen21231/sensor.py index fb1dc19278..52cecbfb69 100644 --- a/esphome/components/sen21231/sensor.py +++ b/esphome/components/sen21231/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ICON_MOTION_SENSOR CODEOWNERS = ["@shreyaskarnik"] diff --git a/esphome/components/senseair/sensor.py b/esphome/components/senseair/sensor.py index d423793873..cd6d85c12b 100644 --- a/esphome/components/senseair/sensor.py +++ b/esphome/components/senseair/sensor.py @@ -1,13 +1,13 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation from esphome.automation import maybe_simple_id +import esphome.codegen as cg from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( CONF_CO2, CONF_ID, - ICON_MOLECULE_CO2, DEVICE_CLASS_CARBON_DIOXIDE, + ICON_MOLECULE_CO2, STATE_CLASS_MEASUREMENT, UNIT_PARTS_PER_MILLION, ) diff --git a/esphome/components/sensirion_common/__init__.py b/esphome/components/sensirion_common/__init__.py index b27f37099d..5d9424d1e7 100644 --- a/esphome/components/sensirion_common/__init__.py +++ b/esphome/components/sensirion_common/__init__.py @@ -1,8 +1,6 @@ import esphome.codegen as cg - from esphome.components import i2c - CODEOWNERS = ["@martgras"] sensirion_common_ns = cg.esphome_ns.namespace("sensirion_common") diff --git a/esphome/components/servo/__init__.py b/esphome/components/servo/__init__.py index 7147828a07..2fee2840a5 100644 --- a/esphome/components/servo/__init__.py +++ b/esphome/components/servo/__init__.py @@ -1,15 +1,15 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation from esphome.automation import maybe_simple_id +import esphome.codegen as cg from esphome.components.output import FloatOutput +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_IDLE_LEVEL, + CONF_LEVEL, CONF_MAX_LEVEL, CONF_MIN_LEVEL, CONF_OUTPUT, - CONF_LEVEL, CONF_RESTORE, CONF_TRANSITION_LENGTH, ) diff --git a/esphome/components/sfa30/sensor.py b/esphome/components/sfa30/sensor.py index 428f6b874b..8e8a57e341 100644 --- a/esphome/components/sfa30/sensor.py +++ b/esphome/components/sfa30/sensor.py @@ -1,22 +1,21 @@ import esphome.codegen as cg +from esphome.components import i2c, sensirion_common, sensor import esphome.config_validation as cv -from esphome.components import i2c, sensor, sensirion_common - from esphome.const import ( - CONF_ID, CONF_FORMALDEHYDE, CONF_HUMIDITY, + CONF_ID, CONF_TEMPERATURE, DEVICE_CLASS_GAS, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, ICON_RADIATOR, - ICON_WATER_PERCENT, ICON_THERMOMETER, + ICON_WATER_PERCENT, STATE_CLASS_MEASUREMENT, + UNIT_CELSIUS, UNIT_PARTS_PER_BILLION, UNIT_PERCENT, - UNIT_CELSIUS, ) CODEOWNERS = ["@ghsensdev"] diff --git a/esphome/components/sgp4x/sensor.py b/esphome/components/sgp4x/sensor.py index b7cec542bf..9317187df3 100644 --- a/esphome/components/sgp4x/sensor.py +++ b/esphome/components/sgp4x/sensor.py @@ -1,13 +1,13 @@ import esphome.codegen as cg +from esphome.components import i2c, sensirion_common, sensor import esphome.config_validation as cv -from esphome.components import i2c, sensor, sensirion_common from esphome.const import ( CONF_COMPENSATION, CONF_ID, CONF_STORE_BASELINE, CONF_TEMPERATURE_SOURCE, - ICON_RADIATOR, DEVICE_CLASS_AQI, + ICON_RADIATOR, STATE_CLASS_MEASUREMENT, ) diff --git a/esphome/components/shelly_dimmer/light.py b/esphome/components/shelly_dimmer/light.py index 625784427f..bb2c3ceee8 100644 --- a/esphome/components/shelly_dimmer/light.py +++ b/esphome/components/shelly_dimmer/light.py @@ -1,32 +1,32 @@ -from pathlib import Path import hashlib +from pathlib import Path import re + import requests - -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import light, sensor, uart +import esphome.config_validation as cv from esphome.const import ( - CONF_OUTPUT_ID, - CONF_GAMMA_CORRECT, - CONF_POWER, - CONF_VOLTAGE, CONF_CURRENT, - CONF_VERSION, - CONF_URL, + CONF_GAMMA_CORRECT, + CONF_MAX_BRIGHTNESS, + CONF_MIN_BRIGHTNESS, + CONF_OUTPUT_ID, + CONF_POWER, CONF_UPDATE_INTERVAL, - UNIT_VOLT, - UNIT_AMPERE, - UNIT_WATT, + CONF_URL, + CONF_VERSION, + CONF_VOLTAGE, + DEVICE_CLASS_CURRENT, DEVICE_CLASS_POWER, DEVICE_CLASS_VOLTAGE, - DEVICE_CLASS_CURRENT, - CONF_MIN_BRIGHTNESS, - CONF_MAX_BRIGHTNESS, + UNIT_AMPERE, + UNIT_VOLT, + UNIT_WATT, ) -from esphome.core import HexInt, CORE +from esphome.core import CORE, HexInt DOMAIN = "shelly_dimmer" AUTO_LOAD = ["sensor"] diff --git a/esphome/components/sht3xd/sensor.py b/esphome/components/sht3xd/sensor.py index 1286489b29..7ad34972d4 100644 --- a/esphome/components/sht3xd/sensor.py +++ b/esphome/components/sht3xd/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import i2c, sensirion_common, sensor import esphome.config_validation as cv -from esphome.components import i2c, sensor, sensirion_common from esphome.const import ( CONF_HUMIDITY, CONF_ID, diff --git a/esphome/components/sht4x/sensor.py b/esphome/components/sht4x/sensor.py index e195bb9acc..871956f783 100644 --- a/esphome/components/sht4x/sensor.py +++ b/esphome/components/sht4x/sensor.py @@ -1,17 +1,17 @@ import esphome.codegen as cg +from esphome.components import i2c, sensirion_common, sensor import esphome.config_validation as cv -from esphome.components import i2c, sensor, sensirion_common from esphome.const import ( + CONF_HUMIDITY, CONF_ID, CONF_TEMPERATURE, - CONF_HUMIDITY, + DEVICE_CLASS_HUMIDITY, + DEVICE_CLASS_TEMPERATURE, + ICON_THERMOMETER, + ICON_WATER_PERCENT, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - ICON_THERMOMETER, - ICON_WATER_PERCENT, - DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_HUMIDITY, ) CODEOWNERS = ["@sjtrny"] diff --git a/esphome/components/shtcx/sensor.py b/esphome/components/shtcx/sensor.py index c8b56cfe30..bb83ee4482 100644 --- a/esphome/components/shtcx/sensor.py +++ b/esphome/components/shtcx/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import i2c, sensirion_common, sensor import esphome.config_validation as cv -from esphome.components import i2c, sensor, sensirion_common from esphome.const import ( CONF_HUMIDITY, CONF_ID, diff --git a/esphome/components/shutdown/button/__init__.py b/esphome/components/shutdown/button/__init__.py index 79d0b23935..3423b40089 100644 --- a/esphome/components/shutdown/button/__init__.py +++ b/esphome/components/shutdown/button/__init__.py @@ -1,11 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import button -from esphome.const import ( - CONF_ID, - ENTITY_CATEGORY_CONFIG, - ICON_POWER, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID, ENTITY_CATEGORY_CONFIG, ICON_POWER shutdown_ns = cg.esphome_ns.namespace("shutdown") ShutdownButton = shutdown_ns.class_("ShutdownButton", button.Button, cg.Component) diff --git a/esphome/components/shutdown/switch/__init__.py b/esphome/components/shutdown/switch/__init__.py index 5de9f2d189..12cc477647 100644 --- a/esphome/components/shutdown/switch/__init__.py +++ b/esphome/components/shutdown/switch/__init__.py @@ -1,10 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import switch -from esphome.const import ( - ENTITY_CATEGORY_CONFIG, - ICON_POWER, -) +import esphome.config_validation as cv +from esphome.const import ENTITY_CATEGORY_CONFIG, ICON_POWER shutdown_ns = cg.esphome_ns.namespace("shutdown") ShutdownSwitch = shutdown_ns.class_("ShutdownSwitch", switch.Switch, cg.Component) diff --git a/esphome/components/sigma_delta_output/output.py b/esphome/components/sigma_delta_output/output.py index 49ac9e685a..ca5b7a53e0 100644 --- a/esphome/components/sigma_delta_output/output.py +++ b/esphome/components/sigma_delta_output/output.py @@ -1,13 +1,8 @@ from esphome import automation, pins +import esphome.codegen as cg from esphome.components import output import esphome.config_validation as cv -import esphome.codegen as cg -from esphome.const import ( - CONF_ID, - CONF_PIN, - CONF_TURN_ON_ACTION, - CONF_TURN_OFF_ACTION, -) +from esphome.const import CONF_ID, CONF_PIN, CONF_TURN_OFF_ACTION, CONF_TURN_ON_ACTION DEPENDENCIES = [] diff --git a/esphome/components/sim800l/__init__.py b/esphome/components/sim800l/__init__.py index faa6cefe27..2ca9127d3f 100644 --- a/esphome/components/sim800l/__init__.py +++ b/esphome/components/sim800l/__init__.py @@ -1,12 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation -from esphome.const import ( - CONF_ID, - CONF_MESSAGE, - CONF_TRIGGER_ID, -) +import esphome.codegen as cg from esphome.components import uart +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_MESSAGE, CONF_TRIGGER_ID DEPENDENCIES = ["uart"] CODEOWNERS = ["@glmnet"] diff --git a/esphome/components/sim800l/binary_sensor.py b/esphome/components/sim800l/binary_sensor.py index f046d031ea..1cf0b4e1b8 100644 --- a/esphome/components/sim800l/binary_sensor.py +++ b/esphome/components/sim800l/binary_sensor.py @@ -1,10 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor -from esphome.const import ( - DEVICE_CLASS_CONNECTIVITY, - ENTITY_CATEGORY_DIAGNOSTIC, -) +import esphome.config_validation as cv +from esphome.const import DEVICE_CLASS_CONNECTIVITY, ENTITY_CATEGORY_DIAGNOSTIC + from . import CONF_SIM800L_ID, Sim800LComponent DEPENDENCIES = ["sim800l"] diff --git a/esphome/components/sim800l/sensor.py b/esphome/components/sim800l/sensor.py index 156bd6a040..010e325df4 100644 --- a/esphome/components/sim800l/sensor.py +++ b/esphome/components/sim800l/sensor.py @@ -1,12 +1,13 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( DEVICE_CLASS_SIGNAL_STRENGTH, ENTITY_CATEGORY_DIAGNOSTIC, STATE_CLASS_MEASUREMENT, UNIT_DECIBEL_MILLIWATT, ) + from . import CONF_SIM800L_ID, Sim800LComponent DEPENDENCIES = ["sim800l"] diff --git a/esphome/components/slow_pwm/output.py b/esphome/components/slow_pwm/output.py index 9cce35254b..73807ba377 100644 --- a/esphome/components/slow_pwm/output.py +++ b/esphome/components/slow_pwm/output.py @@ -1,14 +1,13 @@ -from esphome import pins, core +from esphome import automation, core, pins +import esphome.codegen as cg from esphome.components import output import esphome.config_validation as cv -import esphome.codegen as cg -from esphome import automation from esphome.const import ( CONF_ID, - CONF_PIN, CONF_PERIOD, - CONF_TURN_ON_ACTION, + CONF_PIN, CONF_TURN_OFF_ACTION, + CONF_TURN_ON_ACTION, ) slow_pwm_ns = cg.esphome_ns.namespace("slow_pwm") diff --git a/esphome/components/sm10bit_base/__init__.py b/esphome/components/sm10bit_base/__init__.py index 8722bd35a9..81e7c04c0e 100644 --- a/esphome/components/sm10bit_base/__init__.py +++ b/esphome/components/sm10bit_base/__init__.py @@ -1,11 +1,7 @@ +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins -from esphome.const import ( - CONF_CLOCK_PIN, - CONF_DATA_PIN, - CONF_ID, -) +from esphome.const import CONF_CLOCK_PIN, CONF_DATA_PIN, CONF_ID CODEOWNERS = ["@Cossid"] MULTI_CONF = True diff --git a/esphome/components/sm16716/__init__.py b/esphome/components/sm16716/__init__.py index ec8ed722f3..e97bc440f4 100644 --- a/esphome/components/sm16716/__init__.py +++ b/esphome/components/sm16716/__init__.py @@ -1,6 +1,6 @@ +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins from esphome.const import ( CONF_CLOCK_PIN, CONF_DATA_PIN, diff --git a/esphome/components/sm16716/output.py b/esphome/components/sm16716/output.py index e9b92f68f8..50f6ec759f 100644 --- a/esphome/components/sm16716/output.py +++ b/esphome/components/sm16716/output.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL, CONF_ID + from . import SM16716 DEPENDENCIES = ["sm16716"] diff --git a/esphome/components/sm2135/__init__.py b/esphome/components/sm2135/__init__.py index 52128f1f24..28c92a42a7 100644 --- a/esphome/components/sm2135/__init__.py +++ b/esphome/components/sm2135/__init__.py @@ -1,11 +1,7 @@ +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins -from esphome.const import ( - CONF_CLOCK_PIN, - CONF_DATA_PIN, - CONF_ID, -) +from esphome.const import CONF_CLOCK_PIN, CONF_DATA_PIN, CONF_ID AUTO_LOAD = ["output"] CODEOWNERS = ["@BoukeHaarsma23", "@matika77", "@dd32"] diff --git a/esphome/components/sm2135/output.py b/esphome/components/sm2135/output.py index 5cd969c6a5..71c4af2253 100644 --- a/esphome/components/sm2135/output.py +++ b/esphome/components/sm2135/output.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL, CONF_ID + from . import SM2135 DEPENDENCIES = ["sm2135"] diff --git a/esphome/components/sm2235/__init__.py b/esphome/components/sm2235/__init__.py index ae6cb336ad..1b18a1d342 100644 --- a/esphome/components/sm2235/__init__.py +++ b/esphome/components/sm2235/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sm10bit_base +import esphome.config_validation as cv AUTO_LOAD = ["sm10bit_base", "output"] CODEOWNERS = ["@Cossid"] diff --git a/esphome/components/sm2235/output.py b/esphome/components/sm2235/output.py index c4f63b451a..2a9698d645 100644 --- a/esphome/components/sm2235/output.py +++ b/esphome/components/sm2235/output.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL, CONF_ID + from . import SM2235 DEPENDENCIES = ["sm2235"] diff --git a/esphome/components/sm2335/__init__.py b/esphome/components/sm2335/__init__.py index 6d6e0e311c..02a6d1f697 100644 --- a/esphome/components/sm2335/__init__.py +++ b/esphome/components/sm2335/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sm10bit_base +import esphome.config_validation as cv AUTO_LOAD = ["sm10bit_base", "output"] CODEOWNERS = ["@Cossid"] diff --git a/esphome/components/sm2335/output.py b/esphome/components/sm2335/output.py index 52b6321db1..ef7fec7307 100644 --- a/esphome/components/sm2335/output.py +++ b/esphome/components/sm2335/output.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL, CONF_ID + from . import SM2335 DEPENDENCIES = ["sm2335"] diff --git a/esphome/components/sm300d2/sensor.py b/esphome/components/sm300d2/sensor.py index 0c3c54f200..60c9ccc40d 100644 --- a/esphome/components/sm300d2/sensor.py +++ b/esphome/components/sm300d2/sensor.py @@ -1,30 +1,30 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_CO2, CONF_FORMALDEHYDE, - CONF_TVOC, + CONF_HUMIDITY, + CONF_ID, CONF_PM_2_5, CONF_PM_10_0, CONF_TEMPERATURE, - CONF_HUMIDITY, + CONF_TVOC, DEVICE_CLASS_CARBON_DIOXIDE, - DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, - DEVICE_CLASS_PM25, - DEVICE_CLASS_PM10, - DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_HUMIDITY, - STATE_CLASS_MEASUREMENT, - UNIT_PARTS_PER_MILLION, - UNIT_MICROGRAMS_PER_CUBIC_METER, - UNIT_CELSIUS, - UNIT_PERCENT, - ICON_MOLECULE_CO2, - ICON_FLASK, + DEVICE_CLASS_PM10, + DEVICE_CLASS_PM25, + DEVICE_CLASS_TEMPERATURE, + DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS, ICON_CHEMICAL_WEAPON, + ICON_FLASK, ICON_GRAIN, + ICON_MOLECULE_CO2, + STATE_CLASS_MEASUREMENT, + UNIT_CELSIUS, + UNIT_MICROGRAMS_PER_CUBIC_METER, + UNIT_PARTS_PER_MILLION, + UNIT_PERCENT, ) DEPENDENCIES = ["uart"] diff --git a/esphome/components/sml/__init__.py b/esphome/components/sml/__init__.py index 8bcfb69a45..936efd8561 100644 --- a/esphome/components/sml/__init__.py +++ b/esphome/components/sml/__init__.py @@ -2,8 +2,8 @@ import re from esphome import automation import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import uart +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_TRIGGER_ID CODEOWNERS = ["@alengwenus"] diff --git a/esphome/components/sml/sensor/__init__.py b/esphome/components/sml/sensor/__init__.py index a1fcc5e7ae..164a31f8a7 100644 --- a/esphome/components/sml/sensor/__init__.py +++ b/esphome/components/sml/sensor/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import CONF_ID from .. import CONF_OBIS_CODE, CONF_SERVER_ID, CONF_SML_ID, Sml, obis_code, sml_ns diff --git a/esphome/components/sml/text_sensor/__init__.py b/esphome/components/sml/text_sensor/__init__.py index 81564bf65b..401db9c582 100644 --- a/esphome/components/sml/text_sensor/__init__.py +++ b/esphome/components/sml/text_sensor/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor +import esphome.config_validation as cv from esphome.const import CONF_FORMAT, CONF_ID from .. import CONF_OBIS_CODE, CONF_SERVER_ID, CONF_SML_ID, Sml, obis_code, sml_ns diff --git a/esphome/components/smt100/sensor.py b/esphome/components/smt100/sensor.py index 33eb78b841..ea42499379 100644 --- a/esphome/components/smt100/sensor.py +++ b/esphome/components/smt100/sensor.py @@ -1,20 +1,19 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart - +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_COUNTS, CONF_DIELECTRIC_CONSTANT, - CONF_TEMPERATURE, + CONF_ID, CONF_MOISTURE, + CONF_TEMPERATURE, CONF_VOLTAGE, - ICON_WATER_PERCENT, DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_VOLTAGE, + ICON_WATER_PERCENT, STATE_CLASS_MEASUREMENT, - UNIT_EMPTY, UNIT_CELSIUS, + UNIT_EMPTY, UNIT_PERCENT, UNIT_VOLT, ) diff --git a/esphome/components/sn74hc165/__init__.py b/esphome/components/sn74hc165/__init__.py index 0f2abd3678..f2ba5fedd1 100644 --- a/esphome/components/sn74hc165/__init__.py +++ b/esphome/components/sn74hc165/__init__.py @@ -1,14 +1,14 @@ +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins from esphome.const import ( + CONF_CLOCK_PIN, + CONF_DATA_PIN, CONF_ID, + CONF_INPUT, + CONF_INVERTED, CONF_MODE, CONF_NUMBER, - CONF_INVERTED, - CONF_DATA_PIN, - CONF_CLOCK_PIN, - CONF_INPUT, ) CODEOWNERS = ["@jesserockz"] diff --git a/esphome/components/sn74hc595/__init__.py b/esphome/components/sn74hc595/__init__.py index 2fd49f6824..db18b00cd1 100644 --- a/esphome/components/sn74hc595/__init__.py +++ b/esphome/components/sn74hc595/__init__.py @@ -1,13 +1,13 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import spi +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, - CONF_NUMBER, - CONF_INVERTED, - CONF_DATA_PIN, CONF_CLOCK_PIN, + CONF_DATA_PIN, + CONF_ID, + CONF_INVERTED, + CONF_NUMBER, CONF_OE_PIN, CONF_OUTPUT, CONF_TYPE, diff --git a/esphome/components/socket/__init__.py b/esphome/components/socket/__init__.py index 19952aeece..77e8fe51f6 100644 --- a/esphome/components/socket/__init__.py +++ b/esphome/components/socket/__init__.py @@ -1,5 +1,5 @@ -import esphome.config_validation as cv import esphome.codegen as cg +import esphome.config_validation as cv CODEOWNERS = ["@esphome/core"] diff --git a/esphome/components/sonoff_d1/light.py b/esphome/components/sonoff_d1/light.py index 8ffe60224e..06cde45cd6 100644 --- a/esphome/components/sonoff_d1/light.py +++ b/esphome/components/sonoff_d1/light.py @@ -1,11 +1,7 @@ import esphome.codegen as cg +from esphome.components import light, uart import esphome.config_validation as cv -from esphome.components import uart, light -from esphome.const import ( - CONF_OUTPUT_ID, - CONF_MIN_VALUE, - CONF_MAX_VALUE, -) +from esphome.const import CONF_MAX_VALUE, CONF_MIN_VALUE, CONF_OUTPUT_ID CONF_USE_RM433_REMOTE = "use_rm433_remote" diff --git a/esphome/components/speed/fan/__init__.py b/esphome/components/speed/fan/__init__.py index 5fbf011669..fe43ac6a3a 100644 --- a/esphome/components/speed/fan/__init__.py +++ b/esphome/components/speed/fan/__init__.py @@ -1,13 +1,13 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import fan, output from esphome.components.fan import validate_preset_modes +import esphome.config_validation as cv from esphome.const import ( - CONF_PRESET_MODES, CONF_DIRECTION_OUTPUT, CONF_OSCILLATION_OUTPUT, CONF_OUTPUT, CONF_OUTPUT_ID, + CONF_PRESET_MODES, CONF_SPEED, CONF_SPEED_COUNT, ) diff --git a/esphome/components/sprinkler/__init__.py b/esphome/components/sprinkler/__init__.py index e5bcf681f4..2c59309b1f 100644 --- a/esphome/components/sprinkler/__init__.py +++ b/esphome/components/sprinkler/__init__.py @@ -1,9 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation from esphome.automation import maybe_simple_id -from esphome.components import number -from esphome.components import switch +import esphome.codegen as cg +from esphome.components import number, switch +import esphome.config_validation as cv from esphome.const import ( CONF_ENTITY_CATEGORY, CONF_ID, @@ -14,12 +13,12 @@ from esphome.const import ( CONF_REPEAT, CONF_RESTORE_VALUE, CONF_RUN_DURATION, + CONF_SET_ACTION, CONF_STEP, CONF_UNIT_OF_MEASUREMENT, ENTITY_CATEGORY_CONFIG, UNIT_MINUTE, UNIT_SECOND, - CONF_SET_ACTION, ) AUTO_LOAD = ["number", "switch"] diff --git a/esphome/components/sps30/sensor.py b/esphome/components/sps30/sensor.py index 0f01bab514..d4f91b4188 100644 --- a/esphome/components/sps30/sensor.py +++ b/esphome/components/sps30/sensor.py @@ -1,30 +1,30 @@ -import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import i2c, sensor, sensirion_common from esphome import automation from esphome.automation import maybe_simple_id +import esphome.codegen as cg +from esphome.components import i2c, sensirion_common, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_PM_1_0, CONF_PM_2_5, CONF_PM_4_0, CONF_PM_10_0, + CONF_PM_SIZE, CONF_PMC_0_5, CONF_PMC_1_0, CONF_PMC_2_5, CONF_PMC_4_0, CONF_PMC_10_0, - CONF_PM_SIZE, DEVICE_CLASS_PM1, DEVICE_CLASS_PM10, DEVICE_CLASS_PM25, - STATE_CLASS_MEASUREMENT, - UNIT_MICROGRAMS_PER_CUBIC_METER, - UNIT_COUNTS_PER_CUBIC_CENTIMETER, - UNIT_MICROMETER, ICON_CHEMICAL_WEAPON, ICON_COUNTER, ICON_RULER, + STATE_CLASS_MEASUREMENT, + UNIT_COUNTS_PER_CUBIC_CENTIMETER, + UNIT_MICROGRAMS_PER_CUBIC_METER, + UNIT_MICROMETER, ) CODEOWNERS = ["@martgras"] diff --git a/esphome/components/ssd1306_i2c/display.py b/esphome/components/ssd1306_i2c/display.py index c51ab5f93e..2ac0093ef1 100644 --- a/esphome/components/ssd1306_i2c/display.py +++ b/esphome/components/ssd1306_i2c/display.py @@ -1,7 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components import ssd1306_base, i2c +from esphome.components import i2c, ssd1306_base from esphome.components.ssd1306_base import _validate +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_LAMBDA, CONF_PAGES AUTO_LOAD = ["ssd1306_base"] diff --git a/esphome/components/ssd1322_base/__init__.py b/esphome/components/ssd1322_base/__init__.py index 471c874986..3569bbe957 100644 --- a/esphome/components/ssd1322_base/__init__.py +++ b/esphome/components/ssd1322_base/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import display +import esphome.config_validation as cv from esphome.const import ( CONF_BRIGHTNESS, CONF_EXTERNAL_VCC, diff --git a/esphome/components/ssd1325_base/__init__.py b/esphome/components/ssd1325_base/__init__.py index e66cfbc684..12cbd883a0 100644 --- a/esphome/components/ssd1325_base/__init__.py +++ b/esphome/components/ssd1325_base/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import display +import esphome.config_validation as cv from esphome.const import ( CONF_BRIGHTNESS, CONF_EXTERNAL_VCC, diff --git a/esphome/components/ssd1327_base/__init__.py b/esphome/components/ssd1327_base/__init__.py index 7f2259cf32..d0ec2410e6 100644 --- a/esphome/components/ssd1327_base/__init__.py +++ b/esphome/components/ssd1327_base/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import display +import esphome.config_validation as cv from esphome.const import CONF_BRIGHTNESS, CONF_LAMBDA, CONF_MODEL, CONF_RESET_PIN CODEOWNERS = ["@kbx81"] diff --git a/esphome/components/ssd1327_i2c/display.py b/esphome/components/ssd1327_i2c/display.py index 7b581cc92c..95de1c2979 100644 --- a/esphome/components/ssd1327_i2c/display.py +++ b/esphome/components/ssd1327_i2c/display.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import i2c, ssd1327_base import esphome.config_validation as cv -from esphome.components import ssd1327_base, i2c from esphome.const import CONF_ID, CONF_LAMBDA, CONF_PAGES CODEOWNERS = ["@kbx81"] diff --git a/esphome/components/ssd1331_base/__init__.py b/esphome/components/ssd1331_base/__init__.py index 80162979fc..144a95a29f 100644 --- a/esphome/components/ssd1331_base/__init__.py +++ b/esphome/components/ssd1331_base/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import display +import esphome.config_validation as cv from esphome.const import CONF_BRIGHTNESS, CONF_LAMBDA, CONF_RESET_PIN CODEOWNERS = ["@kbx81"] diff --git a/esphome/components/ssd1351_base/__init__.py b/esphome/components/ssd1351_base/__init__.py index 150d89afed..fc03083ad0 100644 --- a/esphome/components/ssd1351_base/__init__.py +++ b/esphome/components/ssd1351_base/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import display +import esphome.config_validation as cv from esphome.const import CONF_BRIGHTNESS, CONF_LAMBDA, CONF_MODEL, CONF_RESET_PIN CODEOWNERS = ["@kbx81"] diff --git a/esphome/components/st7567_base/__init__.py b/esphome/components/st7567_base/__init__.py index 7ce50fd99f..6f93172a1a 100644 --- a/esphome/components/st7567_base/__init__.py +++ b/esphome/components/st7567_base/__init__.py @@ -1,14 +1,14 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import display +import esphome.config_validation as cv from esphome.const import ( + CONF_INVERT_COLORS, CONF_LAMBDA, - CONF_RESET_PIN, CONF_MIRROR_X, CONF_MIRROR_Y, + CONF_RESET_PIN, CONF_TRANSFORM, - CONF_INVERT_COLORS, ) CODEOWNERS = ["@latonita"] diff --git a/esphome/components/st7567_i2c/display.py b/esphome/components/st7567_i2c/display.py index fa92d652d7..bd62b3b382 100644 --- a/esphome/components/st7567_i2c/display.py +++ b/esphome/components/st7567_i2c/display.py @@ -1,6 +1,6 @@ import esphome.codegen as cg +from esphome.components import i2c, st7567_base import esphome.config_validation as cv -from esphome.components import st7567_base, i2c from esphome.const import CONF_ID, CONF_LAMBDA, CONF_PAGES CODEOWNERS = ["@latonita"] diff --git a/esphome/components/st7920/display.py b/esphome/components/st7920/display.py index 1267e2ad63..de7b2247dd 100644 --- a/esphome/components/st7920/display.py +++ b/esphome/components/st7920/display.py @@ -1,7 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import display, spi -from esphome.const import CONF_ID, CONF_LAMBDA, CONF_WIDTH, CONF_HEIGHT +import esphome.config_validation as cv +from esphome.const import CONF_HEIGHT, CONF_ID, CONF_LAMBDA, CONF_WIDTH AUTO_LOAD = ["display"] CODEOWNERS = ["@marsjan155"] diff --git a/esphome/components/statsd/__init__.py b/esphome/components/statsd/__init__.py index 3623338aec..39188c6b81 100644 --- a/esphome/components/statsd/__init__.py +++ b/esphome/components/statsd/__init__.py @@ -1,12 +1,12 @@ import esphome.codegen as cg +from esphome.components import binary_sensor, sensor import esphome.config_validation as cv -from esphome.components import sensor, binary_sensor from esphome.const import ( - CONF_ID, - CONF_PORT, - CONF_NAME, - CONF_SENSORS, CONF_BINARY_SENSORS, + CONF_ID, + CONF_NAME, + CONF_PORT, + CONF_SENSORS, ) AUTO_LOAD = ["socket"] diff --git a/esphome/components/status/binary_sensor.py b/esphome/components/status/binary_sensor.py index adc342ed4d..c1a4a52ce2 100644 --- a/esphome/components/status/binary_sensor.py +++ b/esphome/components/status/binary_sensor.py @@ -1,10 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor -from esphome.const import ( - DEVICE_CLASS_CONNECTIVITY, - ENTITY_CATEGORY_DIAGNOSTIC, -) +import esphome.config_validation as cv +from esphome.const import DEVICE_CLASS_CONNECTIVITY, ENTITY_CATEGORY_DIAGNOSTIC DEPENDENCIES = ["network"] diff --git a/esphome/components/status_led/__init__.py b/esphome/components/status_led/__init__.py index 92869ee630..b299ae7ff7 100644 --- a/esphome/components/status_led/__init__.py +++ b/esphome/components/status_led/__init__.py @@ -1,6 +1,6 @@ from esphome import pins -import esphome.config_validation as cv import esphome.codegen as cg +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_PIN from esphome.core import coroutine_with_priority diff --git a/esphome/components/status_led/light/__init__.py b/esphome/components/status_led/light/__init__.py index d6a4a245e6..f8d03a3b4f 100644 --- a/esphome/components/status_led/light/__init__.py +++ b/esphome/components/status_led/light/__init__.py @@ -1,8 +1,9 @@ from esphome import pins import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import light, output +import esphome.config_validation as cv from esphome.const import CONF_OUTPUT, CONF_OUTPUT_ID, CONF_PIN + from .. import status_led_ns AUTO_LOAD = ["output"] diff --git a/esphome/components/stepper/__init__.py b/esphome/components/stepper/__init__.py index f2367fd62a..66fe88c6c4 100644 --- a/esphome/components/stepper/__init__.py +++ b/esphome/components/stepper/__init__.py @@ -1,14 +1,14 @@ +from esphome import automation import esphome.codegen as cg import esphome.config_validation as cv -from esphome import automation from esphome.const import ( CONF_ACCELERATION, CONF_DECELERATION, CONF_ID, CONF_MAX_SPEED, CONF_POSITION, - CONF_TARGET, CONF_SPEED, + CONF_TARGET, ) from esphome.core import CORE, coroutine_with_priority diff --git a/esphome/components/sts3x/sensor.py b/esphome/components/sts3x/sensor.py index a99503a2b8..7b04bd58bb 100644 --- a/esphome/components/sts3x/sensor.py +++ b/esphome/components/sts3x/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, diff --git a/esphome/components/substitutions/__init__.py b/esphome/components/substitutions/__init__.py index fa52200d46..41e49f70db 100644 --- a/esphome/components/substitutions/__init__.py +++ b/esphome/components/substitutions/__init__.py @@ -1,10 +1,10 @@ import logging -import esphome.config_validation as cv from esphome import core +from esphome.config_helpers import Extend, Remove, merge_config +import esphome.config_validation as cv from esphome.const import CONF_SUBSTITUTIONS, VALID_SUBSTITUTIONS_CHARACTERS from esphome.yaml_util import ESPHomeDataBase, make_data_base -from esphome.config_helpers import merge_config, Extend, Remove CODEOWNERS = ["@esphome/core"] _LOGGER = logging.getLogger(__name__) diff --git a/esphome/components/sun/__init__.py b/esphome/components/sun/__init__.py index d00a00661a..5a2a39c427 100644 --- a/esphome/components/sun/__init__.py +++ b/esphome/components/sun/__init__.py @@ -1,15 +1,15 @@ import re -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import time +import esphome.config_validation as cv from esphome.const import ( - CONF_TIME_ID, CONF_ID, - CONF_TRIGGER_ID, CONF_LATITUDE, CONF_LONGITUDE, + CONF_TIME_ID, + CONF_TRIGGER_ID, ) CODEOWNERS = ["@OttoWinter"] diff --git a/esphome/components/sun/sensor/__init__.py b/esphome/components/sun/sensor/__init__.py index 10c0237327..a356d9cca8 100644 --- a/esphome/components/sun/sensor/__init__.py +++ b/esphome/components/sun/sensor/__init__.py @@ -1,12 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor -from esphome.const import ( - UNIT_DEGREES, - ICON_WEATHER_SUNSET, - CONF_TYPE, -) -from .. import sun_ns, CONF_SUN_ID, Sun +import esphome.config_validation as cv +from esphome.const import CONF_TYPE, ICON_WEATHER_SUNSET, UNIT_DEGREES + +from .. import CONF_SUN_ID, Sun, sun_ns DEPENDENCIES = ["sun"] diff --git a/esphome/components/sun/text_sensor/__init__.py b/esphome/components/sun/text_sensor/__init__.py index 80737bb9f2..fc733d3435 100644 --- a/esphome/components/sun/text_sensor/__init__.py +++ b/esphome/components/sun/text_sensor/__init__.py @@ -1,14 +1,15 @@ +import esphome.codegen as cg from esphome.components import text_sensor import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import ( + CONF_FORMAT, CONF_ICON, + CONF_TYPE, ICON_WEATHER_SUNSET_DOWN, ICON_WEATHER_SUNSET_UP, - CONF_TYPE, - CONF_FORMAT, ) -from .. import sun_ns, CONF_SUN_ID, Sun, CONF_ELEVATION, elevation, DEFAULT_ELEVATION + +from .. import CONF_ELEVATION, CONF_SUN_ID, DEFAULT_ELEVATION, Sun, elevation, sun_ns DEPENDENCIES = ["sun"] diff --git a/esphome/components/sun_gtil2/__init__.py b/esphome/components/sun_gtil2/__init__.py index f4d46fade7..d073c16e4e 100644 --- a/esphome/components/sun_gtil2/__init__.py +++ b/esphome/components/sun_gtil2/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import uart +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@Mat931"] diff --git a/esphome/components/sun_gtil2/sensor.py b/esphome/components/sun_gtil2/sensor.py index 6d1be9c740..d8c59bf1de 100644 --- a/esphome/components/sun_gtil2/sensor.py +++ b/esphome/components/sun_gtil2/sensor.py @@ -1,18 +1,19 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( - DEVICE_CLASS_VOLTAGE, + CONF_TEMPERATURE, DEVICE_CLASS_POWER, DEVICE_CLASS_TEMPERATURE, + DEVICE_CLASS_VOLTAGE, ICON_FLASH, - UNIT_VOLT, ICON_THERMOMETER, - UNIT_WATT, UNIT_CELSIUS, - CONF_TEMPERATURE, + UNIT_VOLT, + UNIT_WATT, ) -from . import SunGTIL2Component, CONF_SUN_GTIL2_ID + +from . import CONF_SUN_GTIL2_ID, SunGTIL2Component CONF_AC_VOLTAGE = "ac_voltage" CONF_DC_VOLTAGE = "dc_voltage" diff --git a/esphome/components/sun_gtil2/text_sensor.py b/esphome/components/sun_gtil2/text_sensor.py index d9d3e3ca66..f74f89b3b4 100644 --- a/esphome/components/sun_gtil2/text_sensor.py +++ b/esphome/components/sun_gtil2/text_sensor.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor +import esphome.config_validation as cv from esphome.const import CONF_STATE -from . import SunGTIL2Component, CONF_SUN_GTIL2_ID + +from . import CONF_SUN_GTIL2_ID, SunGTIL2Component CONF_SERIAL_NUMBER = "serial_number" diff --git a/esphome/components/sx1509/__init__.py b/esphome/components/sx1509/__init__.py index e4f79dc2bc..b1702b5ade 100644 --- a/esphome/components/sx1509/__init__.py +++ b/esphome/components/sx1509/__init__.py @@ -1,17 +1,17 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_INPUT, - CONF_NUMBER, - CONF_MODE, CONF_INVERTED, + CONF_MODE, + CONF_NUMBER, + CONF_OPEN_DRAIN, CONF_OUTPUT, CONF_PULLDOWN, CONF_PULLUP, - CONF_OPEN_DRAIN, ) CONF_KEYPAD = "keypad" diff --git a/esphome/components/sx1509/binary_sensor/__init__.py b/esphome/components/sx1509/binary_sensor/__init__.py index 280b5ad90c..0ceca77a5d 100644 --- a/esphome/components/sx1509/binary_sensor/__init__.py +++ b/esphome/components/sx1509/binary_sensor/__init__.py @@ -1,9 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor -from esphome.const import CONF_ROW, CONF_COL +import esphome.config_validation as cv +from esphome.const import CONF_COL, CONF_ROW -from .. import SX1509Component, sx1509_ns, CONF_SX1509_ID +from .. import CONF_SX1509_ID, SX1509Component, sx1509_ns DEPENDENCIES = ["sx1509"] diff --git a/esphome/components/sx1509/output/__init__.py b/esphome/components/sx1509/output/__init__.py index 7afea0fbf8..9e2db7bb10 100644 --- a/esphome/components/sx1509/output/__init__.py +++ b/esphome/components/sx1509/output/__init__.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output -from esphome.const import CONF_PIN, CONF_ID -from .. import SX1509Component, sx1509_ns, CONF_SX1509_ID +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_PIN + +from .. import CONF_SX1509_ID, SX1509Component, sx1509_ns DEPENDENCIES = ["sx1509"] diff --git a/esphome/components/t6615/sensor.py b/esphome/components/t6615/sensor.py index 71a099d635..6df40497a9 100644 --- a/esphome/components/t6615/sensor.py +++ b/esphome/components/t6615/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, uart +import esphome.config_validation as cv from esphome.const import ( CONF_CO2, CONF_ID, diff --git a/esphome/components/tca9548a/__init__.py b/esphome/components/tca9548a/__init__.py index 0f222b8fc7..cef779de2e 100644 --- a/esphome/components/tca9548a/__init__.py +++ b/esphome/components/tca9548a/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL, CONF_CHANNELS, CONF_ID, CONF_SCAN CODEOWNERS = ["@andreashergert1984"] diff --git a/esphome/components/tcl112/climate.py b/esphome/components/tcl112/climate.py index 9facd6b8db..9cd193f5c7 100644 --- a/esphome/components/tcl112/climate.py +++ b/esphome/components/tcl112/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/tcs34725/sensor.py b/esphome/components/tcs34725/sensor.py index d47e9a34c8..34b6c579b6 100644 --- a/esphome/components/tcs34725/sensor.py +++ b/esphome/components/tcs34725/sensor.py @@ -1,20 +1,20 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_COLOR_TEMPERATURE, CONF_GAIN, + CONF_GLASS_ATTENUATION_FACTOR, CONF_ID, CONF_ILLUMINANCE, - CONF_GLASS_ATTENUATION_FACTOR, CONF_INTEGRATION_TIME, DEVICE_CLASS_ILLUMINANCE, ICON_LIGHTBULB, - STATE_CLASS_MEASUREMENT, - UNIT_PERCENT, ICON_THERMOMETER, + STATE_CLASS_MEASUREMENT, UNIT_KELVIN, UNIT_LUX, + UNIT_PERCENT, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/tee501/sensor.py b/esphome/components/tee501/sensor.py index 329fc724bd..db8e8d9268 100644 --- a/esphome/components/tee501/sensor.py +++ b/esphome/components/tee501/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, diff --git a/esphome/components/teleinfo/__init__.py b/esphome/components/teleinfo/__init__.py index e289e42c81..87c7b9e85c 100644 --- a/esphome/components/teleinfo/__init__.py +++ b/esphome/components/teleinfo/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import uart +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@0hax"] diff --git a/esphome/components/teleinfo/sensor/__init__.py b/esphome/components/teleinfo/sensor/__init__.py index ff2d81c95e..b436c70120 100644 --- a/esphome/components/teleinfo/sensor/__init__.py +++ b/esphome/components/teleinfo/sensor/__init__.py @@ -2,13 +2,7 @@ import esphome.codegen as cg from esphome.components import sensor from esphome.const import CONF_ID, ICON_FLASH, UNIT_WATT_HOURS -from .. import ( - CONF_TAG_NAME, - TELEINFO_LISTENER_SCHEMA, - teleinfo_ns, - CONF_TELEINFO_ID, -) - +from .. import CONF_TAG_NAME, CONF_TELEINFO_ID, TELEINFO_LISTENER_SCHEMA, teleinfo_ns TeleInfoSensor = teleinfo_ns.class_("TeleInfoSensor", sensor.Sensor, cg.Component) diff --git a/esphome/components/teleinfo/text_sensor/__init__.py b/esphome/components/teleinfo/text_sensor/__init__.py index df8e4c21fc..79fabd10d0 100644 --- a/esphome/components/teleinfo/text_sensor/__init__.py +++ b/esphome/components/teleinfo/text_sensor/__init__.py @@ -2,7 +2,7 @@ import esphome.codegen as cg from esphome.components import text_sensor from esphome.const import CONF_ID -from .. import CONF_TAG_NAME, TELEINFO_LISTENER_SCHEMA, teleinfo_ns, CONF_TELEINFO_ID +from .. import CONF_TAG_NAME, CONF_TELEINFO_ID, TELEINFO_LISTENER_SCHEMA, teleinfo_ns TeleInfoTextSensor = teleinfo_ns.class_( "TeleInfoTextSensor", text_sensor.TextSensor, cg.Component diff --git a/esphome/components/tem3200/sensor.py b/esphome/components/tem3200/sensor.py index 5cd27433d0..508dc1bcd4 100644 --- a/esphome/components/tem3200/sensor.py +++ b/esphome/components/tem3200/sensor.py @@ -1,7 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor - +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_TEMPERATURE, diff --git a/esphome/components/template/alarm_control_panel/__init__.py b/esphome/components/template/alarm_control_panel/__init__.py index 3555f2fafd..0f213857dc 100644 --- a/esphome/components/template/alarm_control_panel/__init__.py +++ b/esphome/components/template/alarm_control_panel/__init__.py @@ -1,15 +1,8 @@ import esphome.codegen as cg +from esphome.components import alarm_control_panel, binary_sensor import esphome.config_validation as cv -from esphome.components import ( - binary_sensor, - alarm_control_panel, -) -from esphome.const import ( - CONF_ID, - CONF_BINARY_SENSORS, - CONF_INPUT, - CONF_RESTORE_MODE, -) +from esphome.const import CONF_BINARY_SENSORS, CONF_ID, CONF_INPUT, CONF_RESTORE_MODE + from .. import template_ns CODEOWNERS = ["@grahambrown11", "@hwstar"] diff --git a/esphome/components/template/cover/__init__.py b/esphome/components/template/cover/__init__.py index 43d0be99b4..5129e6b1af 100644 --- a/esphome/components/template/cover/__init__.py +++ b/esphome/components/template/cover/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import cover +import esphome.config_validation as cv from esphome.const import ( CONF_ASSUMED_STATE, CONF_CLOSE_ACTION, @@ -11,14 +11,15 @@ from esphome.const import ( CONF_OPEN_ACTION, CONF_OPTIMISTIC, CONF_POSITION, + CONF_POSITION_ACTION, CONF_RESTORE_MODE, CONF_STATE, CONF_STOP_ACTION, CONF_TILT, CONF_TILT_ACTION, CONF_TILT_LAMBDA, - CONF_POSITION_ACTION, ) + from .. import template_ns TemplateCover = template_ns.class_("TemplateCover", cover.Cover, cg.Component) diff --git a/esphome/components/template/datetime/__init__.py b/esphome/components/template/datetime/__init__.py index 746ab8a6f3..813d351fd9 100644 --- a/esphome/components/template/datetime/__init__.py +++ b/esphome/components/template/datetime/__init__.py @@ -1,18 +1,18 @@ from esphome import automation import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import datetime +import esphome.config_validation as cv from esphome.const import ( - CONF_INITIAL_VALUE, - CONF_LAMBDA, - CONF_OPTIMISTIC, - CONF_RESTORE_VALUE, - CONF_SET_ACTION, CONF_DAY, CONF_HOUR, + CONF_INITIAL_VALUE, + CONF_LAMBDA, CONF_MINUTE, CONF_MONTH, + CONF_OPTIMISTIC, + CONF_RESTORE_VALUE, CONF_SECOND, + CONF_SET_ACTION, CONF_TYPE, CONF_YEAR, ) @@ -44,9 +44,8 @@ def validate(config): raise cv.Invalid("initial_value cannot be used with lambda") if CONF_RESTORE_VALUE in config: raise cv.Invalid("restore_value cannot be used with lambda") - else: - if CONF_RESTORE_VALUE not in config: - config[CONF_RESTORE_VALUE] = False + elif CONF_RESTORE_VALUE not in config: + config[CONF_RESTORE_VALUE] = False if not config[CONF_OPTIMISTIC] and CONF_SET_ACTION not in config: raise cv.Invalid( diff --git a/esphome/components/template/event/__init__.py b/esphome/components/template/event/__init__.py index 2a948cfdfd..cf9c7f4c3d 100644 --- a/esphome/components/template/event/__init__.py +++ b/esphome/components/template/event/__init__.py @@ -1,9 +1,6 @@ -import esphome.config_validation as cv - -from esphome.components import event - import esphome.codegen as cg - +from esphome.components import event +import esphome.config_validation as cv from esphome.const import CONF_EVENT_TYPES from .. import template_ns diff --git a/esphome/components/template/fan/__init__.py b/esphome/components/template/fan/__init__.py index 348ebd281f..c885866d40 100644 --- a/esphome/components/template/fan/__init__.py +++ b/esphome/components/template/fan/__init__.py @@ -1,12 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import fan from esphome.components.fan import validate_preset_modes -from esphome.const import ( - CONF_OUTPUT_ID, - CONF_PRESET_MODES, - CONF_SPEED_COUNT, -) +import esphome.config_validation as cv +from esphome.const import CONF_OUTPUT_ID, CONF_PRESET_MODES, CONF_SPEED_COUNT from .. import template_ns diff --git a/esphome/components/template/lock/__init__.py b/esphome/components/template/lock/__init__.py index 24709ff4f2..2dcb90e038 100644 --- a/esphome/components/template/lock/__init__.py +++ b/esphome/components/template/lock/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import lock +import esphome.config_validation as cv from esphome.const import ( CONF_ASSUMED_STATE, CONF_ID, @@ -12,6 +12,7 @@ from esphome.const import ( CONF_STATE, CONF_UNLOCK_ACTION, ) + from .. import template_ns TemplateLock = template_ns.class_("TemplateLock", lock.Lock, cg.Component) diff --git a/esphome/components/template/number/__init__.py b/esphome/components/template/number/__init__.py index c6ed25adda..2f4c9cbffe 100644 --- a/esphome/components/template/number/__init__.py +++ b/esphome/components/template/number/__init__.py @@ -1,7 +1,7 @@ from esphome import automation import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import number +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_INITIAL_VALUE, @@ -10,9 +10,10 @@ from esphome.const import ( CONF_MIN_VALUE, CONF_OPTIMISTIC, CONF_RESTORE_VALUE, - CONF_STEP, CONF_SET_ACTION, + CONF_STEP, ) + from .. import template_ns TemplateNumber = template_ns.class_( diff --git a/esphome/components/template/output/__init__.py b/esphome/components/template/output/__init__.py index b42a4be166..2a37fccdbe 100644 --- a/esphome/components/template/output/__init__.py +++ b/esphome/components/template/output/__init__.py @@ -1,8 +1,9 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import output -from esphome.const import CONF_ID, CONF_TYPE, CONF_BINARY +import esphome.config_validation as cv +from esphome.const import CONF_BINARY, CONF_ID, CONF_TYPE + from .. import template_ns TemplateBinaryOutput = template_ns.class_("TemplateBinaryOutput", output.BinaryOutput) diff --git a/esphome/components/template/select/__init__.py b/esphome/components/template/select/__init__.py index 75dbd4f5c5..3282092d63 100644 --- a/esphome/components/template/select/__init__.py +++ b/esphome/components/template/select/__init__.py @@ -1,16 +1,17 @@ from esphome import automation import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import select +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_INITIAL_OPTION, CONF_LAMBDA, - CONF_OPTIONS, CONF_OPTIMISTIC, + CONF_OPTIONS, CONF_RESTORE_VALUE, CONF_SET_ACTION, ) + from .. import template_ns TemplateSelect = template_ns.class_( diff --git a/esphome/components/template/sensor/__init__.py b/esphome/components/template/sensor/__init__.py index 9ed7a83848..2c325427e9 100644 --- a/esphome/components/template/sensor/__init__.py +++ b/esphome/components/template/sensor/__init__.py @@ -1,12 +1,9 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import sensor -from esphome.const import ( - CONF_ID, - CONF_LAMBDA, - CONF_STATE, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_LAMBDA, CONF_STATE + from .. import template_ns TemplateSensor = template_ns.class_( diff --git a/esphome/components/template/switch/__init__.py b/esphome/components/template/switch/__init__.py index a221cbaa60..e86657510f 100644 --- a/esphome/components/template/switch/__init__.py +++ b/esphome/components/template/switch/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import switch +import esphome.config_validation as cv from esphome.const import ( CONF_ASSUMED_STATE, CONF_ID, @@ -12,6 +12,7 @@ from esphome.const import ( CONF_TURN_OFF_ACTION, CONF_TURN_ON_ACTION, ) + from .. import template_ns TemplateSwitch = template_ns.class_("TemplateSwitch", switch.Switch, cg.Component) diff --git a/esphome/components/template/text/__init__.py b/esphome/components/template/text/__init__.py index f73b240197..b0fea38aaf 100644 --- a/esphome/components/template/text/__init__.py +++ b/esphome/components/template/text/__init__.py @@ -1,17 +1,18 @@ from esphome import automation import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text +import esphome.config_validation as cv from esphome.const import ( CONF_INITIAL_VALUE, CONF_LAMBDA, - CONF_OPTIMISTIC, - CONF_RESTORE_VALUE, CONF_MAX_LENGTH, CONF_MIN_LENGTH, + CONF_OPTIMISTIC, CONF_PATTERN, + CONF_RESTORE_VALUE, CONF_SET_ACTION, ) + from .. import template_ns TemplateText = template_ns.class_("TemplateText", text.Text, cg.PollingComponent) diff --git a/esphome/components/template/text_sensor/__init__.py b/esphome/components/template/text_sensor/__init__.py index 9bd603bbca..550b27356d 100644 --- a/esphome/components/template/text_sensor/__init__.py +++ b/esphome/components/template/text_sensor/__init__.py @@ -1,9 +1,10 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import text_sensor from esphome.components.text_sensor import TextSensorPublishAction +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_LAMBDA, CONF_STATE + from .. import template_ns TemplateTextSensor = template_ns.class_( diff --git a/esphome/components/template/valve/__init__.py b/esphome/components/template/valve/__init__.py index 89d776dfdd..12e5174168 100644 --- a/esphome/components/template/valve/__init__.py +++ b/esphome/components/template/valve/__init__.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import valve +import esphome.config_validation as cv from esphome.const import ( CONF_ASSUMED_STATE, CONF_CLOSE_ACTION, @@ -16,6 +16,7 @@ from esphome.const import ( CONF_STATE, CONF_STOP_ACTION, ) + from .. import template_ns TemplateValve = template_ns.class_("TemplateValve", valve.Valve, cg.Component) diff --git a/esphome/components/time_based/cover.py b/esphome/components/time_based/cover.py index a14a08ccad..c723345370 100644 --- a/esphome/components/time_based/cover.py +++ b/esphome/components/time_based/cover.py @@ -1,15 +1,15 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import automation +import esphome.codegen as cg from esphome.components import cover +import esphome.config_validation as cv from esphome.const import ( + CONF_ASSUMED_STATE, CONF_CLOSE_ACTION, CONF_CLOSE_DURATION, CONF_ID, CONF_OPEN_ACTION, CONF_OPEN_DURATION, CONF_STOP_ACTION, - CONF_ASSUMED_STATE, ) time_based_ns = cg.esphome_ns.namespace("time_based") diff --git a/esphome/components/tlc59208f/__init__.py b/esphome/components/tlc59208f/__init__.py index 419fa397b7..b685423787 100644 --- a/esphome/components/tlc59208f/__init__.py +++ b/esphome/components/tlc59208f/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["i2c"] diff --git a/esphome/components/tlc59208f/output.py b/esphome/components/tlc59208f/output.py index ac45909673..a2f4f16554 100644 --- a/esphome/components/tlc59208f/output.py +++ b/esphome/components/tlc59208f/output.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL, CONF_ID + from . import TLC59208FOutput, tlc59208f_ns DEPENDENCIES = ["tlc59208f"] diff --git a/esphome/components/tlc5947/__init__.py b/esphome/components/tlc5947/__init__.py index 528d690fab..20e53893aa 100644 --- a/esphome/components/tlc5947/__init__.py +++ b/esphome/components/tlc5947/__init__.py @@ -1,9 +1,9 @@ # this component is for the "TLC5947 24-Channel, 12-Bit PWM LED Driver" [https://www.ti.com/lit/ds/symlink/tlc5947.pdf], # which is used e.g. on [https://www.adafruit.com/product/1429]. The code is based on the components sm2135 and sm26716. +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins from esphome.const import ( CONF_CLOCK_PIN, CONF_DATA_PIN, diff --git a/esphome/components/tlc5947/output/__init__.py b/esphome/components/tlc5947/output/__init__.py index 1b5dff1854..a1290add81 100644 --- a/esphome/components/tlc5947/output/__init__.py +++ b/esphome/components/tlc5947/output/__init__.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL, CONF_ID + from .. import TLC5947, tlc5947_ns DEPENDENCIES = ["tlc5947"] diff --git a/esphome/components/tlc5971/__init__.py b/esphome/components/tlc5971/__init__.py index 0ff2a5d176..b09924c3d3 100644 --- a/esphome/components/tlc5971/__init__.py +++ b/esphome/components/tlc5971/__init__.py @@ -1,16 +1,10 @@ # this component is for the "TLC5971 12-Channel, 12-Bit PWM LED Driver" [https://www.ti.com/lit/ds/symlink/tlc5971.pdf], # which is used e.g. on [https://www.adafruit.com/product/1455]. The code is based on the TLC5947 component by @rnauber. +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins -from esphome.const import ( - CONF_CLOCK_PIN, - CONF_DATA_PIN, - CONF_ID, - CONF_NUM_CHIPS, -) - +from esphome.const import CONF_CLOCK_PIN, CONF_DATA_PIN, CONF_ID, CONF_NUM_CHIPS CODEOWNERS = ["@IJIJI"] diff --git a/esphome/components/tlc5971/output/__init__.py b/esphome/components/tlc5971/output/__init__.py index 9fe7b18294..ae000ae0a9 100644 --- a/esphome/components/tlc5971/output/__init__.py +++ b/esphome/components/tlc5971/output/__init__.py @@ -1,7 +1,8 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import output +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL, CONF_ID + from .. import TLC5971, tlc5971_ns DEPENDENCIES = ["tlc5971"] diff --git a/esphome/components/tm1621/display.py b/esphome/components/tm1621/display.py index a82b680f62..f521af2842 100644 --- a/esphome/components/tm1621/display.py +++ b/esphome/components/tm1621/display.py @@ -1,10 +1,10 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import display +import esphome.config_validation as cv from esphome.const import ( - CONF_DATA_PIN, CONF_CS_PIN, + CONF_DATA_PIN, CONF_ID, CONF_LAMBDA, CONF_READ_PIN, diff --git a/esphome/components/tm1637/binary_sensor.py b/esphome/components/tm1637/binary_sensor.py index f14b9bd018..817231627a 100644 --- a/esphome/components/tm1637/binary_sensor.py +++ b/esphome/components/tm1637/binary_sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_KEY CONF_TM1637_ID = "tm1637_id" diff --git a/esphome/components/tm1637/display.py b/esphome/components/tm1637/display.py index dcbc64332a..141ee5a39f 100644 --- a/esphome/components/tm1637/display.py +++ b/esphome/components/tm1637/display.py @@ -1,14 +1,14 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import display +import esphome.config_validation as cv from esphome.const import ( CONF_CLK_PIN, CONF_DIO_PIN, CONF_ID, - CONF_LAMBDA, CONF_INTENSITY, CONF_INVERTED, + CONF_LAMBDA, CONF_LENGTH, ) diff --git a/esphome/components/tm1651/__init__.py b/esphome/components/tm1651/__init__.py index 4ef8842571..153cc690e7 100644 --- a/esphome/components/tm1651/__init__.py +++ b/esphome/components/tm1651/__init__.py @@ -1,13 +1,13 @@ +from esphome import automation, pins +from esphome.automation import maybe_simple_id import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins, automation -from esphome.automation import maybe_simple_id from esphome.const import ( - CONF_ID, + CONF_BRIGHTNESS, CONF_CLK_PIN, CONF_DIO_PIN, + CONF_ID, CONF_LEVEL, - CONF_BRIGHTNESS, ) CODEOWNERS = ["@freekode"] diff --git a/esphome/components/tmp102/sensor.py b/esphome/components/tmp102/sensor.py index 2cb1a6d1f5..862d526ccf 100644 --- a/esphome/components/tmp102/sensor.py +++ b/esphome/components/tmp102/sensor.py @@ -9,8 +9,8 @@ https://www.sparkfun.com/datasheets/Sensors/Temperature/tmp102.pdf """ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, diff --git a/esphome/components/tmp1075/sensor.py b/esphome/components/tmp1075/sensor.py index 25ec350b7a..bedeef8e3c 100644 --- a/esphome/components/tmp1075/sensor.py +++ b/esphome/components/tmp1075/sensor.py @@ -1,11 +1,11 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( DEVICE_CLASS_TEMPERATURE, + ICON_THERMOMETER, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, - ICON_THERMOMETER, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/tmp117/sensor.py b/esphome/components/tmp117/sensor.py index 82d099cf12..e906fe0aee 100644 --- a/esphome/components/tmp117/sensor.py +++ b/esphome/components/tmp117/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_UPDATE_INTERVAL, DEVICE_CLASS_TEMPERATURE, diff --git a/esphome/components/tof10120/sensor.py b/esphome/components/tof10120/sensor.py index 21d6d48659..d3aeaa814f 100644 --- a/esphome/components/tof10120/sensor.py +++ b/esphome/components/tof10120/sensor.py @@ -1,10 +1,10 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( + ICON_ARROW_EXPAND_VERTICAL, STATE_CLASS_MEASUREMENT, UNIT_METER, - ICON_ARROW_EXPAND_VERTICAL, ) CODEOWNERS = ["@wstrzalka"] diff --git a/esphome/components/tormatic/cover.py b/esphome/components/tormatic/cover.py index f1cfe09a05..627ae6b63d 100644 --- a/esphome/components/tormatic/cover.py +++ b/esphome/components/tormatic/cover.py @@ -1,11 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import cover, uart -from esphome.const import ( - CONF_CLOSE_DURATION, - CONF_ID, - CONF_OPEN_DURATION, -) +import esphome.config_validation as cv +from esphome.const import CONF_CLOSE_DURATION, CONF_ID, CONF_OPEN_DURATION tormatic_ns = cg.esphome_ns.namespace("tormatic") Tormatic = tormatic_ns.class_("Tormatic", cover.Cover, cg.PollingComponent) diff --git a/esphome/components/toshiba/climate.py b/esphome/components/toshiba/climate.py index 3f2c644c87..54582b78a9 100644 --- a/esphome/components/toshiba/climate.py +++ b/esphome/components/toshiba/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_MODEL AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/total_daily_energy/sensor.py b/esphome/components/total_daily_energy/sensor.py index 45e9c03c1d..f026dc9530 100644 --- a/esphome/components/total_daily_energy/sensor.py +++ b/esphome/components/total_daily_energy/sensor.py @@ -1,16 +1,16 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor, time +import esphome.config_validation as cv from esphome.const import ( + CONF_ACCURACY_DECIMALS, CONF_ICON, CONF_ID, + CONF_METHOD, CONF_RESTORE, CONF_TIME_ID, - DEVICE_CLASS_ENERGY, - CONF_METHOD, - STATE_CLASS_TOTAL_INCREASING, CONF_UNIT_OF_MEASUREMENT, - CONF_ACCURACY_DECIMALS, + DEVICE_CLASS_ENERGY, + STATE_CLASS_TOTAL_INCREASING, ) from esphome.core.entity_helpers import inherit_property_from diff --git a/esphome/components/tsl2561/sensor.py b/esphome/components/tsl2561/sensor.py index fb2c00697b..cd4b88e740 100644 --- a/esphome/components/tsl2561/sensor.py +++ b/esphome/components/tsl2561/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_GAIN, CONF_INTEGRATION_TIME, diff --git a/esphome/components/tsl2591/sensor.py b/esphome/components/tsl2591/sensor.py index 5435ed4b62..0df3fa6687 100644 --- a/esphome/components/tsl2591/sensor.py +++ b/esphome/components/tsl2591/sensor.py @@ -20,23 +20,23 @@ # place: https://hackaday.io/project/176690-the-water-watcher import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_GAIN, CONF_ACTUAL_GAIN, - CONF_ID, - CONF_NAME, - CONF_INTEGRATION_TIME, - CONF_FULL_SPECTRUM, - CONF_INFRARED, - CONF_POWER_SAVE_MODE, - CONF_VISIBLE, CONF_CALCULATED_LUX, CONF_DEVICE_FACTOR, + CONF_FULL_SPECTRUM, + CONF_GAIN, CONF_GLASS_ATTENUATION_FACTOR, - ICON_BRIGHTNESS_6, + CONF_ID, + CONF_INFRARED, + CONF_INTEGRATION_TIME, + CONF_NAME, + CONF_POWER_SAVE_MODE, + CONF_VISIBLE, DEVICE_CLASS_ILLUMINANCE, + ICON_BRIGHTNESS_6, STATE_CLASS_MEASUREMENT, UNIT_LUX, ) diff --git a/esphome/components/tt21100/binary_sensor/__init__.py b/esphome/components/tt21100/binary_sensor/__init__.py index d5423a01b2..f79eff0e01 100644 --- a/esphome/components/tt21100/binary_sensor/__init__.py +++ b/esphome/components/tt21100/binary_sensor/__init__.py @@ -1,10 +1,10 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_INDEX from .. import tt21100_ns -from ..touchscreen import TT21100Touchscreen, TT21100ButtonListener +from ..touchscreen import TT21100ButtonListener, TT21100Touchscreen CONF_TT21100_ID = "tt21100_id" diff --git a/esphome/components/tt21100/touchscreen/__init__.py b/esphome/components/tt21100/touchscreen/__init__.py index 510ca2df3a..9466dcdaa5 100644 --- a/esphome/components/tt21100/touchscreen/__init__.py +++ b/esphome/components/tt21100/touchscreen/__init__.py @@ -1,8 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv - from esphome import pins +import esphome.codegen as cg from esphome.components import i2c, touchscreen +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_INTERRUPT_PIN, CONF_RESET_PIN from .. import tt21100_ns diff --git a/esphome/components/ttp229_bsf/__init__.py b/esphome/components/ttp229_bsf/__init__.py index 9c8208df83..fa1938723d 100644 --- a/esphome/components/ttp229_bsf/__init__.py +++ b/esphome/components/ttp229_bsf/__init__.py @@ -1,7 +1,7 @@ +from esphome import pins import esphome.codegen as cg import esphome.config_validation as cv -from esphome import pins -from esphome.const import CONF_ID, CONF_SDO_PIN, CONF_SCL_PIN +from esphome.const import CONF_ID, CONF_SCL_PIN, CONF_SDO_PIN AUTO_LOAD = ["binary_sensor"] diff --git a/esphome/components/ttp229_bsf/binary_sensor.py b/esphome/components/ttp229_bsf/binary_sensor.py index 8a0c7fce48..178ad4f037 100644 --- a/esphome/components/ttp229_bsf/binary_sensor.py +++ b/esphome/components/ttp229_bsf/binary_sensor.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL -from . import ttp229_bsf_ns, TTP229BSFComponent, CONF_TTP229_ID + +from . import CONF_TTP229_ID, TTP229BSFComponent, ttp229_bsf_ns DEPENDENCIES = ["ttp229_bsf"] TTP229BSFChannel = ttp229_bsf_ns.class_("TTP229BSFChannel", binary_sensor.BinarySensor) diff --git a/esphome/components/ttp229_lsf/__init__.py b/esphome/components/ttp229_lsf/__init__.py index cba41a7938..412233a6bd 100644 --- a/esphome/components/ttp229_lsf/__init__.py +++ b/esphome/components/ttp229_lsf/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["i2c"] diff --git a/esphome/components/ttp229_lsf/binary_sensor.py b/esphome/components/ttp229_lsf/binary_sensor.py index 5fba0096de..07f00df4b4 100644 --- a/esphome/components/ttp229_lsf/binary_sensor.py +++ b/esphome/components/ttp229_lsf/binary_sensor.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import CONF_CHANNEL -from . import ttp229_lsf_ns, TTP229LSFComponent, CONF_TTP229_ID + +from . import CONF_TTP229_ID, TTP229LSFComponent, ttp229_lsf_ns DEPENDENCIES = ["ttp229_lsf"] TTP229Channel = ttp229_lsf_ns.class_("TTP229Channel", binary_sensor.BinarySensor) diff --git a/esphome/components/tuya/__init__.py b/esphome/components/tuya/__init__.py index 0738f9b6a4..2cc60e225c 100644 --- a/esphome/components/tuya/__init__.py +++ b/esphome/components/tuya/__init__.py @@ -1,10 +1,8 @@ -from esphome.components import time -from esphome import automation -from esphome import pins +from esphome import automation, pins import esphome.codegen as cg +from esphome.components import time, uart import esphome.config_validation as cv -from esphome.components import uart -from esphome.const import CONF_ID, CONF_TIME_ID, CONF_TRIGGER_ID, CONF_SENSOR_DATAPOINT +from esphome.const import CONF_ID, CONF_SENSOR_DATAPOINT, CONF_TIME_ID, CONF_TRIGGER_ID DEPENDENCIES = ["uart"] diff --git a/esphome/components/tuya/binary_sensor/__init__.py b/esphome/components/tuya/binary_sensor/__init__.py index 856b5eb323..767d1c636e 100644 --- a/esphome/components/tuya/binary_sensor/__init__.py +++ b/esphome/components/tuya/binary_sensor/__init__.py @@ -1,9 +1,9 @@ +import esphome.codegen as cg from esphome.components import binary_sensor import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import CONF_SENSOR_DATAPOINT -from .. import tuya_ns, CONF_TUYA_ID, Tuya +from .. import CONF_TUYA_ID, Tuya, tuya_ns DEPENDENCIES = ["tuya"] CODEOWNERS = ["@jesserockz"] diff --git a/esphome/components/tuya/climate/__init__.py b/esphome/components/tuya/climate/__init__.py index 363e7c764b..371c599ef7 100644 --- a/esphome/components/tuya/climate/__init__.py +++ b/esphome/components/tuya/climate/__init__.py @@ -1,18 +1,19 @@ from esphome import pins +import esphome.codegen as cg from esphome.components import climate import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import ( + CONF_FAN_MODE, CONF_ID, - CONF_SWITCH_DATAPOINT, + CONF_PRESET, CONF_SUPPORTS_COOL, CONF_SUPPORTS_HEAT, - CONF_PRESET, CONF_SWING_MODE, - CONF_FAN_MODE, + CONF_SWITCH_DATAPOINT, CONF_TEMPERATURE, ) -from .. import tuya_ns, CONF_TUYA_ID, Tuya + +from .. import CONF_TUYA_ID, Tuya, tuya_ns DEPENDENCIES = ["tuya"] CODEOWNERS = ["@jesserockz"] diff --git a/esphome/components/tuya/cover/__init__.py b/esphome/components/tuya/cover/__init__.py index 2dd66f814d..61029b6daa 100644 --- a/esphome/components/tuya/cover/__init__.py +++ b/esphome/components/tuya/cover/__init__.py @@ -1,13 +1,14 @@ +import esphome.codegen as cg from esphome.components import cover import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import ( - CONF_OUTPUT_ID, - CONF_MIN_VALUE, CONF_MAX_VALUE, + CONF_MIN_VALUE, + CONF_OUTPUT_ID, CONF_RESTORE_MODE, ) -from .. import tuya_ns, CONF_TUYA_ID, Tuya + +from .. import CONF_TUYA_ID, Tuya, tuya_ns DEPENDENCIES = ["tuya"] diff --git a/esphome/components/tuya/fan/__init__.py b/esphome/components/tuya/fan/__init__.py index 4832fd8638..c732bdaf31 100644 --- a/esphome/components/tuya/fan/__init__.py +++ b/esphome/components/tuya/fan/__init__.py @@ -1,8 +1,9 @@ +import esphome.codegen as cg from esphome.components import fan import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import CONF_OUTPUT_ID, CONF_SPEED_COUNT, CONF_SWITCH_DATAPOINT -from .. import tuya_ns, CONF_TUYA_ID, Tuya + +from .. import CONF_TUYA_ID, Tuya, tuya_ns DEPENDENCIES = ["tuya"] diff --git a/esphome/components/tuya/light/__init__.py b/esphome/components/tuya/light/__init__.py index d806060018..1d2286e3c7 100644 --- a/esphome/components/tuya/light/__init__.py +++ b/esphome/components/tuya/light/__init__.py @@ -1,18 +1,19 @@ +import esphome.codegen as cg from esphome.components import light import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import ( - CONF_OUTPUT_ID, - CONF_MIN_VALUE, - CONF_MAX_VALUE, - CONF_GAMMA_CORRECT, - CONF_DEFAULT_TRANSITION_LENGTH, - CONF_SWITCH_DATAPOINT, CONF_COLD_WHITE_COLOR_TEMPERATURE, - CONF_WARM_WHITE_COLOR_TEMPERATURE, CONF_COLOR_INTERLOCK, + CONF_DEFAULT_TRANSITION_LENGTH, + CONF_GAMMA_CORRECT, + CONF_MAX_VALUE, + CONF_MIN_VALUE, + CONF_OUTPUT_ID, + CONF_SWITCH_DATAPOINT, + CONF_WARM_WHITE_COLOR_TEMPERATURE, ) -from .. import tuya_ns, CONF_TUYA_ID, Tuya + +from .. import CONF_TUYA_ID, Tuya, tuya_ns DEPENDENCIES = ["tuya"] diff --git a/esphome/components/tuya/number/__init__.py b/esphome/components/tuya/number/__init__.py index c00ea08d23..bd57c8be14 100644 --- a/esphome/components/tuya/number/__init__.py +++ b/esphome/components/tuya/number/__init__.py @@ -1,17 +1,18 @@ +import esphome.codegen as cg from esphome.components import number import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import ( CONF_ID, - CONF_NUMBER_DATAPOINT, + CONF_INITIAL_VALUE, CONF_MAX_VALUE, CONF_MIN_VALUE, CONF_MULTIPLY, - CONF_STEP, - CONF_INITIAL_VALUE, + CONF_NUMBER_DATAPOINT, CONF_RESTORE_VALUE, + CONF_STEP, ) -from .. import tuya_ns, CONF_TUYA_ID, Tuya, TuyaDatapointType + +from .. import CONF_TUYA_ID, Tuya, TuyaDatapointType, tuya_ns DEPENDENCIES = ["tuya"] CODEOWNERS = ["@frankiboy1"] diff --git a/esphome/components/tuya/select/__init__.py b/esphome/components/tuya/select/__init__.py index dc78b2c3db..a34e279746 100644 --- a/esphome/components/tuya/select/__init__.py +++ b/esphome/components/tuya/select/__init__.py @@ -1,8 +1,9 @@ +import esphome.codegen as cg from esphome.components import select import esphome.config_validation as cv -import esphome.codegen as cg -from esphome.const import CONF_OPTIONS, CONF_OPTIMISTIC, CONF_ENUM_DATAPOINT -from .. import tuya_ns, CONF_TUYA_ID, Tuya +from esphome.const import CONF_ENUM_DATAPOINT, CONF_OPTIMISTIC, CONF_OPTIONS + +from .. import CONF_TUYA_ID, Tuya, tuya_ns DEPENDENCIES = ["tuya"] CODEOWNERS = ["@bearpawmaxim"] diff --git a/esphome/components/tuya/sensor/__init__.py b/esphome/components/tuya/sensor/__init__.py index 69711204a8..861bbc656a 100644 --- a/esphome/components/tuya/sensor/__init__.py +++ b/esphome/components/tuya/sensor/__init__.py @@ -1,8 +1,9 @@ +import esphome.codegen as cg from esphome.components import sensor import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import CONF_ID, CONF_SENSOR_DATAPOINT -from .. import tuya_ns, CONF_TUYA_ID, Tuya + +from .. import CONF_TUYA_ID, Tuya, tuya_ns DEPENDENCIES = ["tuya"] CODEOWNERS = ["@jesserockz"] diff --git a/esphome/components/tuya/switch/__init__.py b/esphome/components/tuya/switch/__init__.py index b4ec53ec59..e9987050cb 100644 --- a/esphome/components/tuya/switch/__init__.py +++ b/esphome/components/tuya/switch/__init__.py @@ -1,8 +1,9 @@ +import esphome.codegen as cg from esphome.components import switch import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import CONF_SWITCH_DATAPOINT -from .. import tuya_ns, CONF_TUYA_ID, Tuya + +from .. import CONF_TUYA_ID, Tuya, tuya_ns DEPENDENCIES = ["tuya"] CODEOWNERS = ["@jesserockz"] diff --git a/esphome/components/tuya/text_sensor/__init__.py b/esphome/components/tuya/text_sensor/__init__.py index bc60369377..3bae109b93 100644 --- a/esphome/components/tuya/text_sensor/__init__.py +++ b/esphome/components/tuya/text_sensor/__init__.py @@ -1,8 +1,9 @@ +import esphome.codegen as cg from esphome.components import text_sensor import esphome.config_validation as cv -import esphome.codegen as cg from esphome.const import CONF_SENSOR_DATAPOINT -from .. import tuya_ns, CONF_TUYA_ID, Tuya + +from .. import CONF_TUYA_ID, Tuya, tuya_ns DEPENDENCIES = ["tuya"] CODEOWNERS = ["@dentra"] diff --git a/esphome/components/tx20/sensor.py b/esphome/components/tx20/sensor.py index f8a0b08d99..4f1582072e 100644 --- a/esphome/components/tx20/sensor.py +++ b/esphome/components/tx20/sensor.py @@ -1,17 +1,17 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, - CONF_WIND_SPEED, CONF_PIN, CONF_WIND_DIRECTION_DEGREES, - STATE_CLASS_MEASUREMENT, - UNIT_KILOMETER_PER_HOUR, - ICON_WEATHER_WINDY, + CONF_WIND_SPEED, ICON_SIGN_DIRECTION, + ICON_WEATHER_WINDY, + STATE_CLASS_MEASUREMENT, UNIT_DEGREES, + UNIT_KILOMETER_PER_HOUR, ) tx20_ns = cg.esphome_ns.namespace("tx20") diff --git a/esphome/components/uart/__init__.py b/esphome/components/uart/__init__.py index 0738a127e1..bee037774f 100644 --- a/esphome/components/uart/__init__.py +++ b/esphome/components/uart/__init__.py @@ -1,36 +1,37 @@ -from typing import Optional import re +from typing import Optional + +from esphome import automation, pins import esphome.codegen as cg import esphome.config_validation as cv -import esphome.final_validate as fv -from esphome.yaml_util import make_data_base -from esphome import pins, automation from esphome.const import ( - CONF_BAUD_RATE, - CONF_ID, - CONF_NUMBER, - CONF_RX_PIN, - CONF_TX_PIN, - CONF_PORT, - CONF_UART_ID, - CONF_DATA, - CONF_RX_BUFFER_SIZE, - CONF_INVERTED, - CONF_INVERT, - CONF_TRIGGER_ID, - CONF_SEQUENCE, - CONF_TIMEOUT, - CONF_DEBUG, - CONF_DIRECTION, CONF_AFTER, + CONF_BAUD_RATE, CONF_BYTES, + CONF_DATA, + CONF_DEBUG, CONF_DELIMITER, + CONF_DIRECTION, CONF_DUMMY_RECEIVER, CONF_DUMMY_RECEIVER_ID, + CONF_ID, + CONF_INVERT, + CONF_INVERTED, CONF_LAMBDA, + CONF_NUMBER, + CONF_PORT, + CONF_RX_BUFFER_SIZE, + CONF_RX_PIN, + CONF_SEQUENCE, + CONF_TIMEOUT, + CONF_TRIGGER_ID, + CONF_TX_PIN, + CONF_UART_ID, PLATFORM_HOST, ) from esphome.core import CORE +import esphome.final_validate as fv +from esphome.yaml_util import make_data_base CODEOWNERS = ["@esphome/core"] uart_ns = cg.esphome_ns.namespace("uart") diff --git a/esphome/components/uart/button/__init__.py b/esphome/components/uart/button/__init__.py index 05909516a0..5b811de07d 100644 --- a/esphome/components/uart/button/__init__.py +++ b/esphome/components/uart/button/__init__.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import button, uart +import esphome.config_validation as cv from esphome.const import CONF_DATA from esphome.core import HexInt + from .. import uart_ns, validate_raw_data CODEOWNERS = ["@ssieb"] diff --git a/esphome/components/uart/switch/__init__.py b/esphome/components/uart/switch/__init__.py index 8853a61ae3..b25e070461 100644 --- a/esphome/components/uart/switch/__init__.py +++ b/esphome/components/uart/switch/__init__.py @@ -1,8 +1,9 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import switch, uart +import esphome.config_validation as cv from esphome.const import CONF_DATA, CONF_SEND_EVERY from esphome.core import HexInt + from .. import uart_ns, validate_raw_data DEPENDENCIES = ["uart"] diff --git a/esphome/components/ufire_ise/sensor.py b/esphome/components/ufire_ise/sensor.py index 8f4359d6af..e57a1155a4 100644 --- a/esphome/components/ufire_ise/sensor.py +++ b/esphome/components/ufire_ise/sensor.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg from esphome import automation -import esphome.config_validation as cv +import esphome.codegen as cg from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_PH, diff --git a/esphome/components/uln2003/stepper.py b/esphome/components/uln2003/stepper.py index 88252ead73..b57d7ffb92 100644 --- a/esphome/components/uln2003/stepper.py +++ b/esphome/components/uln2003/stepper.py @@ -1,7 +1,7 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import stepper +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_PIN_A, diff --git a/esphome/components/ultrasonic/sensor.py b/esphome/components/ultrasonic/sensor.py index afbd1128c2..937d9a5261 100644 --- a/esphome/components/ultrasonic/sensor.py +++ b/esphome/components/ultrasonic/sensor.py @@ -1,14 +1,14 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ECHO_PIN, - CONF_TRIGGER_PIN, CONF_TIMEOUT, + CONF_TRIGGER_PIN, + ICON_ARROW_EXPAND_VERTICAL, STATE_CLASS_MEASUREMENT, UNIT_METER, - ICON_ARROW_EXPAND_VERTICAL, ) CONF_PULSE_TIME = "pulse_time" diff --git a/esphome/components/uponor_smatrix/__init__.py b/esphome/components/uponor_smatrix/__init__.py index 35c4c4cecd..d4102d1026 100644 --- a/esphome/components/uponor_smatrix/__init__.py +++ b/esphome/components/uponor_smatrix/__init__.py @@ -1,11 +1,7 @@ import esphome.codegen as cg +from esphome.components import time, uart import esphome.config_validation as cv -from esphome.components import uart, time -from esphome.const import ( - CONF_ADDRESS, - CONF_ID, - CONF_TIME_ID, -) +from esphome.const import CONF_ADDRESS, CONF_ID, CONF_TIME_ID CODEOWNERS = ["@kroimon"] diff --git a/esphome/components/uponor_smatrix/climate/__init__.py b/esphome/components/uponor_smatrix/climate/__init__.py index 0becec2624..5aeb521fb1 100644 --- a/esphome/components/uponor_smatrix/climate/__init__.py +++ b/esphome/components/uponor_smatrix/climate/__init__.py @@ -1,13 +1,13 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate +import esphome.config_validation as cv from esphome.const import CONF_ID from .. import ( - uponor_smatrix_ns, - UponorSmatrixDevice, UPONOR_SMATRIX_DEVICE_SCHEMA, + UponorSmatrixDevice, register_uponor_smatrix_device, + uponor_smatrix_ns, ) DEPENDENCIES = ["uponor_smatrix"] diff --git a/esphome/components/vbus/__init__.py b/esphome/components/vbus/__init__.py index 99a473a3dc..d916d7c064 100644 --- a/esphome/components/vbus/__init__.py +++ b/esphome/components/vbus/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import uart +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@ssieb"] diff --git a/esphome/components/vbus/binary_sensor/__init__.py b/esphome/components/vbus/binary_sensor/__init__.py index 70fbda2d1f..ae927656c0 100644 --- a/esphome/components/vbus/binary_sensor/__init__.py +++ b/esphome/components/vbus/binary_sensor/__init__.py @@ -1,27 +1,28 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_BINARY_SENSORS, CONF_COMMAND, CONF_CUSTOM, CONF_DEST, + CONF_ID, CONF_LAMBDA, CONF_MODEL, CONF_SOURCE, DEVICE_CLASS_PROBLEM, ENTITY_CATEGORY_DIAGNOSTIC, ) + from .. import ( - vbus_ns, - VBus, - CONF_VBUS_ID, - CONF_DELTASOL_BS_PLUS, CONF_DELTASOL_BS_2009, + CONF_DELTASOL_BS_PLUS, CONF_DELTASOL_C, CONF_DELTASOL_CS2, CONF_DELTASOL_CS_PLUS, + CONF_VBUS_ID, + VBus, + vbus_ns, ) DeltaSol_BS_Plus = vbus_ns.class_("DeltaSolBSPlusBSensor", cg.Component) diff --git a/esphome/components/vbus/sensor/__init__.py b/esphome/components/vbus/sensor/__init__.py index 2b89da6d32..fcff698ac0 100644 --- a/esphome/components/vbus/sensor/__init__.py +++ b/esphome/components/vbus/sensor/__init__.py @@ -1,11 +1,11 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_COMMAND, CONF_CUSTOM, CONF_DEST, + CONF_ID, CONF_LAMBDA, CONF_MODEL, CONF_SENSORS, @@ -29,15 +29,16 @@ from esphome.const import ( UNIT_PERCENT, UNIT_WATT_HOURS, ) + from .. import ( - vbus_ns, - VBus, - CONF_VBUS_ID, - CONF_DELTASOL_BS_PLUS, CONF_DELTASOL_BS_2009, + CONF_DELTASOL_BS_PLUS, CONF_DELTASOL_C, CONF_DELTASOL_CS2, CONF_DELTASOL_CS_PLUS, + CONF_VBUS_ID, + VBus, + vbus_ns, ) DeltaSol_BS_Plus = vbus_ns.class_("DeltaSolBSPlusSensor", cg.Component) diff --git a/esphome/components/veml3235/sensor.py b/esphome/components/veml3235/sensor.py index 79ba510e41..862fac302f 100644 --- a/esphome/components/veml3235/sensor.py +++ b/esphome/components/veml3235/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_GAIN, CONF_INTEGRATION_TIME, diff --git a/esphome/components/veml7700/sensor.py b/esphome/components/veml7700/sensor.py index 308f1c1c00..6ad2eb417f 100644 --- a/esphome/components/veml7700/sensor.py +++ b/esphome/components/veml7700/sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( CONF_ACTUAL_GAIN, CONF_ACTUAL_INTEGRATION_TIME, diff --git a/esphome/components/version/text_sensor.py b/esphome/components/version/text_sensor.py index c8774bb322..ba8c493d4b 100644 --- a/esphome/components/version/text_sensor.py +++ b/esphome/components/version/text_sensor.py @@ -1,11 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor -from esphome.const import ( - ENTITY_CATEGORY_DIAGNOSTIC, - ICON_NEW_BOX, - CONF_HIDE_TIMESTAMP, -) +import esphome.config_validation as cv +from esphome.const import CONF_HIDE_TIMESTAMP, ENTITY_CATEGORY_DIAGNOSTIC, ICON_NEW_BOX version_ns = cg.esphome_ns.namespace("version") VersionTextSensor = version_ns.class_( diff --git a/esphome/components/vl53l0x/sensor.py b/esphome/components/vl53l0x/sensor.py index 7b485e3887..8055d5ff77 100644 --- a/esphome/components/vl53l0x/sensor.py +++ b/esphome/components/vl53l0x/sensor.py @@ -1,15 +1,15 @@ +from esphome import pins import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_ADDRESS, + CONF_ENABLE_PIN, + CONF_TIMEOUT, + ICON_ARROW_EXPAND_VERTICAL, STATE_CLASS_MEASUREMENT, UNIT_METER, - ICON_ARROW_EXPAND_VERTICAL, - CONF_ADDRESS, - CONF_TIMEOUT, - CONF_ENABLE_PIN, ) -from esphome import pins DEPENDENCIES = ["i2c"] diff --git a/esphome/components/web_server_base/__init__.py b/esphome/components/web_server_base/__init__.py index 115f521d04..f50ee59b9c 100644 --- a/esphome/components/web_server_base/__init__.py +++ b/esphome/components/web_server_base/__init__.py @@ -1,7 +1,7 @@ -import esphome.config_validation as cv import esphome.codegen as cg +import esphome.config_validation as cv from esphome.const import CONF_ID -from esphome.core import coroutine_with_priority, CORE +from esphome.core import CORE, coroutine_with_priority CODEOWNERS = ["@OttoWinter"] DEPENDENCIES = ["network"] diff --git a/esphome/components/web_server_idf/__init__.py b/esphome/components/web_server_idf/__init__.py index a84d9bb663..73c51f8cb5 100644 --- a/esphome/components/web_server_idf/__init__.py +++ b/esphome/components/web_server_idf/__init__.py @@ -1,5 +1,5 @@ -import esphome.config_validation as cv from esphome.components.esp32 import add_idf_sdkconfig_option +import esphome.config_validation as cv CODEOWNERS = ["@dentra"] diff --git a/esphome/components/weikai/__init__.py b/esphome/components/weikai/__init__.py index 4248c48e35..4c8f7e700d 100644 --- a/esphome/components/weikai/__init__.py +++ b/esphome/components/weikai/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import uart +import esphome.config_validation as cv from esphome.const import ( CONF_BAUD_RATE, CONF_CHANNEL, diff --git a/esphome/components/whirlpool/climate.py b/esphome/components/whirlpool/climate.py index c5b953c46f..40c6053349 100644 --- a/esphome/components/whirlpool/climate.py +++ b/esphome/components/whirlpool/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_MODEL AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/whynter/climate.py b/esphome/components/whynter/climate.py index 1d576344e6..ae21c64e9b 100644 --- a/esphome/components/whynter/climate.py +++ b/esphome/components/whynter/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_USE_FAHRENHEIT AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/wireguard/binary_sensor.py b/esphome/components/wireguard/binary_sensor.py index 7344558659..02c4862e8d 100644 --- a/esphome/components/wireguard/binary_sensor.py +++ b/esphome/components/wireguard/binary_sensor.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import ( CONF_STATUS, DEVICE_CLASS_CONNECTIVITY, diff --git a/esphome/components/wireguard/sensor.py b/esphome/components/wireguard/sensor.py index 85703d24b3..4c9d601eee 100644 --- a/esphome/components/wireguard/sensor.py +++ b/esphome/components/wireguard/sensor.py @@ -1,10 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor -from esphome.const import ( - DEVICE_CLASS_TIMESTAMP, - ENTITY_CATEGORY_DIAGNOSTIC, -) +import esphome.config_validation as cv +from esphome.const import DEVICE_CLASS_TIMESTAMP, ENTITY_CATEGORY_DIAGNOSTIC from . import CONF_WIREGUARD_ID, Wireguard diff --git a/esphome/components/wireguard/text_sensor.py b/esphome/components/wireguard/text_sensor.py index 51614a1a28..e48678f5bf 100644 --- a/esphome/components/wireguard/text_sensor.py +++ b/esphome/components/wireguard/text_sensor.py @@ -1,10 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor -from esphome.const import ( - CONF_ADDRESS, - ENTITY_CATEGORY_DIAGNOSTIC, -) +import esphome.config_validation as cv +from esphome.const import CONF_ADDRESS, ENTITY_CATEGORY_DIAGNOSTIC from . import CONF_WIREGUARD_ID, Wireguard diff --git a/esphome/components/wk2132_i2c/__init__.py b/esphome/components/wk2132_i2c/__init__.py index 912ab04236..903fe8fe4f 100644 --- a/esphome/components/wk2132_i2c/__init__.py +++ b/esphome/components/wk2132_i2c/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, weikai +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@DrCoolZic"] diff --git a/esphome/components/wk2132_spi/__init__.py b/esphome/components/wk2132_spi/__init__.py index 02c5fd9604..debc84f6d8 100644 --- a/esphome/components/wk2132_spi/__init__.py +++ b/esphome/components/wk2132_spi/__init__.py @@ -1,7 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import spi, weikai - +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@DrCoolZic"] diff --git a/esphome/components/wk2168_i2c/__init__.py b/esphome/components/wk2168_i2c/__init__.py index 93a8161e8e..32fd4882db 100644 --- a/esphome/components/wk2168_i2c/__init__.py +++ b/esphome/components/wk2168_i2c/__init__.py @@ -1,13 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import i2c, weikai -from esphome.const import ( - CONF_ID, - CONF_INVERTED, - CONF_MODE, - CONF_NUMBER, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_INVERTED, CONF_MODE, CONF_NUMBER CODEOWNERS = ["@DrCoolZic"] DEPENDENCIES = ["i2c"] diff --git a/esphome/components/wk2168_spi/__init__.py b/esphome/components/wk2168_spi/__init__.py index 8861a6738c..123ce0bb8b 100644 --- a/esphome/components/wk2168_spi/__init__.py +++ b/esphome/components/wk2168_spi/__init__.py @@ -1,13 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import spi, weikai -from esphome.const import ( - CONF_ID, - CONF_INVERTED, - CONF_MODE, - CONF_NUMBER, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_INVERTED, CONF_MODE, CONF_NUMBER CODEOWNERS = ["@DrCoolZic"] DEPENDENCIES = ["spi"] diff --git a/esphome/components/wk2204_i2c/__init__.py b/esphome/components/wk2204_i2c/__init__.py index 98eca56c4d..a52aa30cc9 100644 --- a/esphome/components/wk2204_i2c/__init__.py +++ b/esphome/components/wk2204_i2c/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, weikai +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@DrCoolZic"] diff --git a/esphome/components/wk2204_spi/__init__.py b/esphome/components/wk2204_spi/__init__.py index 447805375d..616ba75c59 100644 --- a/esphome/components/wk2204_spi/__init__.py +++ b/esphome/components/wk2204_spi/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import spi, weikai +import esphome.config_validation as cv from esphome.const import CONF_ID CODEOWNERS = ["@DrCoolZic"] diff --git a/esphome/components/wk2212_i2c/__init__.py b/esphome/components/wk2212_i2c/__init__.py index fd4d717b31..0ef32cbc96 100644 --- a/esphome/components/wk2212_i2c/__init__.py +++ b/esphome/components/wk2212_i2c/__init__.py @@ -1,13 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import i2c, weikai -from esphome.const import ( - CONF_ID, - CONF_INVERTED, - CONF_MODE, - CONF_NUMBER, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_INVERTED, CONF_MODE, CONF_NUMBER CODEOWNERS = ["@DrCoolZic"] DEPENDENCIES = ["i2c"] diff --git a/esphome/components/wk2212_spi/__init__.py b/esphome/components/wk2212_spi/__init__.py index bfeca87c22..8c9bea5416 100644 --- a/esphome/components/wk2212_spi/__init__.py +++ b/esphome/components/wk2212_spi/__init__.py @@ -1,13 +1,8 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import spi, weikai -from esphome.const import ( - CONF_ID, - CONF_INVERTED, - CONF_MODE, - CONF_NUMBER, -) +import esphome.config_validation as cv +from esphome.const import CONF_ID, CONF_INVERTED, CONF_MODE, CONF_NUMBER CODEOWNERS = ["@DrCoolZic"] DEPENDENCIES = ["spi"] diff --git a/esphome/components/wl_134/text_sensor.py b/esphome/components/wl_134/text_sensor.py index 1373df77f4..d10627ab64 100644 --- a/esphome/components/wl_134/text_sensor.py +++ b/esphome/components/wl_134/text_sensor.py @@ -1,9 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import text_sensor, uart -from esphome.const import ( - ICON_FINGERPRINT, -) +import esphome.config_validation as cv +from esphome.const import ICON_FINGERPRINT CODEOWNERS = ["@hobbypunk90"] DEPENDENCIES = ["uart"] diff --git a/esphome/components/wled/__init__.py b/esphome/components/wled/__init__.py index 396d5891d8..fb20a03010 100644 --- a/esphome/components/wled/__init__.py +++ b/esphome/components/wled/__init__.py @@ -1,7 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv -from esphome.components.light.types import AddressableLightEffect from esphome.components.light.effects import register_addressable_effect +from esphome.components.light.types import AddressableLightEffect +import esphome.config_validation as cv from esphome.const import CONF_NAME, CONF_PORT wled_ns = cg.esphome_ns.namespace("wled") diff --git a/esphome/components/x9c/output.py b/esphome/components/x9c/output.py index 4497994982..0cc850b856 100644 --- a/esphome/components/x9c/output.py +++ b/esphome/components/x9c/output.py @@ -1,14 +1,14 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import output +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_CS_PIN, + CONF_ID, CONF_INC_PIN, - CONF_UD_PIN, CONF_INITIAL_VALUE, CONF_STEP_DELAY, + CONF_UD_PIN, ) CODEOWNERS = ["@EtienneMD"] diff --git a/esphome/components/xgzp68xx/sensor.py b/esphome/components/xgzp68xx/sensor.py index 3e381aaa61..74cef3bf7b 100644 --- a/esphome/components/xgzp68xx/sensor.py +++ b/esphome/components/xgzp68xx/sensor.py @@ -1,15 +1,15 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor +import esphome.config_validation as cv from esphome.const import ( - DEVICE_CLASS_PRESSURE, CONF_ID, + CONF_PRESSURE, + CONF_TEMPERATURE, + DEVICE_CLASS_PRESSURE, DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, - UNIT_PASCAL, UNIT_CELSIUS, - CONF_TEMPERATURE, - CONF_PRESSURE, + UNIT_PASCAL, ) DEPENDENCIES = ["i2c"] diff --git a/esphome/components/xiaomi_ble/__init__.py b/esphome/components/xiaomi_ble/__init__.py index 046adc6248..541a0e7894 100644 --- a/esphome/components/xiaomi_ble/__init__.py +++ b/esphome/components/xiaomi_ble/__init__.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import esp32_ble_tracker +import esphome.config_validation as cv from esphome.const import CONF_ID DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_cgd1/sensor.py b/esphome/components/xiaomi_cgd1/sensor.py index 5b88121d7c..e11ddac19d 100644 --- a/esphome/components/xiaomi_cgd1/sensor.py +++ b/esphome/components/xiaomi_cgd1/sensor.py @@ -1,12 +1,13 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, + CONF_BINDKEY, CONF_HUMIDITY, + CONF_ID, CONF_MAC_ADDRESS, CONF_TEMPERATURE, - CONF_ID, DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, @@ -14,7 +15,6 @@ from esphome.const import ( STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - CONF_BINDKEY, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_cgdk2/sensor.py b/esphome/components/xiaomi_cgdk2/sensor.py index ac487d87fc..c7ec13f6e0 100644 --- a/esphome/components/xiaomi_cgdk2/sensor.py +++ b/esphome/components/xiaomi_cgdk2/sensor.py @@ -1,9 +1,11 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, + CONF_BINDKEY, CONF_HUMIDITY, + CONF_ID, CONF_MAC_ADDRESS, CONF_TEMPERATURE, DEVICE_CLASS_BATTERY, @@ -13,8 +15,6 @@ from esphome.const import ( STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - CONF_ID, - CONF_BINDKEY, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_cgg1/sensor.py b/esphome/components/xiaomi_cgg1/sensor.py index a4f9a39aff..1a6ed2b7da 100644 --- a/esphome/components/xiaomi_cgg1/sensor.py +++ b/esphome/components/xiaomi_cgg1/sensor.py @@ -1,13 +1,13 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, CONF_BINDKEY, CONF_HUMIDITY, + CONF_ID, CONF_MAC_ADDRESS, CONF_TEMPERATURE, - CONF_ID, DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, diff --git a/esphome/components/xiaomi_cgpr1/binary_sensor.py b/esphome/components/xiaomi_cgpr1/binary_sensor.py index 1b878ca800..2f71a11b28 100644 --- a/esphome/components/xiaomi_cgpr1/binary_sensor.py +++ b/esphome/components/xiaomi_cgpr1/binary_sensor.py @@ -1,20 +1,20 @@ import esphome.codegen as cg +from esphome.components import binary_sensor, esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, binary_sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, CONF_BINDKEY, + CONF_IDLE_TIME, + CONF_ILLUMINANCE, CONF_MAC_ADDRESS, DEVICE_CLASS_BATTERY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_MOTION, ENTITY_CATEGORY_DIAGNOSTIC, - UNIT_PERCENT, - CONF_IDLE_TIME, - CONF_ILLUMINANCE, - UNIT_MINUTE, - UNIT_LUX, ICON_TIMELAPSE, + UNIT_LUX, + UNIT_MINUTE, + UNIT_PERCENT, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_gcls002/sensor.py b/esphome/components/xiaomi_gcls002/sensor.py index 4154b64233..6c9ad2e361 100644 --- a/esphome/components/xiaomi_gcls002/sensor.py +++ b/esphome/components/xiaomi_gcls002/sensor.py @@ -1,22 +1,22 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( + CONF_CONDUCTIVITY, + CONF_ID, + CONF_ILLUMINANCE, CONF_MAC_ADDRESS, + CONF_MOISTURE, CONF_TEMPERATURE, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_TEMPERATURE, + ICON_FLOWER, ICON_WATER_PERCENT, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, - UNIT_PERCENT, - CONF_ID, - CONF_MOISTURE, - CONF_ILLUMINANCE, UNIT_LUX, - CONF_CONDUCTIVITY, UNIT_MICROSIEMENS_PER_CENTIMETER, - ICON_FLOWER, + UNIT_PERCENT, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_hhccjcy01/sensor.py b/esphome/components/xiaomi_hhccjcy01/sensor.py index 535316e246..90a8753412 100644 --- a/esphome/components/xiaomi_hhccjcy01/sensor.py +++ b/esphome/components/xiaomi_hhccjcy01/sensor.py @@ -1,25 +1,25 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( + CONF_BATTERY_LEVEL, + CONF_CONDUCTIVITY, + CONF_ID, + CONF_ILLUMINANCE, CONF_MAC_ADDRESS, + CONF_MOISTURE, CONF_TEMPERATURE, + DEVICE_CLASS_BATTERY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_TEMPERATURE, ENTITY_CATEGORY_DIAGNOSTIC, + ICON_FLOWER, ICON_WATER_PERCENT, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, - UNIT_PERCENT, - CONF_ID, - CONF_MOISTURE, - CONF_ILLUMINANCE, UNIT_LUX, - CONF_CONDUCTIVITY, UNIT_MICROSIEMENS_PER_CENTIMETER, - ICON_FLOWER, - DEVICE_CLASS_BATTERY, - CONF_BATTERY_LEVEL, + UNIT_PERCENT, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_hhccjcy10/sensor.py b/esphome/components/xiaomi_hhccjcy10/sensor.py index 4f77fa8103..d6a4a4adb2 100644 --- a/esphome/components/xiaomi_hhccjcy10/sensor.py +++ b/esphome/components/xiaomi_hhccjcy10/sensor.py @@ -1,25 +1,25 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( + CONF_BATTERY_LEVEL, + CONF_CONDUCTIVITY, + CONF_ID, + CONF_ILLUMINANCE, CONF_MAC_ADDRESS, + CONF_MOISTURE, CONF_TEMPERATURE, + DEVICE_CLASS_BATTERY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_TEMPERATURE, ENTITY_CATEGORY_DIAGNOSTIC, + ICON_FLOWER, ICON_WATER_PERCENT, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, - UNIT_PERCENT, - CONF_ID, - CONF_MOISTURE, - CONF_ILLUMINANCE, UNIT_LUX, - CONF_CONDUCTIVITY, UNIT_MICROSIEMENS_PER_CENTIMETER, - ICON_FLOWER, - DEVICE_CLASS_BATTERY, - CONF_BATTERY_LEVEL, + UNIT_PERCENT, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_hhccpot002/sensor.py b/esphome/components/xiaomi_hhccpot002/sensor.py index 82ee12d8d1..adc64f6650 100644 --- a/esphome/components/xiaomi_hhccpot002/sensor.py +++ b/esphome/components/xiaomi_hhccpot002/sensor.py @@ -1,16 +1,16 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( - CONF_MAC_ADDRESS, - STATE_CLASS_MEASUREMENT, - UNIT_PERCENT, - ICON_WATER_PERCENT, - CONF_ID, - CONF_MOISTURE, CONF_CONDUCTIVITY, - UNIT_MICROSIEMENS_PER_CENTIMETER, + CONF_ID, + CONF_MAC_ADDRESS, + CONF_MOISTURE, ICON_FLOWER, + ICON_WATER_PERCENT, + STATE_CLASS_MEASUREMENT, + UNIT_MICROSIEMENS_PER_CENTIMETER, + UNIT_PERCENT, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_jqjcy01ym/sensor.py b/esphome/components/xiaomi_jqjcy01ym/sensor.py index f4d2b342fd..5890ed6b63 100644 --- a/esphome/components/xiaomi_jqjcy01ym/sensor.py +++ b/esphome/components/xiaomi_jqjcy01ym/sensor.py @@ -1,22 +1,22 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, + CONF_FORMALDEHYDE, + CONF_HUMIDITY, + CONF_ID, CONF_MAC_ADDRESS, CONF_TEMPERATURE, - CONF_ID, DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, ENTITY_CATEGORY_DIAGNOSTIC, + ICON_FLASK_OUTLINE, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, - UNIT_PERCENT, - CONF_HUMIDITY, UNIT_MILLIGRAMS_PER_CUBIC_METER, - ICON_FLASK_OUTLINE, - CONF_FORMALDEHYDE, + UNIT_PERCENT, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_lywsd02/sensor.py b/esphome/components/xiaomi_lywsd02/sensor.py index 20629a0a9c..ef6aebe6c0 100644 --- a/esphome/components/xiaomi_lywsd02/sensor.py +++ b/esphome/components/xiaomi_lywsd02/sensor.py @@ -1,19 +1,19 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, CONF_HUMIDITY, + CONF_ID, CONF_MAC_ADDRESS, CONF_TEMPERATURE, + DEVICE_CLASS_BATTERY, + DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, ENTITY_CATEGORY_DIAGNOSTIC, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_BATTERY, - CONF_ID, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_lywsd02mmc/sensor.py b/esphome/components/xiaomi_lywsd02mmc/sensor.py index 43784ef698..813429a6c5 100644 --- a/esphome/components/xiaomi_lywsd02mmc/sensor.py +++ b/esphome/components/xiaomi_lywsd02mmc/sensor.py @@ -1,20 +1,20 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, + CONF_BINDKEY, CONF_HUMIDITY, + CONF_ID, CONF_MAC_ADDRESS, CONF_TEMPERATURE, + DEVICE_CLASS_BATTERY, + DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, ENTITY_CATEGORY_DIAGNOSTIC, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_BATTERY, - CONF_ID, - CONF_BINDKEY, ) AUTO_LOAD = ["xiaomi_ble"] diff --git a/esphome/components/xiaomi_lywsd03mmc/sensor.py b/esphome/components/xiaomi_lywsd03mmc/sensor.py index b2784e58fc..bf2de3756c 100644 --- a/esphome/components/xiaomi_lywsd03mmc/sensor.py +++ b/esphome/components/xiaomi_lywsd03mmc/sensor.py @@ -1,20 +1,20 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, + CONF_BINDKEY, CONF_HUMIDITY, + CONF_ID, CONF_MAC_ADDRESS, CONF_TEMPERATURE, + DEVICE_CLASS_BATTERY, + DEVICE_CLASS_HUMIDITY, + DEVICE_CLASS_TEMPERATURE, ENTITY_CATEGORY_DIAGNOSTIC, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_HUMIDITY, - CONF_ID, - CONF_BINDKEY, - DEVICE_CLASS_BATTERY, ) CODEOWNERS = ["@ahpohl"] diff --git a/esphome/components/xiaomi_lywsdcgq/sensor.py b/esphome/components/xiaomi_lywsdcgq/sensor.py index 80f24ac0ef..5d964ea22a 100644 --- a/esphome/components/xiaomi_lywsdcgq/sensor.py +++ b/esphome/components/xiaomi_lywsdcgq/sensor.py @@ -1,19 +1,19 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, CONF_HUMIDITY, + CONF_ID, CONF_MAC_ADDRESS, CONF_TEMPERATURE, + DEVICE_CLASS_BATTERY, + DEVICE_CLASS_HUMIDITY, + DEVICE_CLASS_TEMPERATURE, ENTITY_CATEGORY_DIAGNOSTIC, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_BATTERY, - CONF_ID, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_mhoc303/sensor.py b/esphome/components/xiaomi_mhoc303/sensor.py index 18f5ad7764..86c4d6699f 100644 --- a/esphome/components/xiaomi_mhoc303/sensor.py +++ b/esphome/components/xiaomi_mhoc303/sensor.py @@ -1,19 +1,19 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, CONF_HUMIDITY, + CONF_ID, CONF_MAC_ADDRESS, CONF_TEMPERATURE, + DEVICE_CLASS_BATTERY, + DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, ENTITY_CATEGORY_DIAGNOSTIC, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - DEVICE_CLASS_HUMIDITY, - DEVICE_CLASS_BATTERY, - CONF_ID, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_mhoc401/sensor.py b/esphome/components/xiaomi_mhoc401/sensor.py index 9e92e34230..7161e88da5 100644 --- a/esphome/components/xiaomi_mhoc401/sensor.py +++ b/esphome/components/xiaomi_mhoc401/sensor.py @@ -1,20 +1,20 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, + CONF_BINDKEY, CONF_HUMIDITY, + CONF_ID, CONF_MAC_ADDRESS, CONF_TEMPERATURE, + DEVICE_CLASS_BATTERY, + DEVICE_CLASS_HUMIDITY, + DEVICE_CLASS_TEMPERATURE, ENTITY_CATEGORY_DIAGNOSTIC, STATE_CLASS_MEASUREMENT, UNIT_CELSIUS, UNIT_PERCENT, - DEVICE_CLASS_TEMPERATURE, - DEVICE_CLASS_HUMIDITY, - CONF_ID, - CONF_BINDKEY, - DEVICE_CLASS_BATTERY, ) CODEOWNERS = ["@vevsvevs"] diff --git a/esphome/components/xiaomi_miscale/sensor.py b/esphome/components/xiaomi_miscale/sensor.py index a2a2f3bdfc..4aa8d029f8 100644 --- a/esphome/components/xiaomi_miscale/sensor.py +++ b/esphome/components/xiaomi_miscale/sensor.py @@ -1,17 +1,17 @@ import esphome.codegen as cg +from esphome.components import esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, esp32_ble_tracker from esphome.const import ( - CONF_MAC_ADDRESS, + CONF_CLEAR_IMPEDANCE, CONF_ID, + CONF_IMPEDANCE, + CONF_MAC_ADDRESS, CONF_WEIGHT, + ICON_OMEGA, + ICON_SCALE_BATHROOM, STATE_CLASS_MEASUREMENT, UNIT_KILOGRAM, - ICON_SCALE_BATHROOM, UNIT_OHM, - CONF_IMPEDANCE, - ICON_OMEGA, - CONF_CLEAR_IMPEDANCE, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_mjyd02yla/binary_sensor.py b/esphome/components/xiaomi_mjyd02yla/binary_sensor.py index 9a4b50df91..312f8b43b1 100644 --- a/esphome/components/xiaomi_mjyd02yla/binary_sensor.py +++ b/esphome/components/xiaomi_mjyd02yla/binary_sensor.py @@ -1,23 +1,23 @@ import esphome.codegen as cg +from esphome.components import binary_sensor, esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, binary_sensor, esp32_ble_tracker from esphome.const import ( - CONF_MAC_ADDRESS, - CONF_BINDKEY, - CONF_LIGHT, CONF_BATTERY_LEVEL, + CONF_BINDKEY, + CONF_IDLE_TIME, + CONF_ILLUMINANCE, + CONF_LIGHT, + CONF_MAC_ADDRESS, DEVICE_CLASS_BATTERY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_LIGHT, DEVICE_CLASS_MOTION, ENTITY_CATEGORY_DIAGNOSTIC, - STATE_CLASS_MEASUREMENT, - UNIT_PERCENT, - CONF_IDLE_TIME, - CONF_ILLUMINANCE, - UNIT_MINUTE, - UNIT_LUX, ICON_TIMELAPSE, + STATE_CLASS_MEASUREMENT, + UNIT_LUX, + UNIT_MINUTE, + UNIT_PERCENT, ) DEPENDENCIES = ["esp32_ble_tracker"] diff --git a/esphome/components/xiaomi_mue4094rt/binary_sensor.py b/esphome/components/xiaomi_mue4094rt/binary_sensor.py index 94d85213ff..911d179d8b 100644 --- a/esphome/components/xiaomi_mue4094rt/binary_sensor.py +++ b/esphome/components/xiaomi_mue4094rt/binary_sensor.py @@ -1,12 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor, esp32_ble_tracker -from esphome.const import ( - CONF_MAC_ADDRESS, - CONF_TIMEOUT, - DEVICE_CLASS_MOTION, -) - +import esphome.config_validation as cv +from esphome.const import CONF_MAC_ADDRESS, CONF_TIMEOUT, DEVICE_CLASS_MOTION DEPENDENCIES = ["esp32_ble_tracker"] AUTO_LOAD = ["xiaomi_ble"] diff --git a/esphome/components/xiaomi_rtcgq02lm/__init__.py b/esphome/components/xiaomi_rtcgq02lm/__init__.py index 0c8331db09..df143bac22 100644 --- a/esphome/components/xiaomi_rtcgq02lm/__init__.py +++ b/esphome/components/xiaomi_rtcgq02lm/__init__.py @@ -1,8 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import esp32_ble_tracker -from esphome.const import CONF_MAC_ADDRESS, CONF_ID, CONF_BINDKEY - +import esphome.config_validation as cv +from esphome.const import CONF_BINDKEY, CONF_ID, CONF_MAC_ADDRESS AUTO_LOAD = ["xiaomi_ble"] CODEOWNERS = ["@jesserockz"] diff --git a/esphome/components/xiaomi_rtcgq02lm/binary_sensor.py b/esphome/components/xiaomi_rtcgq02lm/binary_sensor.py index ef8a472d66..8d0508b59b 100644 --- a/esphome/components/xiaomi_rtcgq02lm/binary_sensor.py +++ b/esphome/components/xiaomi_rtcgq02lm/binary_sensor.py @@ -1,14 +1,14 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import binary_sensor +import esphome.config_validation as cv from esphome.const import ( + CONF_BUTTON, + CONF_ID, CONF_LIGHT, CONF_MOTION, CONF_TIMEOUT, DEVICE_CLASS_LIGHT, DEVICE_CLASS_MOTION, - CONF_ID, - CONF_BUTTON, ) from esphome.core import TimePeriod diff --git a/esphome/components/xiaomi_rtcgq02lm/sensor.py b/esphome/components/xiaomi_rtcgq02lm/sensor.py index 558e3623e5..e49f1c960b 100644 --- a/esphome/components/xiaomi_rtcgq02lm/sensor.py +++ b/esphome/components/xiaomi_rtcgq02lm/sensor.py @@ -1,13 +1,13 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( CONF_BATTERY_LEVEL, + CONF_ID, + DEVICE_CLASS_BATTERY, ENTITY_CATEGORY_DIAGNOSTIC, STATE_CLASS_MEASUREMENT, UNIT_PERCENT, - CONF_ID, - DEVICE_CLASS_BATTERY, ) from . import XiaomiRTCGQ02LM diff --git a/esphome/components/xiaomi_wx08zm/binary_sensor.py b/esphome/components/xiaomi_wx08zm/binary_sensor.py index 504dff9d66..69facf54ed 100644 --- a/esphome/components/xiaomi_wx08zm/binary_sensor.py +++ b/esphome/components/xiaomi_wx08zm/binary_sensor.py @@ -1,18 +1,17 @@ import esphome.codegen as cg +from esphome.components import binary_sensor, esp32_ble_tracker, sensor import esphome.config_validation as cv -from esphome.components import sensor, binary_sensor, esp32_ble_tracker from esphome.const import ( CONF_BATTERY_LEVEL, CONF_MAC_ADDRESS, CONF_TABLET, DEVICE_CLASS_BATTERY, ENTITY_CATEGORY_DIAGNOSTIC, + ICON_BUG, STATE_CLASS_MEASUREMENT, UNIT_PERCENT, - ICON_BUG, ) - DEPENDENCIES = ["esp32_ble_tracker"] AUTO_LOAD = ["xiaomi_ble", "sensor"] diff --git a/esphome/components/xl9535/__init__.py b/esphome/components/xl9535/__init__.py index e6f8b28b46..58ce4a30f8 100644 --- a/esphome/components/xl9535/__init__.py +++ b/esphome/components/xl9535/__init__.py @@ -1,6 +1,7 @@ +from esphome import pins import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c +import esphome.config_validation as cv from esphome.const import ( CONF_ID, CONF_INPUT, @@ -9,7 +10,6 @@ from esphome.const import ( CONF_NUMBER, CONF_OUTPUT, ) -from esphome import pins CONF_XL9535 = "xl9535" diff --git a/esphome/components/yashima/climate.py b/esphome/components/yashima/climate.py index 8cafd468ac..eb68d3b6e7 100644 --- a/esphome/components/yashima/climate.py +++ b/esphome/components/yashima/climate.py @@ -1,7 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate, remote_transmitter, sensor from esphome.components.remote_base import CONF_TRANSMITTER_ID +import esphome.config_validation as cv from esphome.const import CONF_ID, CONF_SENSOR, CONF_SUPPORTS_COOL, CONF_SUPPORTS_HEAT AUTO_LOAD = ["sensor"] diff --git a/esphome/components/zhlt01/climate.py b/esphome/components/zhlt01/climate.py index 1451f8ec69..fc01107e1d 100644 --- a/esphome/components/zhlt01/climate.py +++ b/esphome/components/zhlt01/climate.py @@ -1,6 +1,6 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import climate_ir +import esphome.config_validation as cv from esphome.const import CONF_ID AUTO_LOAD = ["climate_ir"] diff --git a/esphome/components/zio_ultrasonic/sensor.py b/esphome/components/zio_ultrasonic/sensor.py index c5eed14e64..533bc5cc57 100644 --- a/esphome/components/zio_ultrasonic/sensor.py +++ b/esphome/components/zio_ultrasonic/sensor.py @@ -1,10 +1,7 @@ import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components import i2c, sensor -from esphome.const import ( - DEVICE_CLASS_DISTANCE, - STATE_CLASS_MEASUREMENT, -) +import esphome.config_validation as cv +from esphome.const import DEVICE_CLASS_DISTANCE, STATE_CLASS_MEASUREMENT DEPENDENCIES = ["i2c"] CODEOWNERS = ["@kahrendt"] diff --git a/esphome/components/zyaura/sensor.py b/esphome/components/zyaura/sensor.py index 28a708b866..58de519283 100644 --- a/esphome/components/zyaura/sensor.py +++ b/esphome/components/zyaura/sensor.py @@ -1,22 +1,22 @@ -import esphome.codegen as cg -import esphome.config_validation as cv from esphome import pins +import esphome.codegen as cg from esphome.components import sensor +import esphome.config_validation as cv from esphome.const import ( - CONF_ID, CONF_CLOCK_PIN, - CONF_DATA_PIN, CONF_CO2, - CONF_TEMPERATURE, + CONF_DATA_PIN, CONF_HUMIDITY, + CONF_ID, + CONF_TEMPERATURE, DEVICE_CLASS_CARBON_DIOXIDE, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_TEMPERATURE, - STATE_CLASS_MEASUREMENT, - UNIT_PARTS_PER_MILLION, - UNIT_CELSIUS, - UNIT_PERCENT, ICON_MOLECULE_CO2, + STATE_CLASS_MEASUREMENT, + UNIT_CELSIUS, + UNIT_PARTS_PER_MILLION, + UNIT_PERCENT, ) from esphome.cpp_helpers import gpio_pin_expression diff --git a/requirements_test.txt b/requirements_test.txt index d836efc148..c074ca2496 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,6 +1,6 @@ pylint==3.2.7 flake8==7.0.0 # also change in .pre-commit-config.yaml when updating -ruff==0.9.2 # also change in .pre-commit-config.yaml when updating +ruff==0.11.0 # also change in .pre-commit-config.yaml when updating pyupgrade==3.15.2 # also change in .pre-commit-config.yaml when updating pre-commit diff --git a/script/api_protobuf/api_protobuf.py b/script/api_protobuf/api_protobuf.py index a2bc3abf64..7771922697 100755 --- a/script/api_protobuf/api_protobuf.py +++ b/script/api_protobuf/api_protobuf.py @@ -17,12 +17,12 @@ then run this script with python3 and the files will be generated, they still need to be formatted """ -import os -import re -import sys from abc import ABC, abstractmethod +import os from pathlib import Path +import re from subprocess import call +import sys from textwrap import dedent # Generate with @@ -528,7 +528,7 @@ class RepeatedTypeInfo(TypeInfo): @property def dump_content(self): - o = f'for (const auto {"" if self._ti_is_bool else "&"}it : this->{self.field_name}) {{\n' + o = f"for (const auto {'' if self._ti_is_bool else '&'}it : this->{self.field_name}) {{\n" o += f' out.append(" {self.name}: ");\n' o += indent(self._ti.dump("it")) + "\n" o += ' out.append("\\n");\n' diff --git a/script/build_language_schema.py b/script/build_language_schema.py index 07093e179a..7152e23e8f 100644 --- a/script/build_language_schema.py +++ b/script/build_language_schema.py @@ -85,8 +85,8 @@ def load_components(): # pylint: disable=wrong-import-position -from esphome.const import CONF_TYPE, KEY_CORE, KEY_TARGET_PLATFORM -from esphome.core import CORE +from esphome.const import CONF_TYPE, KEY_CORE, KEY_TARGET_PLATFORM # noqa: E402 +from esphome.core import CORE # noqa: E402 # pylint: enable=wrong-import-position @@ -95,13 +95,13 @@ load_components() # Import esphome after loading components (so schema is tracked) # pylint: disable=wrong-import-position -from esphome import automation, pins -from esphome.components import remote_base -import esphome.config_validation as cv -import esphome.core as esphome_core -from esphome.helpers import write_file_if_changed -from esphome.loader import CORE_COMPONENTS_PATH, get_platform -from esphome.util import Registry +from esphome import automation, pins # noqa: E402 +from esphome.components import remote_base # noqa: E402 +import esphome.config_validation as cv # noqa: E402 +import esphome.core as esphome_core # noqa: E402 +from esphome.helpers import write_file_if_changed # noqa: E402 +from esphome.loader import CORE_COMPONENTS_PATH, get_platform # noqa: E402 +from esphome.util import Registry # noqa: E402 # pylint: enable=wrong-import-position @@ -614,9 +614,9 @@ def build_schema(): if platform_manifest is not None: output[platform][S_COMPONENTS][domain] = {} if len(platform_manifest.dependencies) > 0: - output[platform][S_COMPONENTS][domain][ - "dependencies" - ] = platform_manifest.dependencies + output[platform][S_COMPONENTS][domain]["dependencies"] = ( + platform_manifest.dependencies + ) register_module_schemas( f"{domain}.{platform}", platform_manifest.module, platform_manifest ) diff --git a/script/run-in-env.py b/script/run-in-env.py index 57121266be..b03f5f19d3 100644 --- a/script/run-in-env.py +++ b/script/run-in-env.py @@ -9,8 +9,8 @@ import sys def find_and_activate_virtualenv(): if ( ("VIRTUAL_ENV" in os.environ) - or os.environ.get("DEVCONTAINER", False) - or os.environ.get("ESPHOME_NO_VENV", False) + or os.environ.get("DEVCONTAINER") + or os.environ.get("ESPHOME_NO_VENV") ): return diff --git a/tests/component_tests/conftest.py b/tests/component_tests/conftest.py index aa564ed7b1..7aa7dfe698 100644 --- a/tests/component_tests/conftest.py +++ b/tests/component_tests/conftest.py @@ -1,18 +1,18 @@ """Fixtures for component tests.""" -import sys from pathlib import Path +import sys # Add package root to python path here = Path(__file__).parent package_root = here.parent.parent sys.path.insert(0, package_root.as_posix()) -import pytest +import pytest # noqa: E402 -from esphome.core import CORE -from esphome.config import read_config -from esphome.__main__ import generate_cpp_contents +from esphome.__main__ import generate_cpp_contents # noqa: E402 +from esphome.config import read_config # noqa: E402 +from esphome.core import CORE # noqa: E402 @pytest.fixture diff --git a/tests/unit_tests/conftest.py b/tests/unit_tests/conftest.py index d61c4a442a..955869b799 100644 --- a/tests/unit_tests/conftest.py +++ b/tests/unit_tests/conftest.py @@ -9,11 +9,10 @@ not be part of a unit test suite. """ -import sys -import pytest - from pathlib import Path +import sys +import pytest here = Path(__file__).parent diff --git a/tests/unit_tests/test_cpp_helpers.py b/tests/unit_tests/test_cpp_helpers.py index 497b3966fb..2618803fec 100644 --- a/tests/unit_tests/test_cpp_helpers.py +++ b/tests/unit_tests/test_cpp_helpers.py @@ -1,8 +1,8 @@ -import pytest from unittest.mock import Mock -from esphome import cpp_helpers as ch -from esphome import const +import pytest + +from esphome import const, cpp_helpers as ch @pytest.mark.asyncio diff --git a/tests/unit_tests/test_helpers.py b/tests/unit_tests/test_helpers.py index 26ebdcf6af..862320b09e 100644 --- a/tests/unit_tests/test_helpers.py +++ b/tests/unit_tests/test_helpers.py @@ -1,7 +1,6 @@ -import pytest - from hypothesis import given from hypothesis.strategies import ip_addresses +import pytest from esphome import helpers diff --git a/tests/unit_tests/test_wizard.py b/tests/unit_tests/test_wizard.py index 9260629ec3..6d360740f4 100644 --- a/tests/unit_tests/test_wizard.py +++ b/tests/unit_tests/test_wizard.py @@ -1,16 +1,17 @@ """Tests for the wizard.py file.""" import os - -import esphome.wizard as wz -import pytest -from esphome.core import CORE -from esphome.components.esp8266.boards import ESP8266_BOARD_PINS -from esphome.components.esp32.boards import ESP32_BOARD_PINS -from esphome.components.bk72xx.boards import BK72XX_BOARD_PINS -from esphome.components.rtl87xx.boards import RTL87XX_BOARD_PINS from unittest.mock import MagicMock +import pytest + +from esphome.components.bk72xx.boards import BK72XX_BOARD_PINS +from esphome.components.esp32.boards import ESP32_BOARD_PINS +from esphome.components.esp8266.boards import ESP8266_BOARD_PINS +from esphome.components.rtl87xx.boards import RTL87XX_BOARD_PINS +from esphome.core import CORE +import esphome.wizard as wz + @pytest.fixture def default_config(): From 874026ca8ffc352bb9f2eaee72ea7bb4d8f0d13d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 22:07:38 +0000 Subject: [PATCH 24/88] Bump pylint from 3.2.7 to 3.3.6 (#8441) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: J. Nick Koston --- pyproject.toml | 1 + requirements_test.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c8929238ec..b4431e433b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,6 +86,7 @@ disable = [ "too-many-branches", "too-many-statements", "too-many-arguments", + "too-many-positional-arguments", "too-many-return-statements", "too-many-instance-attributes", "duplicate-code", diff --git a/requirements_test.txt b/requirements_test.txt index c074ca2496..f59c95c87d 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,4 +1,4 @@ -pylint==3.2.7 +pylint==3.3.6 flake8==7.0.0 # also change in .pre-commit-config.yaml when updating ruff==0.11.0 # also change in .pre-commit-config.yaml when updating pyupgrade==3.15.2 # also change in .pre-commit-config.yaml when updating From dfbfb2a2bbf356ea7beed92d347393c7c5cf1c04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 13:08:25 -1000 Subject: [PATCH 25/88] Update wheel requirement from ~=0.43.0 to >=0.43,<0.46 (#8421) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b4431e433b..eef314c4b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools==76.0.0", "wheel~=0.43.0"] +requires = ["setuptools==76.0.0", "wheel>=0.43,<0.46"] build-backend = "setuptools.build_meta" [project] From f3390ff7f5f96c56bb5bdd5f19da429bdeac5503 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 14:41:23 -1000 Subject: [PATCH 26/88] Bump tzlocal from 5.2 to 5.3.1 (#8423) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 1ed77c635a..740de5990b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ paho-mqtt==1.6.1 colorama==0.4.6 icmplib==3.0.4 tornado==6.4.2 -tzlocal==5.2 # from time +tzlocal==5.3.1 # from time tzdata>=2021.1 # from time pyserial==3.5 platformio==6.1.16 # When updating platformio, also update Dockerfile From c0e4701e1dff6f5841438a1df814858e31f726bd Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Thu, 20 Mar 2025 22:31:58 -0400 Subject: [PATCH 27/88] [esp32] Allow pioarduino versions 5.3.2 and 5.4.0 (#8440) Co-authored-by: Keith Burzinski --- esphome/components/esp32/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/components/esp32/__init__.py b/esphome/components/esp32/__init__.py index 23b84f3d13..6a0c74b680 100644 --- a/esphome/components/esp32/__init__.py +++ b/esphome/components/esp32/__init__.py @@ -273,6 +273,8 @@ SUPPORTED_PLATFORMIO_ESP_IDF_5X = [ # pioarduino versions that don't require a release number # List based on https://github.com/pioarduino/esp-idf/releases SUPPORTED_PIOARDUINO_ESP_IDF_5X = [ + cv.Version(5, 4, 0), + cv.Version(5, 3, 2), cv.Version(5, 3, 1), cv.Version(5, 3, 0), cv.Version(5, 1, 5), From 3320e4112b300b1c9bdd0bc814d06eb0d61d5b09 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Fri, 21 Mar 2025 13:38:59 +1100 Subject: [PATCH 28/88] [cli] Add `--reset` and `--upload_speed` options (#8380) --- esphome/__main__.py | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/esphome/__main__.py b/esphome/__main__.py index 43b5504704..0d9662bfd6 100644 --- a/esphome/__main__.py +++ b/esphome/__main__.py @@ -133,7 +133,7 @@ def get_port_type(port): return "NETWORK" -def run_miniterm(config, port): +def run_miniterm(config, port, args): import serial from esphome import platformio_api @@ -154,7 +154,7 @@ def run_miniterm(config, port): # We can't set to False by default since it leads to toggling and hence # ESP32 resets on some platforms. - if config["logger"][CONF_DEASSERT_RTS_DTR]: + if config["logger"][CONF_DEASSERT_RTS_DTR] or args.reset: ser.dtr = False ser.rts = False @@ -244,11 +244,11 @@ def compile_program(args, config): return 0 if idedata is not None else 1 -def upload_using_esptool(config, port, file): +def upload_using_esptool(config, port, file, speed): from esphome import platformio_api - first_baudrate = config[CONF_ESPHOME][CONF_PLATFORMIO_OPTIONS].get( - "upload_speed", 460800 + first_baudrate = speed or config[CONF_ESPHOME][CONF_PLATFORMIO_OPTIONS].get( + "upload_speed", os.getenv("ESPHOME_UPLOAD_SPEED", "460800") ) if file is not None: @@ -348,7 +348,7 @@ def upload_program(config, args, host): check_permissions(host) if CORE.target_platform in (PLATFORM_ESP32, PLATFORM_ESP8266): file = getattr(args, "file", None) - return upload_using_esptool(config, host, file) + return upload_using_esptool(config, host, file, args.upload_speed) if CORE.target_platform in (PLATFORM_RP2040): return upload_using_platformio(config, args.device) @@ -397,7 +397,7 @@ def show_logs(config, args, port): raise EsphomeError("Logger is not configured!") if get_port_type(port) == "SERIAL": check_permissions(port) - return run_miniterm(config, port) + return run_miniterm(config, port, args) if get_port_type(port) == "NETWORK" and "api" in config: if config[CONF_MDNS][CONF_DISABLED] and CONF_MQTT in config: from esphome import mqtt @@ -842,6 +842,10 @@ def parse_args(argv): "--device", help="Manually specify the serial port/address to use, for example /dev/ttyUSB0.", ) + parser_upload.add_argument( + "--upload_speed", + help="Override the default or configured upload speed.", + ) parser_upload.add_argument( "--file", help="Manually specify the binary file to upload.", @@ -860,6 +864,13 @@ def parse_args(argv): "--device", help="Manually specify the serial port/address to use, for example /dev/ttyUSB0.", ) + parser_logs.add_argument( + "--reset", + "-r", + action="store_true", + help="Reset the device before starting serial logs.", + default=os.getenv("ESPHOME_SERIAL_LOGGING_RESET"), + ) parser_discover = subparsers.add_parser( "discover", @@ -882,9 +893,20 @@ def parse_args(argv): "--device", help="Manually specify the serial port/address to use, for example /dev/ttyUSB0.", ) + parser_run.add_argument( + "--upload_speed", + help="Override the default or configured upload speed.", + ) parser_run.add_argument( "--no-logs", help="Disable starting logs.", action="store_true" ) + parser_run.add_argument( + "--reset", + "-r", + action="store_true", + help="Reset the device before starting serial logs.", + default=os.getenv("ESPHOME_SERIAL_LOGGING_RESET"), + ) parser_clean = subparsers.add_parser( "clean-mqtt", From d891521ce2aa849e2b75b42c8e18984e50310a79 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Fri, 21 Mar 2025 15:12:27 +1100 Subject: [PATCH 29/88] [lvgl] Set correct buffer size (#8442) --- esphome/components/lvgl/lvgl_esphome.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/components/lvgl/lvgl_esphome.cpp b/esphome/components/lvgl/lvgl_esphome.cpp index 6030cb90f1..a1820dd1c7 100644 --- a/esphome/components/lvgl/lvgl_esphome.cpp +++ b/esphome/components/lvgl/lvgl_esphome.cpp @@ -441,7 +441,7 @@ void LvglComponent::setup() { this->status_set_error("Memory allocation failure"); return; } - lv_disp_draw_buf_init(&this->draw_buf_, buffer, nullptr, buf_bytes); + lv_disp_draw_buf_init(&this->draw_buf_, buffer, nullptr, buffer_pixels); this->disp_drv_.hor_res = width; this->disp_drv_.ver_res = height; // this->setup_driver_(display->get_width(), display->get_height()); From 17e3bb7324ba61edf0a92b9b6cce562f0a97e5f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 11:44:47 -1000 Subject: [PATCH 30/88] Bump aioesphomeapi from 29.6.0 to 29.7.0 (#8448) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 740de5990b..d7526f664b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ platformio==6.1.16 # When updating platformio, also update Dockerfile esptool==4.8.1 click==8.1.7 esphome-dashboard==20250212.0 -aioesphomeapi==29.6.0 +aioesphomeapi==29.7.0 zeroconf==0.146.1 puremagic==1.28 ruamel.yaml==0.18.6 # dashboard_import From f5885de6f14a6494b9b170388fca30d9d6da8d2f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 22:19:09 +0000 Subject: [PATCH 31/88] Bump pytest-asyncio from 0.23.6 to 0.25.3 (#8447) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index f59c95c87d..79d856e74c 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -8,6 +8,6 @@ pre-commit pytest==8.2.0 pytest-cov==5.0.0 pytest-mock==3.14.0 -pytest-asyncio==0.23.6 +pytest-asyncio==0.25.3 asyncmock==0.4.2 hypothesis==6.92.1 From acce0bc45b5a2d8ef721fba0cf76c8bc6bd23e36 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Sun, 23 Mar 2025 15:09:29 +1100 Subject: [PATCH 32/88] [lvgl] Ensure non-zero screen dimensions during init (#8444) --- esphome/components/lvgl/lvgl_esphome.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/esphome/components/lvgl/lvgl_esphome.cpp b/esphome/components/lvgl/lvgl_esphome.cpp index a1820dd1c7..2560cd2168 100644 --- a/esphome/components/lvgl/lvgl_esphome.cpp +++ b/esphome/components/lvgl/lvgl_esphome.cpp @@ -423,8 +423,6 @@ LvglComponent::LvglComponent(std::vector displays, float buf this->disp_drv_.full_refresh = this->full_refresh_; this->disp_drv_.flush_cb = static_flush_cb; this->disp_drv_.rounder_cb = rounder_cb; - this->disp_drv_.hor_res = 0; - this->disp_drv_.ver_res = 0; this->disp_ = lv_disp_drv_register(&this->disp_drv_); } @@ -448,7 +446,7 @@ void LvglComponent::setup() { lv_disp_drv_update(this->disp_, &this->disp_drv_); this->rotation = display->get_rotation(); if (this->rotation != display::DISPLAY_ROTATION_0_DEGREES) { - this->rotate_buf_ = static_cast(lv_custom_mem_alloc(this->draw_buf_.size)); // NOLINT + this->rotate_buf_ = static_cast(lv_custom_mem_alloc(buf_bytes)); // NOLINT if (this->rotate_buf_ == nullptr) { this->mark_failed(); this->status_set_error("Memory allocation failure"); From 6787730aa48393b37ef3cd03b6db5c63702f3df7 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Sun, 23 Mar 2025 22:46:31 -0400 Subject: [PATCH 33/88] [core] Fix 5.4.0 build issue (#8455) Co-authored-by: Keith Burzinski --- esphome/core/helpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp index 439bb2ccb0..e69f166600 100644 --- a/esphome/core/helpers.cpp +++ b/esphome/core/helpers.cpp @@ -44,7 +44,7 @@ #include #endif #ifdef USE_ESP32 -#include "esp32/rom/crc.h" +#include "rom/crc.h" #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 2) #include "esp_mac.h" #endif From 6cfe3ac44d9be2b3479ede845ecc0852c675a3e5 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 24 Mar 2025 20:07:21 +1100 Subject: [PATCH 34/88] [gt911][cst226][ektf2232] Swap x and y calibration values (#8450) Co-authored-by: Keith Burzinski --- .../cst226/touchscreen/cst226_touchscreen.cpp | 2 ++ .../ektf2232/touchscreen/ektf2232.cpp | 35 ++++++++++--------- .../gt911/touchscreen/gt911_touchscreen.cpp | 19 ++++++---- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/esphome/components/cst226/touchscreen/cst226_touchscreen.cpp b/esphome/components/cst226/touchscreen/cst226_touchscreen.cpp index d4e43d30f5..a25859fe17 100644 --- a/esphome/components/cst226/touchscreen/cst226_touchscreen.cpp +++ b/esphome/components/cst226/touchscreen/cst226_touchscreen.cpp @@ -72,6 +72,8 @@ void CST226Touchscreen::continue_setup_() { if (this->read16_(0xD1F8, buffer, 4)) { this->x_raw_max_ = buffer[0] + (buffer[1] << 8); this->y_raw_max_ = buffer[2] + (buffer[3] << 8); + if (this->swap_x_y_) + std::swap(this->x_raw_max_, this->y_raw_max_); } else { this->x_raw_max_ = this->display_->get_native_width(); this->y_raw_max_ = this->display_->get_native_height(); diff --git a/esphome/components/ektf2232/touchscreen/ektf2232.cpp b/esphome/components/ektf2232/touchscreen/ektf2232.cpp index ef8f1c6802..603b554273 100644 --- a/esphome/components/ektf2232/touchscreen/ektf2232.cpp +++ b/esphome/components/ektf2232/touchscreen/ektf2232.cpp @@ -34,26 +34,29 @@ void EKTF2232Touchscreen::setup() { // Get touch resolution uint8_t received[4]; - if (this->x_raw_max_ == this->x_raw_min_) { - this->write(GET_X_RES, 4); - if (this->read(received, 4)) { - ESP_LOGE(TAG, "Failed to read X resolution!"); + if (this->x_raw_max_ == 0 || this->y_raw_max_ == 0) { + auto err = this->write(GET_X_RES, 4); + if (err == i2c::ERROR_OK) { + err = this->read(received, 4); + if (err == i2c::ERROR_OK) { + this->x_raw_max_ = ((received[2])) | ((received[3] & 0xf0) << 4); + err = this->write(GET_Y_RES, 4); + if (err == i2c::ERROR_OK) { + err = this->read(received, 4); + if (err == i2c::ERROR_OK) { + this->y_raw_max_ = ((received[2])) | ((received[3] & 0xf0) << 4); + } + } + } + } + if (err != i2c::ERROR_OK) { + ESP_LOGE(TAG, "Failed to read calibration values!"); this->interrupt_pin_->detach_interrupt(); this->mark_failed(); return; } - this->x_raw_max_ = ((received[2])) | ((received[3] & 0xf0) << 4); - } - - if (this->y_raw_max_ == this->y_raw_min_) { - this->write(GET_Y_RES, 4); - if (this->read(received, 4)) { - ESP_LOGE(TAG, "Failed to read Y resolution!"); - this->interrupt_pin_->detach_interrupt(); - this->mark_failed(); - return; - } - this->y_raw_max_ = ((received[2])) | ((received[3] & 0xf0) << 4); + if (this->swap_x_y_) + std::swap(this->x_raw_max_, this->y_raw_max_); } this->set_power_state(true); } diff --git a/esphome/components/gt911/touchscreen/gt911_touchscreen.cpp b/esphome/components/gt911/touchscreen/gt911_touchscreen.cpp index 84811b818f..674ef51d64 100644 --- a/esphome/components/gt911/touchscreen/gt911_touchscreen.cpp +++ b/esphome/components/gt911/touchscreen/gt911_touchscreen.cpp @@ -60,20 +60,25 @@ void GT911Touchscreen::setup() { } } } - if (err == i2c::ERROR_OK) { - err = this->write(GET_MAX_VALUES, 2); + if (this->x_raw_max_ == 0 || this->y_raw_max_ == 0) { + // no calibration? Attempt to read the max values from the touchscreen. if (err == i2c::ERROR_OK) { - err = this->read(data, sizeof(data)); + err = this->write(GET_MAX_VALUES, 2); if (err == i2c::ERROR_OK) { - if (this->x_raw_max_ == this->x_raw_min_) { + err = this->read(data, sizeof(data)); + if (err == i2c::ERROR_OK) { this->x_raw_max_ = encode_uint16(data[1], data[0]); - } - if (this->y_raw_max_ == this->y_raw_min_) { this->y_raw_max_ = encode_uint16(data[3], data[2]); + if (this->swap_x_y_) + std::swap(this->x_raw_max_, this->y_raw_max_); } - esph_log_d(TAG, "calibration max_x/max_y %d/%d", this->x_raw_max_, this->y_raw_max_); } } + if (err != i2c::ERROR_OK) { + ESP_LOGE(TAG, "Failed to read calibration values from touchscreen!"); + this->mark_failed(); + return; + } } if (err != i2c::ERROR_OK) { ESP_LOGE(TAG, "Failed to communicate!"); From bc999b50b354379d7e14c650187379ae7cb44e3f Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 24 Mar 2025 20:35:42 +1100 Subject: [PATCH 35/88] [font] More robust handling of fixed font sizes. (#8443) Co-authored-by: Keith Burzinski --- esphome/components/font/__init__.py | 28 +- tests/components/font/Tamzen5x9b.bdf | 3246 ++++++++++++++++++++++++++ tests/components/font/common.yaml | 3 + 3 files changed, 3270 insertions(+), 7 deletions(-) create mode 100644 tests/components/font/Tamzen5x9b.bdf diff --git a/esphome/components/font/__init__.py b/esphome/components/font/__init__.py index 084574d09f..a405761c74 100644 --- a/esphome/components/font/__init__.py +++ b/esphome/components/font/__init__.py @@ -7,7 +7,15 @@ from pathlib import Path import re import esphome_glyphsets as glyphsets -from freetype import Face, ft_pixel_mode_grays, ft_pixel_mode_mono + +# pylint: disable=no-name-in-module +from freetype import ( + FT_LOAD_NO_BITMAP, + FT_LOAD_RENDER, + Face, + ft_pixel_mode_grays, + ft_pixel_mode_mono, +) import requests from esphome import external_files @@ -204,7 +212,7 @@ def validate_font_config(config): if font.get_char_index(x) != 0 ] - if font.has_fixed_sizes: + if not font.is_scalable: sizes = [pt_to_px(x.size) for x in font.available_sizes] if not sizes: raise cv.Invalid( @@ -507,10 +515,16 @@ async def to_code(config): # create the data array for all glyphs for codepoint in codepoints: font = point_font_map[codepoint] - format = font.get_format().decode("utf-8") - if format != "PCF": + if not font.is_scalable: + sizes = [pt_to_px(x.size) for x in font.available_sizes] + if size in sizes: + font.select_size(sizes.index(size)) + else: font.set_pixel_sizes(size, 0) - font.load_char(codepoint) + flags = FT_LOAD_RENDER + if bpp != 1: + flags |= FT_LOAD_NO_BITMAP + font.load_char(codepoint, flags) font.glyph.render(mode) width = font.glyph.bitmap.width height = font.glyph.bitmap.rows @@ -535,7 +549,7 @@ async def to_code(config): pos += 1 ascender = pt_to_px(font.size.ascender) if ascender == 0: - if font.has_fixed_sizes: + if not font.is_scalable: ascender = size else: _LOGGER.error( @@ -585,7 +599,7 @@ async def to_code(config): font_height = pt_to_px(base_font.size.height) ascender = pt_to_px(base_font.size.ascender) if font_height == 0: - if base_font.has_fixed_sizes: + if not base_font.is_scalable: font_height = size ascender = font_height else: diff --git a/tests/components/font/Tamzen5x9b.bdf b/tests/components/font/Tamzen5x9b.bdf new file mode 100644 index 0000000000..dcea6def61 --- /dev/null +++ b/tests/components/font/Tamzen5x9b.bdf @@ -0,0 +1,3246 @@ +STARTFONT 2.1 +FONT -Misc-Tamzen-Bold-R-Normal--9-65-100-100-C-50-ISO8859-1 +SIZE 9 100 100 +FONTBOUNDINGBOX 5 9 0 -2 +STARTPROPERTIES 24 +FONTNAME_REGISTRY "" +FOUNDRY "Misc" +FAMILY_NAME "Tamzen" +WEIGHT_NAME "Bold" +SLANT "R" +SETWIDTH_NAME "Normal" +ADD_STYLE_NAME "" +PIXEL_SIZE 9 +POINT_SIZE 65 +RESOLUTION_X 100 +RESOLUTION_Y 100 +SPACING "C" +AVERAGE_WIDTH 50 +CHARSET_REGISTRY "ISO10646" +CHARSET_ENCODING "1" +COPYRIGHT "(c) 2015 Scott Fial" +CAP_HEIGHT 5 +X_HEIGHT 4 +FONT_VERSION "1.11" +WEIGHT 10 +QUAD_WIDTH 5 +DEFAULT_CHAR 0 +FONT_DESCENT 2 +FONT_ASCENT 7 +ENDPROPERTIES +CHARS 189 + +STARTCHAR U+2592 +ENCODING 2 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +50 +A8 +50 +A8 +50 +A8 +50 +A8 +50 +ENDCHAR + +STARTCHAR U+00B0 +ENCODING 7 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +D0 +60 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+2518 +ENCODING 11 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +20 +20 +20 +20 +E0 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+2510 +ENCODING 12 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +E0 +20 +20 +20 +20 +ENDCHAR + +STARTCHAR U+250C +ENCODING 13 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +38 +20 +20 +20 +20 +ENDCHAR + +STARTCHAR U+2514 +ENCODING 14 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +20 +20 +20 +20 +38 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+253C +ENCODING 15 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +20 +20 +20 +20 +F8 +20 +20 +20 +20 +ENDCHAR + +STARTCHAR U+2500 +ENCODING 18 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +F8 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+251C +ENCODING 21 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +20 +20 +20 +20 +38 +20 +20 +20 +20 +ENDCHAR + +STARTCHAR U+2524 +ENCODING 22 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +20 +20 +20 +20 +E0 +20 +20 +20 +20 +ENDCHAR + +STARTCHAR U+2534 +ENCODING 23 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +20 +20 +20 +20 +F8 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+252C +ENCODING 24 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +F8 +20 +20 +20 +20 +ENDCHAR + +STARTCHAR U+2502 +ENCODING 25 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +20 +20 +20 +20 +20 +20 +20 +20 +20 +ENDCHAR + +STARTCHAR U+00A3 +ENCODING 30 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +30 +60 +F0 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+0020 +ENCODING 32 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +00 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+0021 +ENCODING 33 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +60 +60 +60 +60 +00 +60 +00 +00 +ENDCHAR + +STARTCHAR U+0022 +ENCODING 34 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +F0 +F0 +A0 +00 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+0023 +ENCODING 35 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +50 +F0 +50 +F0 +F0 +50 +00 +00 +ENDCHAR + +STARTCHAR U+0024 +ENCODING 36 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +20 +20 +70 +60 +30 +F0 +40 +40 +ENDCHAR + +STARTCHAR U+0025 +ENCODING 37 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +80 +90 +30 +60 +C0 +90 +10 +00 +ENDCHAR + +STARTCHAR U+0026 +ENCODING 38 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +60 +D0 +60 +D8 +D0 +E8 +00 +00 +ENDCHAR + +STARTCHAR U+0027 +ENCODING 39 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +60 +60 +60 +00 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+0028 +ENCODING 40 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +30 +60 +C0 +C0 +C0 +60 +30 +00 +ENDCHAR + +STARTCHAR U+0029 +ENCODING 41 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +C0 +60 +30 +30 +30 +60 +C0 +00 +ENDCHAR + +STARTCHAR U+002A +ENCODING 42 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +20 +F0 +60 +E0 +A0 +00 +00 +00 +ENDCHAR + +STARTCHAR U+002B +ENCODING 43 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +60 +F8 +60 +60 +00 +00 +ENDCHAR + +STARTCHAR U+002C +ENCODING 44 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +00 +60 +60 +C0 +00 +ENDCHAR + +STARTCHAR U+002D +ENCODING 45 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +F0 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+002E +ENCODING 46 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +00 +60 +60 +00 +00 +ENDCHAR + +STARTCHAR U+002F +ENCODING 47 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +30 +30 +60 +60 +C0 +C0 +00 +ENDCHAR + +STARTCHAR U+0030 +ENCODING 48 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+0031 +ENCODING 49 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +E0 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+0032 +ENCODING 50 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +E0 +30 +60 +C0 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+0033 +ENCODING 51 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +E0 +30 +60 +30 +E0 +00 +00 +ENDCHAR + +STARTCHAR U+0034 +ENCODING 52 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +30 +70 +B0 +F0 +30 +00 +00 +ENDCHAR + +STARTCHAR U+0035 +ENCODING 53 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +F0 +C0 +E0 +30 +E0 +00 +00 +ENDCHAR + +STARTCHAR U+0036 +ENCODING 54 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +C0 +E0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+0037 +ENCODING 55 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +F0 +30 +60 +C0 +C0 +00 +00 +ENDCHAR + +STARTCHAR U+0038 +ENCODING 56 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +D0 +60 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+0039 +ENCODING 57 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +D0 +70 +30 +60 +00 +00 +ENDCHAR + +STARTCHAR U+003A +ENCODING 58 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +60 +00 +60 +60 +00 +00 +ENDCHAR + +STARTCHAR U+003B +ENCODING 59 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +60 +00 +60 +60 +C0 +00 +ENDCHAR + +STARTCHAR U+003C +ENCODING 60 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +30 +60 +C0 +60 +30 +00 +00 +ENDCHAR + +STARTCHAR U+003D +ENCODING 61 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +F0 +00 +F0 +00 +00 +00 +ENDCHAR + +STARTCHAR U+003E +ENCODING 62 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +C0 +60 +30 +60 +C0 +00 +00 +ENDCHAR + +STARTCHAR U+003F +ENCODING 63 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +60 +B0 +30 +60 +00 +60 +00 +00 +ENDCHAR + +STARTCHAR U+0040 +ENCODING 64 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +60 +D0 +D0 +D0 +C0 +C0 +70 +00 +ENDCHAR + +STARTCHAR U+0041 +ENCODING 65 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +20 +70 +B0 +F0 +B0 +00 +00 +ENDCHAR + +STARTCHAR U+0042 +ENCODING 66 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +E0 +D0 +E0 +D0 +E0 +00 +00 +ENDCHAR + +STARTCHAR U+0043 +ENCODING 67 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +70 +C0 +C0 +C0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+0044 +ENCODING 68 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +E0 +D0 +D0 +D0 +E0 +00 +00 +ENDCHAR + +STARTCHAR U+0045 +ENCODING 69 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +F0 +C0 +E0 +C0 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+0046 +ENCODING 70 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +F0 +C0 +E0 +C0 +C0 +00 +00 +ENDCHAR + +STARTCHAR U+0047 +ENCODING 71 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +70 +C0 +D0 +D0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+0048 +ENCODING 72 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +D0 +D0 +F0 +D0 +D0 +00 +00 +ENDCHAR + +STARTCHAR U+0049 +ENCODING 73 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +F0 +60 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+004A +ENCODING 74 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +30 +30 +30 +B0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+004B +ENCODING 75 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +D0 +D0 +E0 +D0 +D0 +00 +00 +ENDCHAR + +STARTCHAR U+004C +ENCODING 76 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +C0 +C0 +C0 +C0 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+004D +ENCODING 77 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +90 +F0 +F0 +90 +90 +00 +00 +ENDCHAR + +STARTCHAR U+004E +ENCODING 78 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +D0 +D0 +F0 +B0 +B0 +00 +00 +ENDCHAR + +STARTCHAR U+004F +ENCODING 79 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+0050 +ENCODING 80 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +E0 +D0 +E0 +C0 +C0 +00 +00 +ENDCHAR + +STARTCHAR U+0051 +ENCODING 81 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +D0 +D0 +D0 +60 +30 +00 +ENDCHAR + +STARTCHAR U+0052 +ENCODING 82 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +E0 +D0 +E0 +E0 +D0 +00 +00 +ENDCHAR + +STARTCHAR U+0053 +ENCODING 83 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +70 +C0 +60 +30 +E0 +00 +00 +ENDCHAR + +STARTCHAR U+0054 +ENCODING 84 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +F0 +60 +60 +60 +60 +00 +00 +ENDCHAR + +STARTCHAR U+0055 +ENCODING 85 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +D0 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+0056 +ENCODING 86 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +D0 +D0 +D0 +E0 +40 +00 +00 +ENDCHAR + +STARTCHAR U+0057 +ENCODING 87 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +90 +90 +F0 +F0 +90 +00 +00 +ENDCHAR + +STARTCHAR U+0058 +ENCODING 88 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +D0 +60 +60 +60 +D0 +00 +00 +ENDCHAR + +STARTCHAR U+0059 +ENCODING 89 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +D0 +D0 +60 +60 +60 +00 +00 +ENDCHAR + +STARTCHAR U+005A +ENCODING 90 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +F0 +30 +60 +C0 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+005B +ENCODING 91 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +70 +60 +60 +60 +60 +60 +70 +00 +ENDCHAR + +STARTCHAR U+005C +ENCODING 92 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +C0 +C0 +60 +60 +30 +30 +00 +ENDCHAR + +STARTCHAR U+005D +ENCODING 93 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +E0 +60 +60 +60 +60 +60 +E0 +00 +ENDCHAR + +STARTCHAR U+005E +ENCODING 94 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +40 +E0 +A0 +00 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+005F +ENCODING 95 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +00 +00 +00 +F8 +00 +ENDCHAR + +STARTCHAR U+0060 +ENCODING 96 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +80 +C0 +60 +20 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+0061 +ENCODING 97 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +70 +B0 +B0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+0062 +ENCODING 98 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +C0 +C0 +E0 +D0 +D0 +E0 +00 +00 +ENDCHAR + +STARTCHAR U+0063 +ENCODING 99 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +70 +C0 +C0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+0064 +ENCODING 100 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +30 +30 +70 +B0 +B0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+0065 +ENCODING 101 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +70 +B0 +E0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+0066 +ENCODING 102 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +30 +60 +F0 +60 +60 +60 +00 +00 +ENDCHAR + +STARTCHAR U+0067 +ENCODING 103 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +70 +D0 +D0 +70 +30 +60 +ENDCHAR + +STARTCHAR U+0068 +ENCODING 104 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +C0 +C0 +E0 +D0 +D0 +D0 +00 +00 +ENDCHAR + +STARTCHAR U+0069 +ENCODING 105 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +60 +00 +E0 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+006A +ENCODING 106 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +30 +00 +70 +30 +30 +30 +30 +E0 +ENDCHAR + +STARTCHAR U+006B +ENCODING 107 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +C0 +C0 +D0 +E0 +D0 +D0 +00 +00 +ENDCHAR + +STARTCHAR U+006C +ENCODING 108 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +E0 +60 +60 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+006D +ENCODING 109 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +D0 +F0 +D0 +D0 +00 +00 +ENDCHAR + +STARTCHAR U+006E +ENCODING 110 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +E0 +D0 +D0 +D0 +00 +00 +ENDCHAR + +STARTCHAR U+006F +ENCODING 111 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +60 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+0070 +ENCODING 112 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +E0 +D0 +D0 +E0 +C0 +C0 +ENDCHAR + +STARTCHAR U+0071 +ENCODING 113 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +70 +B0 +B0 +70 +30 +30 +ENDCHAR + +STARTCHAR U+0072 +ENCODING 114 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +F0 +C0 +C0 +C0 +00 +00 +ENDCHAR + +STARTCHAR U+0073 +ENCODING 115 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +70 +60 +30 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+0074 +ENCODING 116 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +F0 +60 +60 +70 +00 +00 +ENDCHAR + +STARTCHAR U+0075 +ENCODING 117 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+0076 +ENCODING 118 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +D0 +D0 +E0 +40 +00 +00 +ENDCHAR + +STARTCHAR U+0077 +ENCODING 119 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +D0 +D0 +F0 +D0 +00 +00 +ENDCHAR + +STARTCHAR U+0078 +ENCODING 120 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +D0 +60 +60 +D0 +00 +00 +ENDCHAR + +STARTCHAR U+0079 +ENCODING 121 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +D0 +D0 +D0 +70 +30 +60 +ENDCHAR + +STARTCHAR U+007A +ENCODING 122 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +F0 +60 +C0 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+007B +ENCODING 123 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +38 +30 +30 +F0 +30 +30 +38 +00 +ENDCHAR + +STARTCHAR U+007C +ENCODING 124 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +60 +60 +60 +60 +60 +60 +60 +00 +ENDCHAR + +STARTCHAR U+007D +ENCODING 125 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +E0 +60 +60 +78 +60 +60 +E0 +00 +ENDCHAR + +STARTCHAR U+007E +ENCODING 126 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +50 +F0 +A0 +00 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+00A0 +ENCODING 160 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +00 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+00A1 +ENCODING 161 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +60 +00 +60 +60 +60 +60 +ENDCHAR + +STARTCHAR U+00A2 +ENCODING 162 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +20 +70 +C0 +C0 +70 +20 +00 +00 +ENDCHAR + +STARTCHAR U+00A3 +ENCODING 163 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +30 +60 +F0 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00A4 +ENCODING 164 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +D0 +60 +D0 +D0 +60 +D0 +00 +00 +ENDCHAR + +STARTCHAR U+00A5 +ENCODING 165 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +D0 +60 +F0 +60 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00A6 +ENCODING 166 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +60 +60 +60 +00 +60 +60 +60 +00 +ENDCHAR + +STARTCHAR U+00A8 +ENCODING 168 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +A0 +00 +00 +00 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+00A9 +ENCODING 169 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +90 +B0 +90 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00AB +ENCODING 171 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +48 +D8 +48 +00 +00 +ENDCHAR + +STARTCHAR U+00AD +ENCODING 173 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +F0 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+00B0 +ENCODING 176 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +D0 +60 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+00B4 +ENCODING 180 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +10 +20 +00 +00 +00 +00 +00 +00 +ENDCHAR + +STARTCHAR U+00B8 +ENCODING 184 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +00 +00 +00 +20 +60 +ENDCHAR + +STARTCHAR U+00BB +ENCODING 187 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +00 +90 +D8 +90 +00 +00 +ENDCHAR + +STARTCHAR U+00BF +ENCODING 191 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +60 +00 +60 +C0 +D0 +60 +ENDCHAR + +STARTCHAR U+00C0 +ENCODING 192 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +40 +20 +70 +B0 +F0 +B0 +00 +00 +ENDCHAR + +STARTCHAR U+00C1 +ENCODING 193 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +10 +20 +70 +B0 +F0 +B0 +00 +00 +ENDCHAR + +STARTCHAR U+00C2 +ENCODING 194 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +20 +50 +00 +70 +B0 +F0 +B0 +00 +00 +ENDCHAR + +STARTCHAR U+00C3 +ENCODING 195 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +D0 +B0 +00 +70 +B0 +F0 +B0 +00 +00 +ENDCHAR + +STARTCHAR U+00C4 +ENCODING 196 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +90 +00 +20 +70 +B0 +F0 +B0 +00 +00 +ENDCHAR + +STARTCHAR U+00C5 +ENCODING 197 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +60 +B0 +60 +B0 +F0 +B0 +00 +00 +ENDCHAR + +STARTCHAR U+00C6 +ENCODING 198 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +70 +A0 +F0 +A0 +B0 +00 +00 +ENDCHAR + +STARTCHAR U+00C7 +ENCODING 199 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +70 +C0 +C0 +C0 +70 +20 +60 +ENDCHAR + +STARTCHAR U+00C8 +ENCODING 200 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +80 +40 +F0 +C0 +E0 +C0 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00C9 +ENCODING 201 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +10 +20 +F0 +C0 +E0 +C0 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00CA +ENCODING 202 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +40 +A0 +F0 +C0 +E0 +C0 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00CB +ENCODING 203 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +A0 +00 +F0 +C0 +E0 +C0 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00CC +ENCODING 204 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +80 +40 +F0 +60 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00CD +ENCODING 205 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +10 +20 +F0 +60 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00CE +ENCODING 206 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +40 +A0 +F0 +60 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00CF +ENCODING 207 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +A0 +00 +F0 +60 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00D0 +ENCODING 208 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +E0 +50 +D0 +50 +E0 +00 +00 +ENDCHAR + +STARTCHAR U+00D1 +ENCODING 209 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +D0 +B0 +00 +D0 +F0 +B0 +B0 +00 +00 +ENDCHAR + +STARTCHAR U+00D2 +ENCODING 210 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +80 +40 +60 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00D3 +ENCODING 211 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +10 +20 +60 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00D4 +ENCODING 212 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +40 +A0 +60 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00D5 +ENCODING 213 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +D0 +B0 +00 +60 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00D6 +ENCODING 214 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +A0 +00 +60 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00D7 +ENCODING 215 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +D0 +60 +D0 +00 +00 +00 +ENDCHAR + +STARTCHAR U+00D8 +ENCODING 216 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +10 +60 +D0 +D0 +D0 +60 +80 +00 +ENDCHAR + +STARTCHAR U+00D9 +ENCODING 217 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +80 +40 +D0 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00DA +ENCODING 218 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +20 +40 +D0 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00DB +ENCODING 219 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +40 +A0 +D0 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00DC +ENCODING 220 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +A0 +00 +D0 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00DD +ENCODING 221 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +20 +40 +D0 +D0 +60 +60 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00DE +ENCODING 222 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +C0 +E0 +D0 +E0 +C0 +00 +00 +ENDCHAR + +STARTCHAR U+00DF +ENCODING 223 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +70 +D0 +E0 +D0 +E0 +00 +00 +ENDCHAR + +STARTCHAR U+00E0 +ENCODING 224 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +80 +40 +70 +B0 +B0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+00E1 +ENCODING 225 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +10 +20 +70 +B0 +B0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+00E2 +ENCODING 226 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +40 +A0 +00 +70 +B0 +B0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+00E3 +ENCODING 227 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +D0 +B0 +00 +70 +B0 +B0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+00E4 +ENCODING 228 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +A0 +00 +70 +B0 +B0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+00E5 +ENCODING 229 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +60 +B0 +60 +B0 +B0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+00E6 +ENCODING 230 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +F0 +70 +A0 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00E7 +ENCODING 231 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +00 +70 +C0 +C0 +70 +20 +60 +ENDCHAR + +STARTCHAR U+00E8 +ENCODING 232 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +80 +40 +70 +B0 +E0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+00E9 +ENCODING 233 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +10 +20 +70 +B0 +E0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+00EA +ENCODING 234 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +40 +A0 +00 +70 +B0 +E0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+00EB +ENCODING 235 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +A0 +00 +70 +B0 +E0 +70 +00 +00 +ENDCHAR + +STARTCHAR U+00EC +ENCODING 236 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +80 +40 +E0 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00ED +ENCODING 237 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +10 +20 +E0 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00EE +ENCODING 238 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +40 +A0 +00 +E0 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00EF +ENCODING 239 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +A0 +00 +E0 +60 +60 +F0 +00 +00 +ENDCHAR + +STARTCHAR U+00F0 +ENCODING 240 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +40 +F0 +20 +60 +B0 +B0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00F1 +ENCODING 241 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +D0 +B0 +00 +E0 +D0 +D0 +D0 +00 +00 +ENDCHAR + +STARTCHAR U+00F2 +ENCODING 242 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +80 +40 +60 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00F3 +ENCODING 243 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +10 +20 +60 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00F4 +ENCODING 244 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +40 +A0 +00 +60 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00F5 +ENCODING 245 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +D0 +B0 +00 +60 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00F6 +ENCODING 246 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +A0 +00 +60 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00F7 +ENCODING 247 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +60 +00 +F0 +00 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00F8 +ENCODING 248 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +00 +10 +60 +D0 +D0 +60 +80 +00 +ENDCHAR + +STARTCHAR U+00F9 +ENCODING 249 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +80 +40 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00FA +ENCODING 250 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +20 +40 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00FB +ENCODING 251 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +40 +A0 +00 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00FC +ENCODING 252 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +A0 +00 +D0 +D0 +D0 +60 +00 +00 +ENDCHAR + +STARTCHAR U+00FD +ENCODING 253 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +20 +40 +D0 +D0 +D0 +70 +30 +60 +ENDCHAR + +STARTCHAR U+00FE +ENCODING 254 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +C0 +C0 +E0 +D0 +D0 +E0 +C0 +C0 +ENDCHAR + +STARTCHAR U+00FF +ENCODING 255 +SWIDTH 392 0 +DWIDTH 5 0 +BBX 5 9 0 -2 +BITMAP +00 +A0 +00 +D0 +D0 +D0 +70 +30 +60 +ENDCHAR + +ENDFONT diff --git a/tests/components/font/common.yaml b/tests/components/font/common.yaml index 5be9faf5be..fb50fc3336 100644 --- a/tests/components/font/common.yaml +++ b/tests/components/font/common.yaml @@ -43,6 +43,9 @@ font: id: default_font - file: $component_dir/x11.pcf id: pcf_font + - file: $component_dir/Tamzen5x9b.bdf + id: bdf_font + size: 7 i2c: scl: ${i2c_scl} From e7d1072c85d80908835689fd9f8b1611dbdfdad7 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Mon, 24 Mar 2025 19:04:25 -0400 Subject: [PATCH 36/88] [core] Fix s2 build after crc header fix (#8459) --- esphome/core/helpers.cpp | 8 +++++--- tests/components/pipsolar/test.esp32-s2-idf.yaml | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 tests/components/pipsolar/test.esp32-s2-idf.yaml diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp index e69f166600..1472726d31 100644 --- a/esphome/core/helpers.cpp +++ b/esphome/core/helpers.cpp @@ -70,7 +70,9 @@ static const uint16_t CRC16_8408_LE_LUT_L[] = {0x0000, 0x1189, 0x2312, 0x329b, 0 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7}; static const uint16_t CRC16_8408_LE_LUT_H[] = {0x0000, 0x1081, 0x2102, 0x3183, 0x4204, 0x5285, 0x6306, 0x7387, 0x8408, 0x9489, 0xa50a, 0xb58b, 0xc60c, 0xd68d, 0xe70e, 0xf78f}; +#endif +#if !defined(USE_ESP32) || defined(USE_ESP32_VARIANT_ESP32S2) static const uint16_t CRC16_1021_BE_LUT_L[] = {0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef}; static const uint16_t CRC16_1021_BE_LUT_H[] = {0x0000, 0x1231, 0x2462, 0x3653, 0x48c4, 0x5af5, 0x6ca6, 0x7e97, @@ -151,7 +153,7 @@ uint16_t crc16(const uint8_t *data, uint16_t len, uint16_t crc, uint16_t reverse } uint16_t crc16be(const uint8_t *data, uint16_t len, uint16_t crc, uint16_t poly, bool refin, bool refout) { -#ifdef USE_ESP32 +#if defined(USE_ESP32) && !defined(USE_ESP32_VARIANT_ESP32S2) if (poly == 0x1021) { crc = crc16_be(refin ? crc : (crc ^ 0xffff), data, len); return refout ? crc : (crc ^ 0xffff); @@ -160,7 +162,7 @@ uint16_t crc16be(const uint8_t *data, uint16_t len, uint16_t crc, uint16_t poly, if (refin) { crc ^= 0xffff; } -#ifndef USE_ESP32 +#if !defined(USE_ESP32) || defined(USE_ESP32_VARIANT_ESP32S2) if (poly == 0x1021) { while (len--) { uint8_t combo = (crc >> 8) ^ *data++; @@ -178,7 +180,7 @@ uint16_t crc16be(const uint8_t *data, uint16_t len, uint16_t crc, uint16_t poly, } } } -#ifndef USE_ESP32 +#if !defined(USE_ESP32) || defined(USE_ESP32_VARIANT_ESP32S2) } #endif return refout ? (crc ^ 0xffff) : crc; diff --git a/tests/components/pipsolar/test.esp32-s2-idf.yaml b/tests/components/pipsolar/test.esp32-s2-idf.yaml new file mode 100644 index 0000000000..b516342f3b --- /dev/null +++ b/tests/components/pipsolar/test.esp32-s2-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + tx_pin: GPIO4 + rx_pin: GPIO5 + +<<: !include common.yaml From ce2e96600505f8c9416c1b07205753b631e78719 Mon Sep 17 00:00:00 2001 From: Samuel Sieb Date: Tue, 25 Mar 2025 01:33:53 -0700 Subject: [PATCH 37/88] fix 1bpp rendering (#8463) --- esphome/components/font/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esphome/components/font/__init__.py b/esphome/components/font/__init__.py index a405761c74..be88fdb957 100644 --- a/esphome/components/font/__init__.py +++ b/esphome/components/font/__init__.py @@ -12,8 +12,8 @@ import esphome_glyphsets as glyphsets from freetype import ( FT_LOAD_NO_BITMAP, FT_LOAD_RENDER, + FT_LOAD_TARGET_MONO, Face, - ft_pixel_mode_grays, ft_pixel_mode_mono, ) import requests @@ -509,7 +509,6 @@ async def to_code(config): glyph_args = {} data = [] bpp = config[CONF_BPP] - mode = ft_pixel_mode_grays scale = 256 // (1 << bpp) size = config[CONF_SIZE] # create the data array for all glyphs @@ -524,8 +523,9 @@ async def to_code(config): flags = FT_LOAD_RENDER if bpp != 1: flags |= FT_LOAD_NO_BITMAP + else: + flags |= FT_LOAD_TARGET_MONO font.load_char(codepoint, flags) - font.glyph.render(mode) width = font.glyph.bitmap.width height = font.glyph.bitmap.rows buffer = font.glyph.bitmap.buffer From fb9a15f0af0ad4f5cd67624c5b38219b27119852 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Tue, 25 Mar 2025 11:16:12 -0500 Subject: [PATCH 38/88] [media_player] Don't reset enqueue command (#8465) --- esphome/components/media_player/media_player.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphome/components/media_player/media_player.cpp b/esphome/components/media_player/media_player.cpp index 01304d9135..32da7ee265 100644 --- a/esphome/components/media_player/media_player.cpp +++ b/esphome/components/media_player/media_player.cpp @@ -56,7 +56,8 @@ const char *media_player_command_to_string(MediaPlayerCommand command) { void MediaPlayerCall::validate_() { if (this->media_url_.has_value()) { - if (this->command_.has_value()) { + if (this->command_.has_value() && this->command_.value() != MEDIA_PLAYER_COMMAND_ENQUEUE) { + // Don't remove an enqueue command ESP_LOGW(TAG, "MediaPlayerCall: Setting both command and media_url is not needed."); this->command_.reset(); } From 63221d7a1fb2e5502b8c753077f792d192d396ff Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Tue, 25 Mar 2025 15:20:56 -0500 Subject: [PATCH 39/88] [speaker] Bugfix: Fix rapidly adding items to playlist (#8466) Co-authored-by: Keith Burzinski --- .../media_player/speaker_media_player.cpp | 83 +++++-------------- .../media_player/speaker_media_player.h | 8 +- 2 files changed, 25 insertions(+), 66 deletions(-) diff --git a/esphome/components/speaker/media_player/speaker_media_player.cpp b/esphome/components/speaker/media_player/speaker_media_player.cpp index 0a2585ce60..80ddfb2f04 100644 --- a/esphome/components/speaker/media_player/speaker_media_player.cpp +++ b/esphome/components/speaker/media_player/speaker_media_player.cpp @@ -138,77 +138,48 @@ void SpeakerMediaPlayer::watch_media_commands_() { } MediaCallCommand media_command; - esp_err_t err = ESP_OK; if (xQueueReceive(this->media_control_command_queue_, &media_command, 0) == pdTRUE) { - bool new_url = media_command.new_url.has_value() && media_command.new_url.value(); - bool new_file = media_command.new_file.has_value() && media_command.new_file.value(); + bool enqueue = media_command.enqueue.has_value() && media_command.enqueue.value(); - if (new_url || new_file) { - bool enqueue = media_command.enqueue.has_value() && media_command.enqueue.value(); + if (media_command.url.has_value() || media_command.file.has_value()) { + PlaylistItem playlist_item; + if (media_command.url.has_value()) { + playlist_item.url = *media_command.url.value(); + delete media_command.url.value(); + } + if (media_command.file.has_value()) { + playlist_item.file = media_command.file.value(); + } if (this->single_pipeline_() || (media_command.announce.has_value() && media_command.announce.value())) { - // Announcement playlist/pipeline - if (!enqueue) { - // Clear the queue and ensure the loaded next item doesn't start playing + // Ensure the loaded next item doesn't start playing, clear the queue, start the file, and unpause this->cancel_timeout("next_ann"); this->announcement_playlist_.clear(); - } - - PlaylistItem playlist_item; - if (new_url) { - playlist_item.url = this->announcement_url_; - if (!enqueue) { - // Not adding to the queue, so directly start playback and internally unpause the pipeline - this->announcement_pipeline_->start_url(playlist_item.url.value()); - this->announcement_pipeline_->set_pause_state(false); - } - } else { - playlist_item.file = this->announcement_file_; - if (!enqueue) { - // Not adding to the queue, so directly start playback and internally unpause the pipeline + if (media_command.file.has_value()) { this->announcement_pipeline_->start_file(playlist_item.file.value()); - this->announcement_pipeline_->set_pause_state(false); + } else if (media_command.url.has_value()) { + this->announcement_pipeline_->start_url(playlist_item.url.value()); } + this->announcement_pipeline_->set_pause_state(false); } this->announcement_playlist_.push_back(playlist_item); } else { - // Media playlist/pipeline - if (!enqueue) { - // Clear the queue and ensure the loaded next item doesn't start playing + // Ensure the loaded next item doesn't start playing, clear the queue, start the file, and unpause this->cancel_timeout("next_media"); this->media_playlist_.clear(); - } - - this->is_paused_ = false; - PlaylistItem playlist_item; - if (new_url) { - playlist_item.url = this->media_url_; - if (!enqueue) { - // Not adding to the queue, so directly start playback and internally unpause the pipeline - this->media_pipeline_->start_url(playlist_item.url.value()); - this->media_pipeline_->set_pause_state(false); - } - } else { - playlist_item.file = this->media_file_; - if (!enqueue) { - // Not adding to the queue, so directly start playback and internally unpause the pipeline + if (media_command.file.has_value()) { this->media_pipeline_->start_file(playlist_item.file.value()); - this->media_pipeline_->set_pause_state(false); + } else if (media_command.url.has_value()) { + this->media_pipeline_->start_url(playlist_item.url.value()); } + this->media_pipeline_->set_pause_state(false); } this->media_playlist_.push_back(playlist_item); } - if (err != ESP_OK) { - ESP_LOGE(TAG, "Error starting the audio pipeline: %s", esp_err_to_name(err)); - this->status_set_error(); - } else { - this->status_clear_error(); - } - return; // Don't process the new file play command further } @@ -429,12 +400,10 @@ void SpeakerMediaPlayer::play_file(audio::AudioFile *media_file, bool announceme MediaCallCommand media_command; - media_command.new_file = true; + media_command.file = media_file; if (this->single_pipeline_() || announcement) { - this->announcement_file_ = media_file; media_command.announce = true; } else { - this->media_file_ = media_file; media_command.announce = false; } media_command.enqueue = enqueue; @@ -456,14 +425,8 @@ void SpeakerMediaPlayer::control(const media_player::MediaPlayerCall &call) { } if (call.get_media_url().has_value()) { - std::string new_uri = call.get_media_url().value(); - - media_command.new_url = true; - if (this->single_pipeline_() || (call.get_announcement().has_value() && call.get_announcement().value())) { - this->announcement_url_ = new_uri; - } else { - this->media_url_ = new_uri; - } + media_command.url = new std::string( + call.get_media_url().value()); // Must be manually deleted after receiving media_command from a queue if (call.get_command().has_value()) { if (call.get_command().value() == media_player::MEDIA_PLAYER_COMMAND_ENQUEUE) { diff --git a/esphome/components/speaker/media_player/speaker_media_player.h b/esphome/components/speaker/media_player/speaker_media_player.h index 6cbce91866..81eb72a830 100644 --- a/esphome/components/speaker/media_player/speaker_media_player.h +++ b/esphome/components/speaker/media_player/speaker_media_player.h @@ -24,8 +24,8 @@ struct MediaCallCommand { optional command; optional volume; optional announce; - optional new_url; - optional new_file; + optional url; // Must be manually deleted after receiving this struct from a queue + optional file; optional enqueue; }; @@ -109,15 +109,11 @@ class SpeakerMediaPlayer : public Component, public media_player::MediaPlayer { optional media_format_; AudioPipelineState media_pipeline_state_{AudioPipelineState::STOPPED}; - std::string media_url_{}; // only modified by control function - audio::AudioFile *media_file_{}; // only modified by play_file function bool media_repeat_one_{false}; uint32_t media_playlist_delay_ms_{0}; optional announcement_format_; AudioPipelineState announcement_pipeline_state_{AudioPipelineState::STOPPED}; - std::string announcement_url_{}; // only modified by control function - audio::AudioFile *announcement_file_{}; // only modified by play_file function bool announcement_repeat_one_{false}; uint32_t announcement_playlist_delay_ms_{0}; From 2dfd28ba3e3c558ffacd9dc003c84ef7ce142d4f Mon Sep 17 00:00:00 2001 From: Keith Burzinski Date: Tue, 25 Mar 2025 15:21:10 -0500 Subject: [PATCH 40/88] [ld2450] Fix bluetooth state not reported correctly (#8458) --- esphome/components/ld2450/ld2450.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/esphome/components/ld2450/ld2450.cpp b/esphome/components/ld2450/ld2450.cpp index 5bd7635dec..3db065ba1a 100644 --- a/esphome/components/ld2450/ld2450.cpp +++ b/esphome/components/ld2450/ld2450.cpp @@ -15,6 +15,7 @@ namespace esphome { namespace ld2450 { static const char *const TAG = "ld2450"; +static const char *const NO_MAC("08:05:04:03:02:01"); static const char *const UNKNOWN_MAC("unknown"); // LD2450 UART Serial Commands @@ -614,12 +615,12 @@ bool LD2450Component::handle_ack_data_(uint8_t *buffer, uint8_t len) { ESP_LOGV(TAG, "MAC address: %s", this->mac_.c_str()); #ifdef USE_TEXT_SENSOR if (this->mac_text_sensor_ != nullptr) { - this->mac_text_sensor_->publish_state(this->mac_); + this->mac_text_sensor_->publish_state(this->mac_ == NO_MAC ? UNKNOWN_MAC : this->mac_); } #endif #ifdef USE_SWITCH if (this->bluetooth_switch_ != nullptr) { - this->bluetooth_switch_->publish_state(this->mac_ != UNKNOWN_MAC); + this->bluetooth_switch_->publish_state(this->mac_ != NO_MAC); } #endif break; From 4bb59ce1d16bcb81bab5a2e4ad54f759fc2846e1 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 26 Mar 2025 05:06:23 +0100 Subject: [PATCH 41/88] [esp32_can] Configurable enqueue timeout (#8453) --- esphome/components/canbus/__init__.py | 11 +++++++++++ esphome/components/canbus/canbus.cpp | 8 +++++++- esphome/components/esp32_can/canbus.py | 21 +++++++++++++++++++++ esphome/components/esp32_can/esp32_can.cpp | 2 +- esphome/components/esp32_can/esp32_can.h | 4 ++++ 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/esphome/components/canbus/__init__.py b/esphome/components/canbus/__init__.py index cb3634917e..6867177795 100644 --- a/esphome/components/canbus/__init__.py +++ b/esphome/components/canbus/__init__.py @@ -1,3 +1,4 @@ +import re from esphome import automation import esphome.codegen as cg import esphome.config_validation as cv @@ -68,6 +69,16 @@ CAN_SPEEDS = { "800KBPS": CanSpeed.CAN_800KBPS, "1000KBPS": CanSpeed.CAN_1000KBPS, } + + +def get_rate(value): + match = re.match(r"(\d+)(?:K(\d+)?)?BPS", value, re.IGNORECASE) + if not match: + raise ValueError(f"Invalid rate format: {value}") + fraction = match.group(2) or "0" + return int((float(match.group(1)) + float(f"0.{fraction}")) * 1000) + + CANBUS_SCHEMA = cv.Schema( { cv.GenerateID(): cv.declare_id(CanbusComponent), diff --git a/esphome/components/canbus/canbus.cpp b/esphome/components/canbus/canbus.cpp index 73b86cba87..696cfff2b7 100644 --- a/esphome/components/canbus/canbus.cpp +++ b/esphome/components/canbus/canbus.cpp @@ -46,7 +46,13 @@ void Canbus::send_data(uint32_t can_id, bool use_extended_id, bool remote_transm ESP_LOGVV(TAG, " data[%d]=%02x", i, can_message.data[i]); } - this->send_message(&can_message); + if (this->send_message(&can_message) != canbus::ERROR_OK) { + if (use_extended_id) { + ESP_LOGW(TAG, "send to extended id=0x%08" PRIx32 " failed!", can_id); + } else { + ESP_LOGW(TAG, "send to standard id=0x%03" PRIx32 " failed!", can_id); + } + } } void Canbus::add_trigger(CanbusTrigger *trigger) { diff --git a/esphome/components/esp32_can/canbus.py b/esphome/components/esp32_can/canbus.py index 37bdfa3962..dfa98b2eff 100644 --- a/esphome/components/esp32_can/canbus.py +++ b/esphome/components/esp32_can/canbus.py @@ -1,3 +1,5 @@ +import math + from esphome import pins import esphome.codegen as cg from esphome.components import canbus @@ -23,6 +25,8 @@ from esphome.const import ( CODEOWNERS = ["@Sympatron"] DEPENDENCIES = ["esp32"] +CONF_TX_ENQUEUE_TIMEOUT = "tx_enqueue_timeout" + esp32_can_ns = cg.esphome_ns.namespace("esp32_can") esp32_can = esp32_can_ns.class_("ESP32Can", CanbusComponent) @@ -84,10 +88,20 @@ CONFIG_SCHEMA = canbus.CANBUS_SCHEMA.extend( cv.Required(CONF_TX_PIN): pins.internal_gpio_output_pin_number, cv.Optional(CONF_RX_QUEUE_LEN): cv.uint32_t, cv.Optional(CONF_TX_QUEUE_LEN): cv.uint32_t, + cv.Optional(CONF_TX_ENQUEUE_TIMEOUT): cv.positive_time_period_milliseconds, } ) +def get_default_tx_enqueue_timeout(bit_rate): + bit_rate_numeric = canbus.get_rate(bit_rate) + bits_per_packet = 140 # ~max CAN message length + ms_per_packet = bits_per_packet / bit_rate_numeric * 1000 + return int( + max(min(math.ceil(10 * ms_per_packet), 1000), 1) + ) # ~10 packet lengths, min 1ms, max 1000ms + + async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) await canbus.register_canbus(var, config) @@ -98,3 +112,10 @@ async def to_code(config): cg.add(var.set_rx_queue_len(rx_queue_len)) if (tx_queue_len := config.get(CONF_TX_QUEUE_LEN)) is not None: cg.add(var.set_tx_queue_len(tx_queue_len)) + + if CONF_TX_ENQUEUE_TIMEOUT in config: + tx_enqueue_timeout_ms = config[CONF_TX_ENQUEUE_TIMEOUT].total_milliseconds + else: + tx_enqueue_timeout_ms = get_default_tx_enqueue_timeout(config[CONF_BIT_RATE]) + + cg.add(var.set_tx_enqueue_timeout_ms(tx_enqueue_timeout_ms)) diff --git a/esphome/components/esp32_can/esp32_can.cpp b/esphome/components/esp32_can/esp32_can.cpp index 5a45859b1f..a40f493075 100644 --- a/esphome/components/esp32_can/esp32_can.cpp +++ b/esphome/components/esp32_can/esp32_can.cpp @@ -124,7 +124,7 @@ canbus::Error ESP32Can::send_message(struct canbus::CanFrame *frame) { memcpy(message.data, frame->data, frame->can_data_length_code); } - if (twai_transmit(&message, pdMS_TO_TICKS(1000)) == ESP_OK) { + if (twai_transmit(&message, this->tx_enqueue_timeout_ticks_) == ESP_OK) { return canbus::ERROR_OK; } else { return canbus::ERROR_ALLTXBUSY; diff --git a/esphome/components/esp32_can/esp32_can.h b/esphome/components/esp32_can/esp32_can.h index b3086f9a48..416f037083 100644 --- a/esphome/components/esp32_can/esp32_can.h +++ b/esphome/components/esp32_can/esp32_can.h @@ -14,6 +14,9 @@ class ESP32Can : public canbus::Canbus { void set_tx(int tx) { tx_ = tx; } void set_tx_queue_len(uint32_t tx_queue_len) { this->tx_queue_len_ = tx_queue_len; } void set_rx_queue_len(uint32_t rx_queue_len) { this->rx_queue_len_ = rx_queue_len; } + void set_tx_enqueue_timeout_ms(uint32_t tx_enqueue_timeout_ms) { + this->tx_enqueue_timeout_ticks_ = pdMS_TO_TICKS(tx_enqueue_timeout_ms); + } ESP32Can(){}; protected: @@ -23,6 +26,7 @@ class ESP32Can : public canbus::Canbus { int rx_{-1}; int tx_{-1}; + TickType_t tx_enqueue_timeout_ticks_{}; optional tx_queue_len_{}; optional rx_queue_len_{}; }; From ccd55a8e84a01b8262c230941333226cbefc0cb4 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 27 Mar 2025 11:31:55 +1100 Subject: [PATCH 42/88] [display] Don't assume glyph x_offset is zero. (#8473) --- esphome/components/display/display.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/display/display.cpp b/esphome/components/display/display.cpp index b12a81e050..a13464ce1b 100644 --- a/esphome/components/display/display.cpp +++ b/esphome/components/display/display.cpp @@ -555,10 +555,10 @@ void Display::get_text_bounds(int x, int y, const char *text, BaseFont *font, Te switch (x_align) { case TextAlign::RIGHT: - *x1 = x - *width; + *x1 = x - *width - x_offset; break; case TextAlign::CENTER_HORIZONTAL: - *x1 = x - (*width) / 2; + *x1 = x - (*width + x_offset) / 2; break; case TextAlign::LEFT: default: From 58fe8b39b20c8fe9767107a6136ca30873b82056 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Thu, 27 Mar 2025 18:09:22 +1100 Subject: [PATCH 43/88] [scheduler] Properly handle millis() overflow (#8197) --- esphome/const.py | 1 + esphome/core/component.h | 11 +- esphome/core/config.py | 4 + esphome/core/defines.h | 1 + esphome/core/scheduler.cpp | 101 ++++++------------ esphome/core/scheduler.h | 24 ++--- tests/components/esphome/common.yaml | 20 ++++ tests/components/esphome/test.esp32-ard.yaml | 2 + .../components/esphome/test.esp32-c3-ard.yaml | 2 + .../components/esphome/test.esp32-c3-idf.yaml | 1 + tests/components/esphome/test.esp32-idf.yaml | 1 + .../components/esphome/test.esp8266-ard.yaml | 1 + tests/components/esphome/test.host.yaml | 1 + tests/components/esphome/test.rp2040-ard.yaml | 1 + 14 files changed, 85 insertions(+), 86 deletions(-) create mode 100644 tests/components/esphome/common.yaml create mode 100644 tests/components/esphome/test.esp32-ard.yaml create mode 100644 tests/components/esphome/test.esp32-c3-ard.yaml create mode 100644 tests/components/esphome/test.esp32-c3-idf.yaml create mode 100644 tests/components/esphome/test.esp32-idf.yaml create mode 100644 tests/components/esphome/test.esp8266-ard.yaml create mode 100644 tests/components/esphome/test.host.yaml create mode 100644 tests/components/esphome/test.rp2040-ard.yaml diff --git a/esphome/const.py b/esphome/const.py index f3fda8f1d6..5b3d258cc8 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -196,6 +196,7 @@ CONF_DC_PIN = "dc_pin" CONF_DEASSERT_RTS_DTR = "deassert_rts_dtr" CONF_DEBOUNCE = "debounce" CONF_DEBUG = "debug" +CONF_DEBUG_SCHEDULER = "debug_scheduler" CONF_DECAY_MODE = "decay_mode" CONF_DECELERATION = "deceleration" CONF_DEFAULT_MODE = "default_mode" diff --git a/esphome/core/component.h b/esphome/core/component.h index a6bd8f81ac..e6ed55efb7 100644 --- a/esphome/core/component.h +++ b/esphome/core/component.h @@ -165,10 +165,17 @@ class Component { * This will call f every interval ms. Can be cancelled via CancelInterval(). * Similar to javascript's setInterval(). * - * IMPORTANT: Do not rely on this having correct timing. This is only called from - * loop() and therefore can be significantly delay. If you need exact timing please + * IMPORTANT NOTE: + * The only guarantee offered by this call is that the callback will be called no *earlier* than + * the specified interval after the previous call. Any given interval may be longer due to + * other components blocking the loop() call. + * + * So do not rely on this having correct timing. If you need exact timing please * use hardware timers. * + * Note also that the first call to f will not happen immediately, but after a random delay. This is + * intended to prevent many interval functions from being called at the same time. + * * @param name The identifier for this interval function. * @param interval The interval in ms. * @param f The function (or lambda) that should be called diff --git a/esphome/core/config.py b/esphome/core/config.py index f2b8585143..72e9f6a65c 100644 --- a/esphome/core/config.py +++ b/esphome/core/config.py @@ -10,6 +10,7 @@ from esphome.const import ( CONF_BUILD_PATH, CONF_COMMENT, CONF_COMPILE_PROCESS_LIMIT, + CONF_DEBUG_SCHEDULER, CONF_ESPHOME, CONF_FRIENDLY_NAME, CONF_INCLUDES, @@ -144,6 +145,7 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_INCLUDES, default=[]): cv.ensure_list(valid_include), cv.Optional(CONF_LIBRARIES, default=[]): cv.ensure_list(cv.string_strict), cv.Optional(CONF_NAME_ADD_MAC_SUFFIX, default=False): cv.boolean, + cv.Optional(CONF_DEBUG_SCHEDULER, default=False): cv.boolean, cv.Optional(CONF_PROJECT): cv.Schema( { cv.Required(CONF_NAME): cv.All( @@ -369,6 +371,8 @@ async def to_code(config): cg.add_build_flag("-Wno-unused-variable") cg.add_build_flag("-Wno-unused-but-set-variable") cg.add_build_flag("-Wno-sign-compare") + if config[CONF_DEBUG_SCHEDULER]: + cg.add_define("ESPHOME_DEBUG_SCHEDULER") if CORE.using_arduino and not CORE.is_bk72xx: CORE.add_job(add_arduino_global_workaround) diff --git a/esphome/core/defines.h b/esphome/core/defines.h index 7bc84a22dc..50a0847b78 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -13,6 +13,7 @@ #define ESPHOME_PROJECT_VERSION "v2" #define ESPHOME_PROJECT_VERSION_30 "v2" #define ESPHOME_VARIANT "ESP32" +#define ESPHOME_DEBUG_SCHEDULER // logger #define ESPHOME_LOG_LEVEL ESPHOME_LOG_LEVEL_VERY_VERBOSE diff --git a/esphome/core/scheduler.cpp b/esphome/core/scheduler.cpp index 012c9af3c6..7e83b3b705 100644 --- a/esphome/core/scheduler.cpp +++ b/esphome/core/scheduler.cpp @@ -1,4 +1,5 @@ #include "scheduler.h" +#include "esphome/core/defines.h" #include "esphome/core/log.h" #include "esphome/core/helpers.h" #include "esphome/core/hal.h" @@ -21,7 +22,7 @@ static const uint32_t MAX_LOGICALLY_DELETED_ITEMS = 10; void HOT Scheduler::set_timeout(Component *component, const std::string &name, uint32_t timeout, std::function func) { - const uint32_t now = this->millis_(); + const auto now = this->millis_(); if (!name.empty()) this->cancel_timeout(component, name); @@ -29,17 +30,16 @@ void HOT Scheduler::set_timeout(Component *component, const std::string &name, u if (timeout == SCHEDULER_DONT_RUN) return; - ESP_LOGVV(TAG, "set_timeout(name='%s', timeout=%" PRIu32 ")", name.c_str(), timeout); - auto item = make_unique(); item->component = component; item->name = name; item->type = SchedulerItem::TIMEOUT; - item->timeout = timeout; - item->last_execution = now; - item->last_execution_major = this->millis_major_; + item->next_execution_ = now + timeout; item->callback = std::move(func); item->remove = false; +#ifdef ESPHOME_DEBUG_SCHEDULER + ESP_LOGD(TAG, "set_timeout(name='%s/%s', timeout=%" PRIu32 ")", item->get_source(), name.c_str(), timeout); +#endif this->push_(std::move(item)); } bool HOT Scheduler::cancel_timeout(Component *component, const std::string &name) { @@ -47,7 +47,7 @@ bool HOT Scheduler::cancel_timeout(Component *component, const std::string &name } void HOT Scheduler::set_interval(Component *component, const std::string &name, uint32_t interval, std::function func) { - const uint32_t now = this->millis_(); + const auto now = this->millis_(); if (!name.empty()) this->cancel_interval(component, name); @@ -60,19 +60,18 @@ void HOT Scheduler::set_interval(Component *component, const std::string &name, if (interval != 0) offset = (random_uint32() % interval) / 2; - ESP_LOGVV(TAG, "set_interval(name='%s', interval=%" PRIu32 ", offset=%" PRIu32 ")", name.c_str(), interval, offset); - auto item = make_unique(); item->component = component; item->name = name; item->type = SchedulerItem::INTERVAL; item->interval = interval; - item->last_execution = now - offset - interval; - item->last_execution_major = this->millis_major_; - if (item->last_execution > now) - item->last_execution_major--; + item->next_execution_ = now + offset; item->callback = std::move(func); item->remove = false; +#ifdef ESPHOME_DEBUG_SCHEDULER + ESP_LOGD(TAG, "set_interval(name='%s/%s', interval=%" PRIu32 ", offset=%" PRIu32 ")", item->get_source(), + name.c_str(), interval, offset); +#endif this->push_(std::move(item)); } bool HOT Scheduler::cancel_interval(Component *component, const std::string &name) { @@ -138,36 +137,36 @@ optional HOT Scheduler::next_schedule_in() { if (this->empty_()) return {}; auto &item = this->items_[0]; - const uint32_t now = this->millis_(); - uint32_t next_time = item->last_execution + item->interval; - if (next_time < now) + const auto now = this->millis_(); + if (item->next_execution_ < now) return 0; - return next_time - now; + return item->next_execution_ - now; } void HOT Scheduler::call() { - const uint32_t now = this->millis_(); + const auto now = this->millis_(); this->process_to_add(); #ifdef ESPHOME_DEBUG_SCHEDULER - static uint32_t last_print = 0; + static uint64_t last_print = 0; if (now - last_print > 2000) { last_print = now; std::vector> old_items; - ESP_LOGVV(TAG, "Items: count=%u, now=%" PRIu32, this->items_.size(), now); + ESP_LOGD(TAG, "Items: count=%u, now=%" PRIu64 " (%u, %" PRIu32 ")", this->items_.size(), now, this->millis_major_, + this->last_millis_); while (!this->empty_()) { this->lock_.lock(); auto item = std::move(this->items_[0]); this->pop_raw_(); this->lock_.unlock(); - ESP_LOGVV(TAG, " %s '%s' interval=%" PRIu32 " last_execution=%" PRIu32 " (%u) next=%" PRIu32 " (%u)", - item->get_type_str(), item->name.c_str(), item->interval, item->last_execution, - item->last_execution_major, item->next_execution(), item->next_execution_major()); + ESP_LOGD(TAG, " %s '%s/%s' interval=%" PRIu32 " next_execution in %" PRIu64 "ms at %" PRIu64, + item->get_type_str(), item->get_source(), item->name.c_str(), item->interval, + item->next_execution_ - now, item->next_execution_); old_items.push_back(std::move(item)); } - ESP_LOGVV(TAG, "\n"); + ESP_LOGD(TAG, "\n"); { LockGuard guard{this->lock_}; @@ -206,14 +205,10 @@ void HOT Scheduler::call() { { // Don't copy-by value yet auto &item = this->items_[0]; - if ((now - item->last_execution) < item->interval) { + if (item->next_execution_ > now) { // Not reached timeout yet, done for this call break; } - uint8_t major = item->next_execution_major(); - if (this->millis_major_ - major > 1) - break; - // Don't run on failed components if (item->component != nullptr && item->component->is_failed()) { LockGuard guard{this->lock_}; @@ -221,9 +216,10 @@ void HOT Scheduler::call() { continue; } -#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE - ESP_LOGVV(TAG, "Running %s '%s' with interval=%" PRIu32 " last_execution=%" PRIu32 " (now=%" PRIu32 ")", - item->get_type_str(), item->name.c_str(), item->interval, item->last_execution, now); +#ifdef ESPHOME_DEBUG_SCHEDULER + ESP_LOGV(TAG, "Running %s '%s/%s' with interval=%" PRIu32 " next_execution=%" PRIu64 " (now=%" PRIu64 ")", + item->get_type_str(), item->get_source(), item->name.c_str(), item->interval, item->next_execution_, + now); #endif // Warning: During callback(), a lot of stuff can happen, including: @@ -254,13 +250,7 @@ void HOT Scheduler::call() { } if (item->type == SchedulerItem::INTERVAL) { - if (item->interval != 0) { - const uint32_t before = item->last_execution; - const uint32_t amount = (now - item->last_execution) / item->interval; - item->last_execution += amount * item->interval; - if (item->last_execution < before) - item->last_execution_major++; - } + item->next_execution_ = now + item->interval; this->push_(std::move(item)); } } @@ -322,43 +312,20 @@ bool HOT Scheduler::cancel_item_(Component *component, const std::string &name, return ret; } -uint32_t Scheduler::millis_() { +uint64_t Scheduler::millis_() { const uint32_t now = millis(); if (now < this->last_millis_) { - ESP_LOGD(TAG, "Incrementing scheduler major"); this->millis_major_++; + ESP_LOGD(TAG, "Incrementing scheduler major at %" PRIu64 "ms", + now + (static_cast(this->millis_major_) << 32)); } this->last_millis_ = now; - return now; + return now + (static_cast(this->millis_major_) << 32); } bool HOT Scheduler::SchedulerItem::cmp(const std::unique_ptr &a, const std::unique_ptr &b) { - // min-heap - // return true if *a* will happen after *b* - uint32_t a_next_exec = a->next_execution(); - uint8_t a_next_exec_major = a->next_execution_major(); - uint32_t b_next_exec = b->next_execution(); - uint8_t b_next_exec_major = b->next_execution_major(); - - if (a_next_exec_major != b_next_exec_major) { - // The "major" calculation is quite complicated. - // Basically, we need to check if the major value lies in the future or - // - - // Here are some cases to think about: - // Format: a_major,b_major -> expected result (a-b, b-a) - // a=255,b=0 -> false (255, 1) - // a=0,b=1 -> false (255, 1) - // a=1,b=0 -> true (1, 255) - // a=0,b=255 -> true (1, 255) - - uint8_t diff1 = a_next_exec_major - b_next_exec_major; - uint8_t diff2 = b_next_exec_major - a_next_exec_major; - return diff1 < diff2; - } - - return a_next_exec > b_next_exec; + return a->next_execution_ > b->next_execution_; } } // namespace esphome diff --git a/esphome/core/scheduler.h b/esphome/core/scheduler.h index 44a58f37f5..872a8bd6f6 100644 --- a/esphome/core/scheduler.h +++ b/esphome/core/scheduler.h @@ -32,23 +32,10 @@ class Scheduler { Component *component; std::string name; enum Type { TIMEOUT, INTERVAL } type; - union { - uint32_t interval; - uint32_t timeout; - }; - uint32_t last_execution; + uint32_t interval; + uint64_t next_execution_; std::function callback; bool remove; - uint8_t last_execution_major; - - inline uint32_t next_execution() { return this->last_execution + this->timeout; } - inline uint8_t next_execution_major() { - uint32_t next_exec = this->next_execution(); - uint8_t next_exec_major = this->last_execution_major; - if (next_exec < this->last_execution) - next_exec_major++; - return next_exec_major; - } static bool cmp(const std::unique_ptr &a, const std::unique_ptr &b); const char *get_type_str() { @@ -61,9 +48,12 @@ class Scheduler { return ""; } } + const char *get_source() { + return this->component != nullptr ? this->component->get_component_source() : "unknown"; + } }; - uint32_t millis_(); + uint64_t millis_(); void cleanup_(); void pop_raw_(); void push_(std::unique_ptr item); @@ -77,7 +67,7 @@ class Scheduler { std::vector> items_; std::vector> to_add_; uint32_t last_millis_{0}; - uint8_t millis_major_{0}; + uint16_t millis_major_{0}; uint32_t to_remove_{0}; }; diff --git a/tests/components/esphome/common.yaml b/tests/components/esphome/common.yaml new file mode 100644 index 0000000000..05954e37d7 --- /dev/null +++ b/tests/components/esphome/common.yaml @@ -0,0 +1,20 @@ +esphome: + debug_scheduler: true + platformio_options: + board_build.flash_mode: dio + area: testing + on_boot: + logger.log: on_boot + on_shutdown: + logger.log: on_shutdown + on_loop: + logger.log: on_loop + compile_process_limit: 1 + min_version: "2025.1" + name_add_mac_suffix: true + project: + name: esphome.test + version: "1.1" + on_update: + logger.log: on_update + diff --git a/tests/components/esphome/test.esp32-ard.yaml b/tests/components/esphome/test.esp32-ard.yaml new file mode 100644 index 0000000000..a991f7e15a --- /dev/null +++ b/tests/components/esphome/test.esp32-ard.yaml @@ -0,0 +1,2 @@ +<<: !include common.yaml + diff --git a/tests/components/esphome/test.esp32-c3-ard.yaml b/tests/components/esphome/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..a991f7e15a --- /dev/null +++ b/tests/components/esphome/test.esp32-c3-ard.yaml @@ -0,0 +1,2 @@ +<<: !include common.yaml + diff --git a/tests/components/esphome/test.esp32-c3-idf.yaml b/tests/components/esphome/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/esphome/test.esp32-c3-idf.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/esphome/test.esp32-idf.yaml b/tests/components/esphome/test.esp32-idf.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/esphome/test.esp32-idf.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/esphome/test.esp8266-ard.yaml b/tests/components/esphome/test.esp8266-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/esphome/test.esp8266-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/esphome/test.host.yaml b/tests/components/esphome/test.host.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/esphome/test.host.yaml @@ -0,0 +1 @@ +<<: !include common.yaml diff --git a/tests/components/esphome/test.rp2040-ard.yaml b/tests/components/esphome/test.rp2040-ard.yaml new file mode 100644 index 0000000000..dade44d145 --- /dev/null +++ b/tests/components/esphome/test.rp2040-ard.yaml @@ -0,0 +1 @@ +<<: !include common.yaml From 2e16dd788ceaa8f3655884c4bef6487836e4266e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 28 Mar 2025 18:29:53 -1000 Subject: [PATCH 44/88] Bump ESP mdns to 1.8.2 (#8482) --- esphome/components/mdns/__init__.py | 2 +- esphome/idf_component.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/esphome/components/mdns/__init__.py b/esphome/components/mdns/__init__.py index 9a198280dd..e8902d5222 100644 --- a/esphome/components/mdns/__init__.py +++ b/esphome/components/mdns/__init__.py @@ -91,7 +91,7 @@ async def to_code(config): add_idf_component( name="mdns", repo="https://github.com/espressif/esp-protocols.git", - ref="mdns-v1.8.0", + ref="mdns-v1.8.2", path="components/mdns", ) diff --git a/esphome/idf_component.yml b/esphome/idf_component.yml index 32ba414ba3..c273cae07e 100644 --- a/esphome/idf_component.yml +++ b/esphome/idf_component.yml @@ -7,7 +7,7 @@ dependencies: version: v2.0.9 mdns: git: https://github.com/espressif/esp-protocols.git - version: mdns-v1.8.0 + version: mdns-v1.8.2 path: components/mdns rules: - if: "idf_version >=5.0" From 5ed0046bddd73f4d23c109b6d16f2ebedf2451e7 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Sat, 29 Mar 2025 03:28:10 -0400 Subject: [PATCH 45/88] [esp32] Allow pioarduino version 5.4.1 (#8480) Co-authored-by: Keith Burzinski --- esphome/components/esp32/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/esphome/components/esp32/__init__.py b/esphome/components/esp32/__init__.py index 6a0c74b680..d66369f789 100644 --- a/esphome/components/esp32/__init__.py +++ b/esphome/components/esp32/__init__.py @@ -273,6 +273,7 @@ SUPPORTED_PLATFORMIO_ESP_IDF_5X = [ # pioarduino versions that don't require a release number # List based on https://github.com/pioarduino/esp-idf/releases SUPPORTED_PIOARDUINO_ESP_IDF_5X = [ + cv.Version(5, 4, 1), cv.Version(5, 4, 0), cv.Version(5, 3, 2), cv.Version(5, 3, 1), From ffc233d99d3a5c2c80b7f2df4d158fd1945e729f Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Sun, 30 Mar 2025 03:41:08 -0500 Subject: [PATCH 46/88] [speaker] Bugfix: Media player always unpauses when receiving a stop command (#8474) --- .../media_player/speaker_media_player.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/esphome/components/speaker/media_player/speaker_media_player.cpp b/esphome/components/speaker/media_player/speaker_media_player.cpp index 80ddfb2f04..17c73b8469 100644 --- a/esphome/components/speaker/media_player/speaker_media_player.cpp +++ b/esphome/components/speaker/media_player/speaker_media_player.cpp @@ -203,19 +203,37 @@ void SpeakerMediaPlayer::watch_media_commands_() { this->is_paused_ = true; break; case media_player::MEDIA_PLAYER_COMMAND_STOP: + // Pipelines do not stop immediately after calling the stop command, so confirm its stopped before unpausing. + // This avoids an audible short segment playing after receiving the stop command in a paused state. if (this->single_pipeline_() || (media_command.announce.has_value() && media_command.announce.value())) { if (this->announcement_pipeline_ != nullptr) { this->cancel_timeout("next_ann"); this->announcement_playlist_.clear(); this->announcement_pipeline_->stop(); + this->set_retry("unpause_ann", 50, 3, [this](const uint8_t remaining_attempts) { + if (this->announcement_pipeline_state_ == AudioPipelineState::STOPPED) { + this->announcement_pipeline_->set_pause_state(false); + return RetryResult::DONE; + } + return RetryResult::RETRY; + }); } } else { if (this->media_pipeline_ != nullptr) { this->cancel_timeout("next_media"); this->media_playlist_.clear(); this->media_pipeline_->stop(); + this->set_retry("unpause_med", 50, 3, [this](const uint8_t remaining_attempts) { + if (this->media_pipeline_state_ == AudioPipelineState::STOPPED) { + this->media_pipeline_->set_pause_state(false); + this->is_paused_ = false; + return RetryResult::DONE; + } + return RetryResult::RETRY; + }); } } + break; case media_player::MEDIA_PLAYER_COMMAND_TOGGLE: if (this->media_pipeline_ != nullptr) { From c42343be3ae8082b804d9633446441192bde3fc6 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Sun, 30 Mar 2025 20:09:19 +1100 Subject: [PATCH 47/88] [lvgl] Implement switch restore (#8481) --- esphome/components/lvgl/switch/__init__.py | 21 ++++++++++++-------- esphome/components/lvgl/switch/lvgl_switch.h | 21 +++++--------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/esphome/components/lvgl/switch/__init__.py b/esphome/components/lvgl/switch/__init__.py index 4e1e7f72e0..6d10a70d85 100644 --- a/esphome/components/lvgl/switch/__init__.py +++ b/esphome/components/lvgl/switch/__init__.py @@ -1,7 +1,9 @@ import esphome.codegen as cg -from esphome.components.switch import Switch, new_switch, switch_schema +from esphome.components.switch import Switch, register_switch, switch_schema import esphome.config_validation as cv +from esphome.const import CONF_ID from esphome.cpp_generator import MockObj +from esphome.cpp_types import Component from ..defines import CONF_WIDGET, literal from ..lvcode import ( @@ -18,7 +20,7 @@ from ..lvcode import ( from ..types import LV_EVENT, LV_STATE, lv_pseudo_button_t, lvgl_ns from ..widgets import get_widgets, wait_for_widgets -LVGLSwitch = lvgl_ns.class_("LVGLSwitch", Switch) +LVGLSwitch = lvgl_ns.class_("LVGLSwitch", Switch, Component) CONFIG_SCHEMA = switch_schema(LVGLSwitch).extend( { cv.Required(CONF_WIDGET): cv.use_id(lv_pseudo_button_t), @@ -27,21 +29,24 @@ CONFIG_SCHEMA = switch_schema(LVGLSwitch).extend( async def to_code(config): - switch = await new_switch(config) widget = await get_widgets(config, CONF_WIDGET) widget = widget[0] await wait_for_widgets() - async with LambdaContext(EVENT_ARG) as checked_ctx: - checked_ctx.add(switch.publish_state(widget.get_value())) + switch_id = MockObj(config[CONF_ID], "->") + v = literal("v") async with LambdaContext([(cg.bool_, "v")]) as control: - with LvConditional(MockObj("v")) as cond: + with LvConditional(v) as cond: widget.add_state(LV_STATE.CHECKED) cond.else_() widget.clear_state(LV_STATE.CHECKED) lv.event_send(widget.obj, API_EVENT, cg.nullptr) - control.add(switch.publish_state(literal("v"))) + control.add(switch_id.publish_state(v)) + switch = cg.new_Pvariable(config[CONF_ID], await control.get_lambda()) + await cg.register_component(switch, config) + await register_switch(switch, config) + async with LambdaContext(EVENT_ARG) as checked_ctx: + checked_ctx.add(switch.publish_state(widget.get_value())) async with LvContext() as ctx: - lv_add(switch.set_control_lambda(await control.get_lambda())) ctx.add( lvgl_static.add_event_cb( widget.obj, diff --git a/esphome/components/lvgl/switch/lvgl_switch.h b/esphome/components/lvgl/switch/lvgl_switch.h index af839b8892..485459691c 100644 --- a/esphome/components/lvgl/switch/lvgl_switch.h +++ b/esphome/components/lvgl/switch/lvgl_switch.h @@ -10,26 +10,15 @@ namespace esphome { namespace lvgl { -class LVGLSwitch : public switch_::Switch { +class LVGLSwitch : public switch_::Switch, public Component { public: - void set_control_lambda(std::function state_lambda) { - this->state_lambda_ = std::move(state_lambda); - if (this->initial_state_.has_value()) { - this->state_lambda_(this->initial_state_.value()); - this->initial_state_.reset(); - } - } + LVGLSwitch(std::function state_lambda) : state_lambda_(std::move(state_lambda)) {} + + void setup() override { this->write_state(this->get_initial_state_with_restore_mode().value_or(false)); } protected: - void write_state(bool value) override { - if (this->state_lambda_ != nullptr) { - this->state_lambda_(value); - } else { - this->initial_state_ = value; - } - } + void write_state(bool value) override { this->state_lambda_(value); } std::function state_lambda_{}; - optional initial_state_{}; }; } // namespace lvgl From c49391427fd13de36a3a3f99c3d3877640fbdf05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 01:52:10 +0000 Subject: [PATCH 48/88] Bump ruff from 0.11.0 to 0.11.2 (#8461) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 79d856e74c..1fd807952f 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,6 +1,6 @@ pylint==3.3.6 flake8==7.0.0 # also change in .pre-commit-config.yaml when updating -ruff==0.11.0 # also change in .pre-commit-config.yaml when updating +ruff==0.11.2 # also change in .pre-commit-config.yaml when updating pyupgrade==3.15.2 # also change in .pre-commit-config.yaml when updating pre-commit From d1763f9831c7d497f2d001faca6f2a1eab4b418d Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 31 Mar 2025 20:03:59 +1100 Subject: [PATCH 49/88] [psram] 120MHz does not work in octal mode (#8477) --- esphome/components/psram/__init__.py | 29 ++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/esphome/components/psram/__init__.py b/esphome/components/psram/__init__.py index 437ee1a21a..e83cf3ed99 100644 --- a/esphome/components/psram/__init__.py +++ b/esphome/components/psram/__init__.py @@ -9,9 +9,12 @@ CODEOWNERS = ["@esphome/core"] psram_ns = cg.esphome_ns.namespace("psram") PsramComponent = psram_ns.class_("PsramComponent", cg.Component) +TYPE_QUAD = "quad" +TYPE_OCTAL = "octal" + SPIRAM_MODES = { - "quad": "CONFIG_SPIRAM_MODE_QUAD", - "octal": "CONFIG_SPIRAM_MODE_OCT", + TYPE_QUAD: "CONFIG_SPIRAM_MODE_QUAD", + TYPE_OCTAL: "CONFIG_SPIRAM_MODE_OCT", } SPIRAM_SPEEDS = { @@ -20,15 +23,27 @@ SPIRAM_SPEEDS = { 120e6: "CONFIG_SPIRAM_SPEED_120M", } + +def validate_psram_mode(config): + if config[CONF_MODE] == TYPE_OCTAL and config[CONF_SPEED] == 120e6: + raise cv.Invalid("PSRAM 120MHz is not supported in octal mode") + return config + + CONFIG_SCHEMA = cv.All( cv.Schema( { cv.GenerateID(): cv.declare_id(PsramComponent), - cv.Optional(CONF_MODE): cv.enum(SPIRAM_MODES, lower=True), - cv.Optional(CONF_SPEED): cv.All(cv.frequency, cv.one_of(*SPIRAM_SPEEDS)), + cv.Optional(CONF_MODE, default=TYPE_QUAD): cv.enum( + SPIRAM_MODES, lower=True + ), + cv.Optional(CONF_SPEED, default=40e6): cv.All( + cv.frequency, cv.one_of(*SPIRAM_SPEEDS) + ), } ), cv.only_on_esp32, + validate_psram_mode, ) @@ -45,10 +60,8 @@ async def to_code(config): add_idf_sdkconfig_option("CONFIG_SPIRAM_USE_CAPS_ALLOC", True) add_idf_sdkconfig_option("CONFIG_SPIRAM_IGNORE_NOTFOUND", True) - if CONF_MODE in config: - add_idf_sdkconfig_option(f"{SPIRAM_MODES[config[CONF_MODE]]}", True) - if CONF_SPEED in config: - add_idf_sdkconfig_option(f"{SPIRAM_SPEEDS[config[CONF_SPEED]]}", True) + add_idf_sdkconfig_option(f"{SPIRAM_MODES[config[CONF_MODE]]}", True) + add_idf_sdkconfig_option(f"{SPIRAM_SPEEDS[config[CONF_SPEED]]}", True) cg.add_define("USE_PSRAM") From 4c1f83614bdb2a2ba23647d1d5e38b8a4158073c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 14:28:11 +0200 Subject: [PATCH 50/88] Bump actions/setup-python from 5.4.0 to 5.5.0 (#8468) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/ci-api-proto.yml | 2 +- .github/workflows/ci-docker.yml | 2 +- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 4 ++-- .github/workflows/sync-device-classes.yml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-api-proto.yml b/.github/workflows/ci-api-proto.yml index d06d8a8eec..233fb64693 100644 --- a/.github/workflows/ci-api-proto.yml +++ b/.github/workflows/ci-api-proto.yml @@ -23,7 +23,7 @@ jobs: - name: Checkout uses: actions/checkout@v4.1.7 - name: Set up Python - uses: actions/setup-python@v5.4.0 + uses: actions/setup-python@v5.5.0 with: python-version: "3.11" diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index 283b6edaeb..0a08e6ffad 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -42,7 +42,7 @@ jobs: steps: - uses: actions/checkout@v4.1.7 - name: Set up Python - uses: actions/setup-python@v5.4.0 + uses: actions/setup-python@v5.5.0 with: python-version: "3.9" - name: Set up Docker Buildx diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67d382b240..91c40d37c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: run: echo key="${{ hashFiles('requirements.txt', 'requirements_optional.txt', 'requirements_test.txt') }}" >> $GITHUB_OUTPUT - name: Set up Python ${{ env.DEFAULT_PYTHON }} id: python - uses: actions/setup-python@v5.4.0 + uses: actions/setup-python@v5.5.0 with: python-version: ${{ env.DEFAULT_PYTHON }} - name: Restore Python virtual environment diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3cc668c113..ccd5c6c1b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,7 +53,7 @@ jobs: steps: - uses: actions/checkout@v4.1.7 - name: Set up Python - uses: actions/setup-python@v5.4.0 + uses: actions/setup-python@v5.5.0 with: python-version: "3.x" - name: Set up python environment @@ -84,7 +84,7 @@ jobs: steps: - uses: actions/checkout@v4.1.7 - name: Set up Python - uses: actions/setup-python@v5.4.0 + uses: actions/setup-python@v5.5.0 with: python-version: "3.9" diff --git a/.github/workflows/sync-device-classes.yml b/.github/workflows/sync-device-classes.yml index 52adcefc32..8303e61a81 100644 --- a/.github/workflows/sync-device-classes.yml +++ b/.github/workflows/sync-device-classes.yml @@ -22,7 +22,7 @@ jobs: path: lib/home-assistant - name: Setup Python - uses: actions/setup-python@v5.4.0 + uses: actions/setup-python@v5.5.0 with: python-version: 3.12 From 9aa9abfc08cc77269726e7c3596ee26405118dc1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 14:28:21 +0200 Subject: [PATCH 51/88] Bump actions/setup-python from 5.4.0 to 5.5.0 in /.github/actions/restore-python (#8467) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/actions/restore-python/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/restore-python/action.yml b/.github/actions/restore-python/action.yml index a97733567d..3ac91f8ea2 100644 --- a/.github/actions/restore-python/action.yml +++ b/.github/actions/restore-python/action.yml @@ -17,7 +17,7 @@ runs: steps: - name: Set up Python ${{ inputs.python-version }} id: python - uses: actions/setup-python@v5.4.0 + uses: actions/setup-python@v5.5.0 with: python-version: ${{ inputs.python-version }} - name: Restore Python virtual environment From 402ada07b5d6b97874445d0460a41fc06572b836 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 14:33:00 +0200 Subject: [PATCH 52/88] Bump pytest-cov from 5.0.0 to 6.0.0 (#8462) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 1fd807952f..153f5ff601 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -6,7 +6,7 @@ pre-commit # Unit tests pytest==8.2.0 -pytest-cov==5.0.0 +pytest-cov==6.0.0 pytest-mock==3.14.0 pytest-asyncio==0.25.3 asyncmock==0.4.2 From 7e9f93a2906f29347e23c017e70ebed610a9a665 Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Mon, 31 Mar 2025 12:02:53 -0500 Subject: [PATCH 53/88] [speaker] Bugfixes: two pause state issues (#8488) --- .../media_player/speaker_media_player.cpp | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/esphome/components/speaker/media_player/speaker_media_player.cpp b/esphome/components/speaker/media_player/speaker_media_player.cpp index 17c73b8469..e143920010 100644 --- a/esphome/components/speaker/media_player/speaker_media_player.cpp +++ b/esphome/components/speaker/media_player/speaker_media_player.cpp @@ -100,7 +100,7 @@ void SpeakerMediaPlayer::setup() { if (!this->single_pipeline_()) { this->media_pipeline_ = make_unique(this->media_speaker_, this->buffer_size_, - this->task_stack_in_psram_, "ann", MEDIA_PIPELINE_TASK_PRIORITY); + this->task_stack_in_psram_, "med", MEDIA_PIPELINE_TASK_PRIORITY); if (this->media_pipeline_ == nullptr) { ESP_LOGE(TAG, "Failed to create media pipeline"); @@ -170,12 +170,28 @@ void SpeakerMediaPlayer::watch_media_commands_() { // Ensure the loaded next item doesn't start playing, clear the queue, start the file, and unpause this->cancel_timeout("next_media"); this->media_playlist_.clear(); - if (media_command.file.has_value()) { - this->media_pipeline_->start_file(playlist_item.file.value()); - } else if (media_command.url.has_value()) { - this->media_pipeline_->start_url(playlist_item.url.value()); + if (this->is_paused_) { + // If paused, stop the media pipeline and unpause it after confirming its stopped. This avoids playing a + // short segment of the paused file before starting the new one. + this->media_pipeline_->stop(); + this->set_retry("unpause_med", 50, 3, [this](const uint8_t remaining_attempts) { + if (this->media_pipeline_state_ == AudioPipelineState::STOPPED) { + this->media_pipeline_->set_pause_state(false); + this->is_paused_ = false; + return RetryResult::DONE; + } + return RetryResult::RETRY; + }); + } else { + // Not paused, just directly start the file + if (media_command.file.has_value()) { + this->media_pipeline_->start_file(playlist_item.file.value()); + } else if (media_command.url.has_value()) { + this->media_pipeline_->start_url(playlist_item.url.value()); + } + this->media_pipeline_->set_pause_state(false); + this->is_paused_ = false; } - this->media_pipeline_->set_pause_state(false); } this->media_playlist_.push_back(playlist_item); } @@ -350,11 +366,11 @@ void SpeakerMediaPlayer::loop() { } if (timeout_ms > 0) { - // Pause pipeline internally to facilitiate delay between items + // Pause pipeline internally to facilitate the delay between items this->announcement_pipeline_->set_pause_state(true); - // Internally unpause the pipeline after the delay between playlist items - this->set_timeout("next_ann", timeout_ms, - [this]() { this->announcement_pipeline_->set_pause_state(this->is_paused_); }); + // Internally unpause the pipeline after the delay between playlist items. Announcements do not follow the + // media player's pause state. + this->set_timeout("next_ann", timeout_ms, [this]() { this->announcement_pipeline_->set_pause_state(false); }); } } } else { @@ -390,9 +406,10 @@ void SpeakerMediaPlayer::loop() { } if (timeout_ms > 0) { - // Pause pipeline internally to facilitiate delay between items + // Pause pipeline internally to facilitate the delay between items this->media_pipeline_->set_pause_state(true); - // Internally unpause the pipeline after the delay between playlist items + // Internally unpause the pipeline after the delay between playlist items, if the media player state is + // not paused. this->set_timeout("next_media", timeout_ms, [this]() { this->media_pipeline_->set_pause_state(this->is_paused_); }); } From c8395cdf0a450be5df878107d0e67cdb132203f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 20:26:22 +0000 Subject: [PATCH 54/88] Bump pytest-asyncio from 0.25.3 to 0.26.0 (#8490) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 153f5ff601..8ff46a5794 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -8,6 +8,6 @@ pre-commit pytest==8.2.0 pytest-cov==6.0.0 pytest-mock==3.14.0 -pytest-asyncio==0.25.3 +pytest-asyncio==0.26.0 asyncmock==0.4.2 hypothesis==6.92.1 From 37a03de8495d8c782be2b451eb6381bfdfb3a33f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 20:57:23 +0000 Subject: [PATCH 55/88] Bump async-timeout from 4.0.3 to 5.0.1 (#8491) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d7526f664b..6a30e76d50 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -async_timeout==4.0.3; python_version <= "3.10" +async_timeout==5.0.1; python_version <= "3.10" cryptography==44.0.2 voluptuous==0.14.2 PyYAML==6.0.2 From bc372dbeb225624fba443058fece6ddc25003cd9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 21:28:47 +0000 Subject: [PATCH 56/88] Bump platformio from 6.1.16 to 6.1.18 (#8449) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 6a30e76d50..1789bf1dd4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ tornado==6.4.2 tzlocal==5.3.1 # from time tzdata>=2021.1 # from time pyserial==3.5 -platformio==6.1.16 # When updating platformio, also update Dockerfile +platformio==6.1.18 # When updating platformio, also update Dockerfile esptool==4.8.1 click==8.1.7 esphome-dashboard==20250212.0 From 28a9f12595ea1653ea6e926f95260f1d630a6284 Mon Sep 17 00:00:00 2001 From: NP v/d Spek Date: Tue, 1 Apr 2025 00:48:43 +0200 Subject: [PATCH 57/88] Move CONF_DEFAULT to const.py (#8497) --- esphome/components/deep_sleep/__init__.py | 2 +- esphome/components/lvgl/defines.py | 1 - esphome/components/lvgl/widgets/__init__.py | 3 +-- esphome/const.py | 1 + 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/esphome/components/deep_sleep/__init__.py b/esphome/components/deep_sleep/__init__.py index e7f563a0d2..63b359bd5b 100644 --- a/esphome/components/deep_sleep/__init__.py +++ b/esphome/components/deep_sleep/__init__.py @@ -13,6 +13,7 @@ from esphome.components.esp32.const import ( ) import esphome.config_validation as cv from esphome.const import ( + CONF_DEFAULT, CONF_HOUR, CONF_ID, CONF_MINUTE, @@ -153,7 +154,6 @@ WakeupCauseToRunDuration = deep_sleep_ns.struct("WakeupCauseToRunDuration") CONF_WAKEUP_PIN_MODE = "wakeup_pin_mode" CONF_ESP32_EXT1_WAKEUP = "esp32_ext1_wakeup" CONF_TOUCH_WAKEUP = "touch_wakeup" -CONF_DEFAULT = "default" CONF_GPIO_WAKEUP_REASON = "gpio_wakeup_reason" CONF_TOUCH_WAKEUP_REASON = "touch_wakeup_reason" CONF_UNTIL = "until" diff --git a/esphome/components/lvgl/defines.py b/esphome/components/lvgl/defines.py index 56a5a4b9e4..a713124bb3 100644 --- a/esphome/components/lvgl/defines.py +++ b/esphome/components/lvgl/defines.py @@ -416,7 +416,6 @@ CONF_CHANGE_RATE = "change_rate" CONF_CLOSE_BUTTON = "close_button" CONF_COLOR_DEPTH = "color_depth" CONF_CONTROL = "control" -CONF_DEFAULT = "default" CONF_DEFAULT_FONT = "default_font" CONF_DEFAULT_GROUP = "default_group" CONF_DIR = "dir" diff --git a/esphome/components/lvgl/widgets/__init__.py b/esphome/components/lvgl/widgets/__init__.py index e946a96000..ccad45bdc6 100644 --- a/esphome/components/lvgl/widgets/__init__.py +++ b/esphome/components/lvgl/widgets/__init__.py @@ -3,13 +3,12 @@ from typing import Any, Union from esphome import codegen as cg, config_validation as cv from esphome.config_validation import Invalid -from esphome.const import CONF_GROUP, CONF_ID, CONF_STATE, CONF_TYPE +from esphome.const import CONF_DEFAULT, CONF_GROUP, CONF_ID, CONF_STATE, CONF_TYPE from esphome.core import ID, TimePeriod from esphome.coroutine import FakeAwaitable from esphome.cpp_generator import CallExpression, MockObj from ..defines import ( - CONF_DEFAULT, CONF_FLEX_ALIGN_CROSS, CONF_FLEX_ALIGN_MAIN, CONF_FLEX_ALIGN_TRACK, diff --git a/esphome/const.py b/esphome/const.py index 5b3d258cc8..f6f9b7df80 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -199,6 +199,7 @@ CONF_DEBUG = "debug" CONF_DEBUG_SCHEDULER = "debug_scheduler" CONF_DECAY_MODE = "decay_mode" CONF_DECELERATION = "deceleration" +CONF_DEFAULT = "default" CONF_DEFAULT_MODE = "default_mode" CONF_DEFAULT_TARGET_TEMPERATURE_HIGH = "default_target_temperature_high" CONF_DEFAULT_TARGET_TEMPERATURE_LOW = "default_target_temperature_low" From 0812b3dd7081041e4077cbe16aa4873e4037d1c0 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 2 Apr 2025 09:42:23 +1100 Subject: [PATCH 58/88] [lvgl] Add some defines (#8501) --- esphome/core/defines.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/esphome/core/defines.h b/esphome/core/defines.h index 50a0847b78..64de41f23a 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -48,16 +48,36 @@ #define USE_LOGGER #define USE_LVGL #define USE_LVGL_ANIMIMG +#define USE_LVGL_ARC #define USE_LVGL_BINARY_SENSOR +#define USE_LVGL_BUTTON #define USE_LVGL_BUTTONMATRIX +#define USE_LVGL_CANVAS +#define USE_LVGL_CHART +#define USE_LVGL_CHECKBOX #define USE_LVGL_DROPDOWN #define USE_LVGL_FONT #define USE_LVGL_IMAGE +#define USE_LVGL_IMAGEBUTTON #define USE_LVGL_KEY_LISTENER #define USE_LVGL_KEYBOARD +#define USE_LVGL_LABEL +#define USE_LVGL_LINE +#define USE_LVGL_LIST +#define USE_LVGL_MENU #define USE_LVGL_METER +#define USE_LVGL_MSGBOX #define USE_LVGL_ROLLER #define USE_LVGL_ROTARY_ENCODER +#define USE_LVGL_SLIDER +#define USE_LVGL_SPAN +#define USE_LVGL_SPINBOX +#define USE_LVGL_SPINNER +#define USE_LVGL_SWITCH +#define USE_LVGL_TABLE +#define USE_LVGL_TABVIEW +#define USE_LVGL_TEXTAREA +#define USE_LVGL_TILEVIEW #define USE_LVGL_TOUCHSCREEN #define USE_MD5 #define USE_MDNS From e3eb3ee5d2753d5738546abbc832b045258ec6c3 Mon Sep 17 00:00:00 2001 From: Oliver Kleinecke Date: Wed, 2 Apr 2025 01:55:06 +0200 Subject: [PATCH 59/88] Add support for MCP4461 quad i2c digipot/rheostat (#8180) Co-authored-by: Oliver Kleinecke Co-authored-by: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> Co-authored-by: Keith Burzinski --- CODEOWNERS | 1 + esphome/components/mcp4461/__init__.py | 42 ++ esphome/components/mcp4461/mcp4461.cpp | 618 ++++++++++++++++++ esphome/components/mcp4461/mcp4461.h | 171 +++++ esphome/components/mcp4461/output/__init__.py | 60 ++ .../mcp4461/output/mcp4461_output.cpp | 73 +++ .../mcp4461/output/mcp4461_output.h | 49 ++ tests/components/mcp4461/common.yaml | 28 + tests/components/mcp4461/test.esp32-ard.yaml | 5 + .../components/mcp4461/test.esp32-c3-ard.yaml | 5 + .../components/mcp4461/test.esp32-c3-idf.yaml | 5 + tests/components/mcp4461/test.esp32-idf.yaml | 5 + .../components/mcp4461/test.esp8266-ard.yaml | 5 + 13 files changed, 1067 insertions(+) create mode 100644 esphome/components/mcp4461/__init__.py create mode 100644 esphome/components/mcp4461/mcp4461.cpp create mode 100644 esphome/components/mcp4461/mcp4461.h create mode 100644 esphome/components/mcp4461/output/__init__.py create mode 100644 esphome/components/mcp4461/output/mcp4461_output.cpp create mode 100644 esphome/components/mcp4461/output/mcp4461_output.h create mode 100644 tests/components/mcp4461/common.yaml create mode 100644 tests/components/mcp4461/test.esp32-ard.yaml create mode 100644 tests/components/mcp4461/test.esp32-c3-ard.yaml create mode 100644 tests/components/mcp4461/test.esp32-c3-idf.yaml create mode 100644 tests/components/mcp4461/test.esp32-idf.yaml create mode 100644 tests/components/mcp4461/test.esp8266-ard.yaml diff --git a/CODEOWNERS b/CODEOWNERS index 204d2b58bd..f6f7ac6f9c 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -266,6 +266,7 @@ esphome/components/mcp23x17_base/* @jesserockz esphome/components/mcp23xxx_base/* @jesserockz esphome/components/mcp2515/* @danielschramm @mvturnho esphome/components/mcp3204/* @rsumner +esphome/components/mcp4461/* @p1ngb4ck esphome/components/mcp4728/* @berfenger esphome/components/mcp47a1/* @jesserockz esphome/components/mcp9600/* @mreditor97 diff --git a/esphome/components/mcp4461/__init__.py b/esphome/components/mcp4461/__init__.py new file mode 100644 index 0000000000..1764629ff3 --- /dev/null +++ b/esphome/components/mcp4461/__init__.py @@ -0,0 +1,42 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import i2c +from esphome.const import CONF_ID + +CODEOWNERS = ["@p1ngb4ck"] +DEPENDENCIES = ["i2c"] +MULTI_CONF = True +CONF_DISABLE_WIPER_0 = "disable_wiper_0" +CONF_DISABLE_WIPER_1 = "disable_wiper_1" +CONF_DISABLE_WIPER_2 = "disable_wiper_2" +CONF_DISABLE_WIPER_3 = "disable_wiper_3" + +mcp4461_ns = cg.esphome_ns.namespace("mcp4461") +Mcp4461Component = mcp4461_ns.class_("Mcp4461Component", cg.Component, i2c.I2CDevice) +CONF_MCP4461_ID = "mcp4461_id" + +CONFIG_SCHEMA = ( + cv.Schema( + { + cv.GenerateID(): cv.declare_id(Mcp4461Component), + cv.Optional(CONF_DISABLE_WIPER_0, default=False): cv.boolean, + cv.Optional(CONF_DISABLE_WIPER_1, default=False): cv.boolean, + cv.Optional(CONF_DISABLE_WIPER_2, default=False): cv.boolean, + cv.Optional(CONF_DISABLE_WIPER_3, default=False): cv.boolean, + } + ) + .extend(cv.COMPONENT_SCHEMA) + .extend(i2c.i2c_device_schema(0x2C)) +) + + +async def to_code(config): + var = cg.new_Pvariable( + config[CONF_ID], + config[CONF_DISABLE_WIPER_0], + config[CONF_DISABLE_WIPER_1], + config[CONF_DISABLE_WIPER_2], + config[CONF_DISABLE_WIPER_3], + ) + await cg.register_component(var, config) + await i2c.register_i2c_device(var, config) diff --git a/esphome/components/mcp4461/mcp4461.cpp b/esphome/components/mcp4461/mcp4461.cpp new file mode 100644 index 0000000000..5393241281 --- /dev/null +++ b/esphome/components/mcp4461/mcp4461.cpp @@ -0,0 +1,618 @@ +#include "mcp4461.h" + +#include "esphome/core/helpers.h" +#include "esphome/core/hal.h" + +namespace esphome { +namespace mcp4461 { + +static const char *const TAG = "mcp4461"; +constexpr uint8_t EEPROM_WRITE_TIMEOUT_MS = 10; + +void Mcp4461Component::setup() { + ESP_LOGCONFIG(TAG, "Setting up mcp4461 using address (0x%02X)...", this->address_); + auto err = this->write(nullptr, 0); + if (err != i2c::ERROR_OK) { + this->error_code_ = MCP4461_STATUS_I2C_ERROR; + this->mark_failed(); + return; + } + // save WP/WL status + this->update_write_protection_status_(); + for (uint8_t i = 0; i < 8; i++) { + if (this->reg_[i].initial_value.has_value()) { + uint16_t initial_state = static_cast(*this->reg_[i].initial_value * 256.0f); + this->write_wiper_level_(i, initial_state); + } + if (this->reg_[i].enabled) { + this->reg_[i].state = this->read_wiper_level_(i); + } else { + // only volatile wipers can be set disabled on hw level + if (i < 4) { + this->reg_[i].state = 0; + Mcp4461WiperIdx wiper_idx = static_cast(i); + this->disable_wiper_(wiper_idx); + } + } + } +} + +void Mcp4461Component::set_initial_value(Mcp4461WiperIdx wiper, float initial_value) { + uint8_t wiper_idx = static_cast(wiper); + this->reg_[wiper_idx].initial_value = initial_value; +} + +void Mcp4461Component::initialize_terminal_disabled(Mcp4461WiperIdx wiper, char terminal) { + uint8_t wiper_idx = static_cast(wiper); + switch (terminal) { + case 'a': + this->reg_[wiper_idx].terminal_a = false; + break; + case 'b': + this->reg_[wiper_idx].terminal_b = false; + break; + case 'w': + this->reg_[wiper_idx].terminal_w = false; + break; + } +} + +void Mcp4461Component::update_write_protection_status_() { + uint8_t status_register_value = this->get_status_register_(); + this->write_protected_ = static_cast((status_register_value >> 0) & 0x01); + this->reg_[0].wiper_lock_active = static_cast((status_register_value >> 2) & 0x01); + this->reg_[1].wiper_lock_active = static_cast((status_register_value >> 3) & 0x01); + this->reg_[2].wiper_lock_active = static_cast((status_register_value >> 5) & 0x01); + this->reg_[3].wiper_lock_active = static_cast((status_register_value >> 6) & 0x01); +} + +void Mcp4461Component::dump_config() { + ESP_LOGCONFIG(TAG, "mcp4461:"); + LOG_I2C_DEVICE(this); + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + } + // log wiper status + for (uint8_t i = 0; i < 8; ++i) { + // terminals only valid for volatile wipers 0-3 - enable/disable is terminal hw + // so also invalid for nonvolatile. For these, only print current level. + // reworked to be a one-line intentionally, as output would not be in order + if (i < 4) { + ESP_LOGCONFIG(TAG, " ├── Volatile wiper [%u] level: %u, Status: %s, HW: %s, A: %s, B: %s, W: %s", i, + this->reg_[i].state, ONOFF(this->reg_[i].terminal_hw), ONOFF(this->reg_[i].terminal_a), + ONOFF(this->reg_[i].terminal_b), ONOFF(this->reg_[i].terminal_w), ONOFF(this->reg_[i].enabled)); + } else { + ESP_LOGCONFIG(TAG, " ├── Nonvolatile wiper [%u] level: %u", i, this->reg_[i].state); + } + } +} + +void Mcp4461Component::loop() { + if (this->status_has_warning()) { + this->get_status_register_(); + } + for (uint8_t i = 0; i < 8; i++) { + if (this->reg_[i].update_level) { + // set wiper i state if changed + if (this->reg_[i].state != this->read_wiper_level_(i)) { + this->write_wiper_level_(i, this->reg_[i].state); + } + } + this->reg_[i].update_level = false; + // can be true only for wipers 0-3 + // setting changes for terminals of nonvolatile wipers + // is prohibited in public methods + if (this->reg_[i].update_terminal) { + // set terminal register changes + Mcp4461TerminalIdx terminal_connector = + i < 2 ? Mcp4461TerminalIdx::MCP4461_TERMINAL_0 : Mcp4461TerminalIdx::MCP4461_TERMINAL_1; + uint8_t new_terminal_value = this->calc_terminal_connector_byte_(terminal_connector); + ESP_LOGV(TAG, "updating terminal %u to new value %u", static_cast(terminal_connector), + new_terminal_value); + this->set_terminal_register_(terminal_connector, new_terminal_value); + } + this->reg_[i].update_terminal = false; + } +} + +uint8_t Mcp4461Component::get_status_register_() { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return 0; + } + uint8_t addr = static_cast(Mcp4461Addresses::MCP4461_STATUS); + uint8_t reg = addr | static_cast(Mcp4461Commands::READ); + uint16_t buf; + if (!this->read_byte_16(reg, &buf)) { + this->error_code_ = MCP4461_STATUS_REGISTER_ERROR; + this->mark_failed(); + return 0; + } + uint8_t msb = buf >> 8; + uint8_t lsb = static_cast(buf & 0x00ff); + if (msb != 1 || ((lsb >> 7) & 0x01) != 1 || ((lsb >> 1) & 0x01) != 1) { + // D8, D7 and R1 bits are hardlocked to 1 -> a status msb bit 0 (bit 9 of status register) of 0 or lsb bit 1/7 = 0 + // indicate device/communication issues, therefore mark component failed + this->error_code_ = MCP4461_STATUS_REGISTER_INVALID; + this->mark_failed(); + return 0; + } + this->status_clear_warning(); + return lsb; +} + +void Mcp4461Component::read_status_register_to_log() { + uint8_t status_register_value = this->get_status_register_(); + ESP_LOGI(TAG, "D7: %u, WL3: %u, WL2: %u, EEWA: %u, WL1: %u, WL0: %u, R1: %u, WP: %u", + ((status_register_value >> 7) & 0x01), ((status_register_value >> 6) & 0x01), + ((status_register_value >> 5) & 0x01), ((status_register_value >> 4) & 0x01), + ((status_register_value >> 3) & 0x01), ((status_register_value >> 2) & 0x01), + ((status_register_value >> 1) & 0x01), ((status_register_value >> 0) & 0x01)); +} + +uint8_t Mcp4461Component::get_wiper_address_(uint8_t wiper) { + uint8_t addr; + bool nonvolatile = false; + if (wiper > 3) { + nonvolatile = true; + wiper = wiper - 4; + } + switch (wiper) { + case 0: + addr = static_cast(Mcp4461Addresses::MCP4461_VW0); + break; + case 1: + addr = static_cast(Mcp4461Addresses::MCP4461_VW1); + break; + case 2: + addr = static_cast(Mcp4461Addresses::MCP4461_VW2); + break; + case 3: + addr = static_cast(Mcp4461Addresses::MCP4461_VW3); + break; + default: + ESP_LOGW(TAG, "unknown wiper specified"); + return 0; + } + if (nonvolatile) { + addr = addr + 0x20; + } + return addr; +} + +uint16_t Mcp4461Component::get_wiper_level_(Mcp4461WiperIdx wiper) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return 0; + } + uint8_t wiper_idx = static_cast(wiper); + if (!(this->reg_[wiper_idx].enabled)) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WIPER_DISABLED))); + return 0; + } + if (!(this->reg_[wiper_idx].enabled)) { + ESP_LOGW(TAG, "reading from disabled volatile wiper %u, returning 0", wiper_idx); + return 0; + } + return this->read_wiper_level_(wiper_idx); +} + +uint16_t Mcp4461Component::read_wiper_level_(uint8_t wiper_idx) { + uint8_t addr = this->get_wiper_address_(wiper_idx); + uint8_t reg = addr | static_cast(Mcp4461Commands::INCREMENT); + if (wiper_idx > 3) { + if (!this->is_eeprom_ready_for_writing_(true)) { + return 0; + } + } + uint16_t buf = 0; + if (!(this->read_byte_16(reg, &buf))) { + this->error_code_ = MCP4461_STATUS_I2C_ERROR; + this->status_set_warning(); + ESP_LOGW(TAG, "Error fetching %swiper %u value", (wiper_idx > 3) ? "nonvolatile " : "", wiper_idx); + return 0; + } + return buf; +} + +bool Mcp4461Component::update_wiper_level_(Mcp4461WiperIdx wiper) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return false; + } + uint8_t wiper_idx = static_cast(wiper); + if (!(this->reg_[wiper_idx].enabled)) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WIPER_DISABLED))); + return false; + } + uint16_t data = this->get_wiper_level_(wiper); + ESP_LOGV(TAG, "Got value %u from wiper %u", data, wiper_idx); + this->reg_[wiper_idx].state = data; + return true; +} + +bool Mcp4461Component::set_wiper_level_(Mcp4461WiperIdx wiper, uint16_t value) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return false; + } + uint8_t wiper_idx = static_cast(wiper); + if (value > 0x100) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_VALUE_INVALID))); + return false; + } + if (!(this->reg_[wiper_idx].enabled)) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WIPER_DISABLED))); + return false; + } + if (this->reg_[wiper_idx].wiper_lock_active) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WIPER_LOCKED))); + return false; + } + ESP_LOGV(TAG, "Setting MCP4461 wiper %u to %u", wiper_idx, value); + this->reg_[wiper_idx].state = value; + this->reg_[wiper_idx].update_level = true; + return true; +} + +void Mcp4461Component::write_wiper_level_(uint8_t wiper, uint16_t value) { + bool nonvolatile = wiper > 3; + if (!(this->mcp4461_write_(this->get_wiper_address_(wiper), value, nonvolatile))) { + this->error_code_ = MCP4461_STATUS_I2C_ERROR; + this->status_set_warning(); + ESP_LOGW(TAG, "Error writing %swiper %u level %u", (wiper > 3) ? "nonvolatile " : "", wiper, value); + } +} + +void Mcp4461Component::enable_wiper_(Mcp4461WiperIdx wiper) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return; + } + uint8_t wiper_idx = static_cast(wiper); + if ((this->reg_[wiper_idx].enabled)) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WIPER_ENABLED))); + return; + } + if (this->reg_[wiper_idx].wiper_lock_active) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WIPER_LOCKED))); + return; + } + ESP_LOGV(TAG, "Enabling wiper %u", wiper_idx); + this->reg_[wiper_idx].enabled = true; + if (wiper_idx < 4) { + this->reg_[wiper_idx].terminal_hw = true; + this->reg_[wiper_idx].update_terminal = true; + } +} + +void Mcp4461Component::disable_wiper_(Mcp4461WiperIdx wiper) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return; + } + uint8_t wiper_idx = static_cast(wiper); + if (!(this->reg_[wiper_idx].enabled)) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WIPER_DISABLED))); + return; + } + if (this->reg_[wiper_idx].wiper_lock_active) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WIPER_LOCKED))); + return; + } + ESP_LOGV(TAG, "Disabling wiper %u", wiper_idx); + this->reg_[wiper_idx].enabled = true; + if (wiper_idx < 4) { + this->reg_[wiper_idx].terminal_hw = true; + this->reg_[wiper_idx].update_terminal = true; + } +} + +bool Mcp4461Component::increase_wiper_(Mcp4461WiperIdx wiper) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return false; + } + uint8_t wiper_idx = static_cast(wiper); + if (!(this->reg_[wiper_idx].enabled)) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WIPER_DISABLED))); + return false; + } + if (this->reg_[wiper_idx].wiper_lock_active) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WIPER_LOCKED))); + return false; + } + if (this->reg_[wiper_idx].state == 256) { + ESP_LOGV(TAG, "Maximum wiper level reached, further increase of wiper %u prohibited", wiper_idx); + return false; + } + ESP_LOGV(TAG, "Increasing wiper %u", wiper_idx); + uint8_t addr = this->get_wiper_address_(wiper_idx); + uint8_t reg = addr | static_cast(Mcp4461Commands::INCREMENT); + auto err = this->write(&this->address_, reg, sizeof(reg)); + if (err != i2c::ERROR_OK) { + this->error_code_ = MCP4461_STATUS_I2C_ERROR; + this->status_set_warning(); + return false; + } + this->reg_[wiper_idx].state++; + return true; +} + +bool Mcp4461Component::decrease_wiper_(Mcp4461WiperIdx wiper) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return false; + } + uint8_t wiper_idx = static_cast(wiper); + if (!(this->reg_[wiper_idx].enabled)) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WIPER_DISABLED))); + return false; + } + if (this->reg_[wiper_idx].wiper_lock_active) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WIPER_LOCKED))); + return false; + } + if (this->reg_[wiper_idx].state == 0) { + ESP_LOGV(TAG, "Minimum wiper level reached, further decrease of wiper %u prohibited", wiper_idx); + return false; + } + ESP_LOGV(TAG, "Decreasing wiper %u", wiper_idx); + uint8_t addr = this->get_wiper_address_(wiper_idx); + uint8_t reg = addr | static_cast(Mcp4461Commands::DECREMENT); + auto err = this->write(&this->address_, reg, sizeof(reg)); + if (err != i2c::ERROR_OK) { + this->error_code_ = MCP4461_STATUS_I2C_ERROR; + this->status_set_warning(); + return false; + } + this->reg_[wiper_idx].state--; + return true; +} + +uint8_t Mcp4461Component::calc_terminal_connector_byte_(Mcp4461TerminalIdx terminal_connector) { + uint8_t i = static_cast(terminal_connector) <= 1 ? 0 : 2; + uint8_t new_value_byte = 0; + new_value_byte += static_cast(this->reg_[i].terminal_b); + new_value_byte += static_cast(this->reg_[i].terminal_w) << 1; + new_value_byte += static_cast(this->reg_[i].terminal_a) << 2; + new_value_byte += static_cast(this->reg_[i].terminal_hw) << 3; + new_value_byte += static_cast(this->reg_[(i + 1)].terminal_b) << 4; + new_value_byte += static_cast(this->reg_[(i + 1)].terminal_w) << 5; + new_value_byte += static_cast(this->reg_[(i + 1)].terminal_a) << 6; + new_value_byte += static_cast(this->reg_[(i + 1)].terminal_hw) << 7; + return new_value_byte; +} + +uint8_t Mcp4461Component::get_terminal_register_(Mcp4461TerminalIdx terminal_connector) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return 0; + } + uint8_t reg = static_cast(terminal_connector) == 0 ? static_cast(Mcp4461Addresses::MCP4461_TCON0) + : static_cast(Mcp4461Addresses::MCP4461_TCON1); + reg |= static_cast(Mcp4461Commands::READ); + uint16_t buf; + if (this->read_byte_16(reg, &buf)) { + return static_cast(buf & 0x00ff); + } else { + this->error_code_ = MCP4461_STATUS_I2C_ERROR; + this->status_set_warning(); + ESP_LOGW(TAG, "Error fetching terminal register value"); + return 0; + } +} + +void Mcp4461Component::update_terminal_register_(Mcp4461TerminalIdx terminal_connector) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return; + } + if ((static_cast(terminal_connector) != 0 && static_cast(terminal_connector) != 1)) { + return; + } + uint8_t terminal_data = this->get_terminal_register_(terminal_connector); + if (terminal_data == 0) { + return; + } + ESP_LOGV(TAG, "Got terminal register %u data 0x%02X", static_cast(terminal_connector), terminal_data); + uint8_t wiper_index = 0; + if (static_cast(terminal_connector) == 1) { + wiper_index = 2; + } + this->reg_[wiper_index].terminal_b = ((terminal_data >> 0) & 0x01); + this->reg_[wiper_index].terminal_w = ((terminal_data >> 1) & 0x01); + this->reg_[wiper_index].terminal_a = ((terminal_data >> 2) & 0x01); + this->reg_[wiper_index].terminal_hw = ((terminal_data >> 3) & 0x01); + this->reg_[(wiper_index + 1)].terminal_b = ((terminal_data >> 4) & 0x01); + this->reg_[(wiper_index + 1)].terminal_w = ((terminal_data >> 5) & 0x01); + this->reg_[(wiper_index + 1)].terminal_a = ((terminal_data >> 6) & 0x01); + this->reg_[(wiper_index + 1)].terminal_hw = ((terminal_data >> 7) & 0x01); +} + +bool Mcp4461Component::set_terminal_register_(Mcp4461TerminalIdx terminal_connector, uint8_t data) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return false; + } + uint8_t addr; + if (static_cast(terminal_connector) == 0) { + addr = static_cast(Mcp4461Addresses::MCP4461_TCON0); + } else if (static_cast(terminal_connector) == 1) { + addr = static_cast(Mcp4461Addresses::MCP4461_TCON1); + } else { + ESP_LOGW(TAG, "Invalid terminal connector id %u specified", static_cast(terminal_connector)); + return false; + } + if (!(this->mcp4461_write_(addr, data))) { + this->error_code_ = MCP4461_STATUS_I2C_ERROR; + this->status_set_warning(); + return false; + } + return true; +} + +void Mcp4461Component::enable_terminal_(Mcp4461WiperIdx wiper, char terminal) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return; + } + uint8_t wiper_idx = static_cast(wiper); + ESP_LOGV(TAG, "Enabling terminal %c of wiper %u", terminal, wiper_idx); + switch (terminal) { + case 'h': + this->reg_[wiper_idx].terminal_hw = true; + break; + case 'a': + this->reg_[wiper_idx].terminal_a = true; + break; + case 'b': + this->reg_[wiper_idx].terminal_b = true; + break; + case 'w': + this->reg_[wiper_idx].terminal_w = true; + break; + default: + ESP_LOGW(TAG, "Unknown terminal %c specified", terminal); + return; + } + this->reg_[wiper_idx].update_terminal = false; +} + +void Mcp4461Component::disable_terminal_(Mcp4461WiperIdx wiper, char terminal) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return; + } + uint8_t wiper_idx = static_cast(wiper); + ESP_LOGV(TAG, "Disabling terminal %c of wiper %u", terminal, wiper_idx); + switch (terminal) { + case 'h': + this->reg_[wiper_idx].terminal_hw = false; + break; + case 'a': + this->reg_[wiper_idx].terminal_a = false; + break; + case 'b': + this->reg_[wiper_idx].terminal_b = false; + break; + case 'w': + this->reg_[wiper_idx].terminal_w = false; + break; + default: + ESP_LOGW(TAG, "Unknown terminal %c specified", terminal); + return; + } + this->reg_[wiper_idx].update_terminal = false; +} + +uint16_t Mcp4461Component::get_eeprom_value(Mcp4461EepromLocation location) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return 0; + } + uint8_t reg = 0; + reg |= static_cast(Mcp4461EepromLocation::MCP4461_EEPROM_1) + (static_cast(location) * 0x10); + reg |= static_cast(Mcp4461Commands::READ); + uint16_t buf; + if (!this->is_eeprom_ready_for_writing_(true)) { + return 0; + } + if (!this->read_byte_16(reg, &buf)) { + this->error_code_ = MCP4461_STATUS_I2C_ERROR; + this->status_set_warning(); + ESP_LOGW(TAG, "Error fetching EEPROM location value"); + return 0; + } + return buf; +} + +bool Mcp4461Component::set_eeprom_value(Mcp4461EepromLocation location, uint16_t value) { + if (this->is_failed()) { + ESP_LOGE(TAG, "%s", LOG_STR_ARG(this->get_message_string(this->error_code_))); + return false; + } + uint8_t addr = 0; + if (value > 511) { + return false; + } + if (value > 256) { + addr = 1; + } + addr |= static_cast(Mcp4461EepromLocation::MCP4461_EEPROM_1) + (static_cast(location) * 0x10); + if (!(this->mcp4461_write_(addr, value, true))) { + this->error_code_ = MCP4461_STATUS_I2C_ERROR; + this->status_set_warning(); + ESP_LOGW(TAG, "Error writing EEPROM value"); + return false; + } + return true; +} + +bool Mcp4461Component::is_writing_() { + /* Read the EEPROM write-active status from the status register */ + bool writing = static_cast((this->get_status_register_() >> 4) & 0x01); + + /* If EEPROM is no longer writing, reset the timeout flag */ + if (!writing) { + /* This is protected boolean flag in Mcp4461Component class */ + this->last_eeprom_write_timed_out_ = false; + } + + return writing; +} + +bool Mcp4461Component::is_eeprom_ready_for_writing_(bool wait_if_not_ready) { + /* Check initial write status */ + bool ready_for_write = !this->is_writing_(); + + /* Return early if no waiting is required or EEPROM is already ready */ + if (ready_for_write || !wait_if_not_ready || this->last_eeprom_write_timed_out_) { + return ready_for_write; + } + + /* Timestamp before starting the loop */ + const uint32_t start_millis = millis(); + + ESP_LOGV(TAG, "Waiting until EEPROM is ready for write, start_millis = %" PRIu32, start_millis); + + /* Loop until EEPROM is ready or timeout is reached */ + while (!ready_for_write && ((millis() - start_millis) < EEPROM_WRITE_TIMEOUT_MS)) { + ready_for_write = !this->is_writing_(); + + /* If ready, exit early */ + if (ready_for_write) { + ESP_LOGV(TAG, "EEPROM is ready for new write, elapsed_millis = %" PRIu32, millis() - start_millis); + return true; + } + + /* Not ready yet, yield before checking again */ + yield(); + } + + /* If still not ready after timeout, log error and mark the timeout */ + ESP_LOGE(TAG, "EEPROM write timeout exceeded (%u ms)", EEPROM_WRITE_TIMEOUT_MS); + this->last_eeprom_write_timed_out_ = true; + + return false; +} + +bool Mcp4461Component::mcp4461_write_(uint8_t addr, uint16_t data, bool nonvolatile) { + uint8_t reg = data > 0xff ? 1 : 0; + uint8_t value_byte = static_cast(data & 0x00ff); + ESP_LOGV(TAG, "Writing value %u to address %u", data, addr); + reg |= addr; + reg |= static_cast(Mcp4461Commands::WRITE); + if (nonvolatile) { + if (this->write_protected_) { + ESP_LOGW(TAG, "%s", LOG_STR_ARG(this->get_message_string(MCP4461_WRITE_PROTECTED))); + return false; + } + if (!this->is_eeprom_ready_for_writing_(true)) { + return false; + } + } + return this->write_byte(reg, value_byte); +} +} // namespace mcp4461 +} // namespace esphome diff --git a/esphome/components/mcp4461/mcp4461.h b/esphome/components/mcp4461/mcp4461.h new file mode 100644 index 0000000000..9b7f60f201 --- /dev/null +++ b/esphome/components/mcp4461/mcp4461.h @@ -0,0 +1,171 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/core/log.h" +#include "esphome/components/i2c/i2c.h" + +namespace esphome { +namespace mcp4461 { + +struct WiperState { + bool enabled = true; + uint16_t state = 0; + optional initial_value; + bool terminal_a = true; + bool terminal_b = true; + bool terminal_w = true; + bool terminal_hw = true; + bool wiper_lock_active = false; + bool update_level = false; + bool update_terminal = false; +}; + +// default wiper state is 128 / 0x80h +enum class Mcp4461Commands : uint8_t { WRITE = 0x00, INCREMENT = 0x04, DECREMENT = 0x08, READ = 0x0C }; + +enum class Mcp4461Addresses : uint8_t { + MCP4461_VW0 = 0x00, + MCP4461_VW1 = 0x10, + MCP4461_VW2 = 0x60, + MCP4461_VW3 = 0x70, + MCP4461_STATUS = 0x50, + MCP4461_TCON0 = 0x40, + MCP4461_TCON1 = 0xA0, + MCP4461_EEPROM_1 = 0xB0 +}; + +enum class Mcp4461WiperIdx : uint8_t { + MCP4461_WIPER_0 = 0, + MCP4461_WIPER_1 = 1, + MCP4461_WIPER_2 = 2, + MCP4461_WIPER_3 = 3, + MCP4461_WIPER_4 = 4, + MCP4461_WIPER_5 = 5, + MCP4461_WIPER_6 = 6, + MCP4461_WIPER_7 = 7 +}; + +enum class Mcp4461EepromLocation : uint8_t { + MCP4461_EEPROM_0 = 0, + MCP4461_EEPROM_1 = 1, + MCP4461_EEPROM_2 = 2, + MCP4461_EEPROM_3 = 3, + MCP4461_EEPROM_4 = 4 +}; + +enum class Mcp4461TerminalIdx : uint8_t { MCP4461_TERMINAL_0 = 0, MCP4461_TERMINAL_1 = 1 }; + +class Mcp4461Wiper; + +// Mcp4461Component +class Mcp4461Component : public Component, public i2c::I2CDevice { + public: + Mcp4461Component(bool disable_wiper_0, bool disable_wiper_1, bool disable_wiper_2, bool disable_wiper_3) + : wiper_0_disabled_(disable_wiper_0), + wiper_1_disabled_(disable_wiper_1), + wiper_2_disabled_(disable_wiper_2), + wiper_3_disabled_(disable_wiper_3) { + this->reg_[0].enabled = !wiper_0_disabled_; + this->reg_[1].enabled = !wiper_1_disabled_; + this->reg_[2].enabled = !wiper_2_disabled_; + this->reg_[3].enabled = !wiper_3_disabled_; + } + + void setup() override; + void dump_config() override; + float get_setup_priority() const override { return setup_priority::HARDWARE; } + void loop() override; + /// @brief get eeprom value from location + /// @param[in] location - eeprom location 0-4 + /// @return eeprom value of specified location (9 bits max) + uint16_t get_eeprom_value(Mcp4461EepromLocation location); + /// @brief set eeprom value at specified location + /// @param[in] location - eeprom location 0-4 + /// @param[in] value - 9 bits value to store + bool set_eeprom_value(Mcp4461EepromLocation location, uint16_t value); + /// @brief public function used to set initial value + /// @param[in] wiper - the wiper to set the value for + /// @param[in] initial_value - the initial value in range 0-1.0 as float + void set_initial_value(Mcp4461WiperIdx wiper, float initial_value); + /// @brief public function used to set disable terminal config + /// @param[in] wiper - the wiper to set the value for + /// @param[in] terminal - the terminal to disable, one of ['a','b','w','h'] + void initialize_terminal_disabled(Mcp4461WiperIdx wiper, char terminal); + /// @brief read status register to log + void read_status_register_to_log(); + + protected: + friend class Mcp4461Wiper; + void update_write_protection_status_(); + uint8_t get_wiper_address_(uint8_t wiper); + uint16_t read_wiper_level_(uint8_t wiper); + uint8_t get_status_register_(); + uint16_t get_wiper_level_(Mcp4461WiperIdx wiper); + bool set_wiper_level_(Mcp4461WiperIdx wiper, uint16_t value); + bool update_wiper_level_(Mcp4461WiperIdx wiper); + void enable_wiper_(Mcp4461WiperIdx wiper); + void disable_wiper_(Mcp4461WiperIdx wiper); + bool increase_wiper_(Mcp4461WiperIdx wiper); + bool decrease_wiper_(Mcp4461WiperIdx wiper); + void enable_terminal_(Mcp4461WiperIdx wiper, char terminal); + void disable_terminal_(Mcp4461WiperIdx, char terminal); + bool is_writing_(); + bool is_eeprom_ready_for_writing_(bool wait_if_not_ready); + void write_wiper_level_(uint8_t wiper, uint16_t value); + bool mcp4461_write_(uint8_t addr, uint16_t data, bool nonvolatile = false); + uint8_t calc_terminal_connector_byte_(Mcp4461TerminalIdx terminal_connector); + void update_terminal_register_(Mcp4461TerminalIdx terminal_connector); + uint8_t get_terminal_register_(Mcp4461TerminalIdx terminal_connector); + bool set_terminal_register_(Mcp4461TerminalIdx terminal_connector, uint8_t data); + + // Converts a status to a human readable string + static const LogString *get_message_string(int status) { + switch (status) { + case MCP4461_STATUS_I2C_ERROR: + return LOG_STR("I2C error - communication with MCP4461 failed!"); + case MCP4461_STATUS_REGISTER_ERROR: + return LOG_STR("Status register could not be read"); + case MCP4461_STATUS_REGISTER_INVALID: + return LOG_STR("Invalid status register value - bits 1,7 or 8 are 0"); + case MCP4461_VALUE_INVALID: + return LOG_STR("Invalid value for wiper given"); + case MCP4461_WRITE_PROTECTED: + return LOG_STR("MCP4461 is write protected. Setting nonvolatile wipers/eeprom values is prohibited."); + case MCP4461_WIPER_ENABLED: + return LOG_STR("MCP4461 Wiper is already enabled, ignoring cmd to enable."); + case MCP4461_WIPER_DISABLED: + return LOG_STR("MCP4461 Wiper is disabled. All actions on this wiper are prohibited."); + case MCP4461_WIPER_LOCKED: + return LOG_STR("MCP4461 Wiper is locked using WiperLock-technology. All actions on this wiper are prohibited."); + case MCP4461_STATUS_OK: + return LOG_STR("Status OK"); + default: + return LOG_STR("Unknown"); + } + } + + enum ErrorCode { + MCP4461_STATUS_OK = 0, // CMD completed successfully + MCP4461_FAILED, // component failed + MCP4461_STATUS_I2C_ERROR, // Unable to communicate with device + MCP4461_STATUS_REGISTER_INVALID, // Status register value was invalid + MCP4461_STATUS_REGISTER_ERROR, // Error fetching status register + MCP4461_PROHIBITED_FOR_NONVOLATILE, // + MCP4461_VALUE_INVALID, // Invalid value given for wiper / eeprom + MCP4461_WRITE_PROTECTED, // The value was read, but the CRC over the payload (valid and data) does not match + MCP4461_WIPER_ENABLED, // The wiper is enabled, discard additional enabling actions + MCP4461_WIPER_DISABLED, // The wiper is disabled - all actions for this wiper will be aborted/discarded + MCP4461_WIPER_LOCKED, // The wiper is locked using WiperLock-technology - all actions for this wiper will be + // aborted/discarded + } error_code_{MCP4461_STATUS_OK}; + + WiperState reg_[8]; + bool last_eeprom_write_timed_out_{false}; + bool write_protected_{false}; + bool wiper_0_disabled_{false}; + bool wiper_1_disabled_{false}; + bool wiper_2_disabled_{false}; + bool wiper_3_disabled_{false}; +}; +} // namespace mcp4461 +} // namespace esphome diff --git a/esphome/components/mcp4461/output/__init__.py b/esphome/components/mcp4461/output/__init__.py new file mode 100644 index 0000000000..ba59f97643 --- /dev/null +++ b/esphome/components/mcp4461/output/__init__.py @@ -0,0 +1,60 @@ +import esphome.codegen as cg +import esphome.config_validation as cv +from esphome.components import output +from esphome.const import CONF_CHANNEL, CONF_ID, CONF_INITIAL_VALUE +from .. import Mcp4461Component, CONF_MCP4461_ID, mcp4461_ns + +DEPENDENCIES = ["mcp4461"] + +Mcp4461Wiper = mcp4461_ns.class_( + "Mcp4461Wiper", output.FloatOutput, cg.Parented.template(Mcp4461Component) +) + +Mcp4461WiperIdx = mcp4461_ns.enum("Mcp4461WiperIdx", is_class=True) +CHANNEL_OPTIONS = { + "A": Mcp4461WiperIdx.MCP4461_WIPER_0, + "B": Mcp4461WiperIdx.MCP4461_WIPER_1, + "C": Mcp4461WiperIdx.MCP4461_WIPER_2, + "D": Mcp4461WiperIdx.MCP4461_WIPER_3, + "E": Mcp4461WiperIdx.MCP4461_WIPER_4, + "F": Mcp4461WiperIdx.MCP4461_WIPER_5, + "G": Mcp4461WiperIdx.MCP4461_WIPER_6, + "H": Mcp4461WiperIdx.MCP4461_WIPER_7, +} + +CONF_TERMINAL_A = "terminal_a" +CONF_TERMINAL_B = "terminal_b" +CONF_TERMINAL_W = "terminal_w" + +CONFIG_SCHEMA = output.FLOAT_OUTPUT_SCHEMA.extend( + { + cv.Required(CONF_ID): cv.declare_id(Mcp4461Wiper), + cv.GenerateID(CONF_MCP4461_ID): cv.use_id(Mcp4461Component), + cv.Required(CONF_CHANNEL): cv.enum(CHANNEL_OPTIONS, upper=True), + cv.Optional(CONF_TERMINAL_A, default=True): cv.boolean, + cv.Optional(CONF_TERMINAL_B, default=True): cv.boolean, + cv.Optional(CONF_TERMINAL_W, default=True): cv.boolean, + cv.Optional(CONF_INITIAL_VALUE): cv.float_range(min=0.0, max=1.0), + } +) + + +async def to_code(config): + parent = await cg.get_variable(config[CONF_MCP4461_ID]) + var = cg.new_Pvariable( + config[CONF_ID], + parent, + config[CONF_CHANNEL], + ) + if not config[CONF_TERMINAL_A]: + cg.add(parent.initialize_terminal_disabled(config[CONF_CHANNEL], "a")) + if not config[CONF_TERMINAL_B]: + cg.add(parent.initialize_terminal_disabled(config[CONF_CHANNEL], "b")) + if not config[CONF_TERMINAL_W]: + cg.add(parent.initialize_terminal_disabled(config[CONF_CHANNEL], "w")) + if CONF_INITIAL_VALUE in config: + cg.add( + parent.set_initial_value(config[CONF_CHANNEL], config[CONF_INITIAL_VALUE]) + ) + await output.register_output(var, config) + await cg.register_parented(var, config[CONF_MCP4461_ID]) diff --git a/esphome/components/mcp4461/output/mcp4461_output.cpp b/esphome/components/mcp4461/output/mcp4461_output.cpp new file mode 100644 index 0000000000..2d85a5df61 --- /dev/null +++ b/esphome/components/mcp4461/output/mcp4461_output.cpp @@ -0,0 +1,73 @@ +#include "mcp4461_output.h" +#include + +#include "esphome/core/helpers.h" +#include "esphome/core/log.h" + +namespace esphome { +namespace mcp4461 { + +static const char *const TAG = "mcp4461.output"; + +// public set_level function +void Mcp4461Wiper::set_level(float state) { + if (!std::isfinite(state)) { + ESP_LOGW(TAG, "Finite state state value is required."); + return; + } + state = clamp(state, 0.0f, 1.0f); + if (this->is_inverted()) { + state = 1.0f - state; + } + this->write_state(state); +} + +// floats from other components (like light etc.) are passed as "percentage floats" +// this function converts them to the 0 - 256 range used by the MCP4461 +void Mcp4461Wiper::write_state(float state) { + if (this->parent_->set_wiper_level_(this->wiper_, static_cast(std::roundf(state * 256)))) { + this->state_ = state; + } +} + +float Mcp4461Wiper::read_state() { return (static_cast(this->parent_->get_wiper_level_(this->wiper_)) / 256.0); } + +float Mcp4461Wiper::update_state() { + this->state_ = this->read_state(); + return this->state_; +} + +void Mcp4461Wiper::set_state(bool state) { + if (state) { + this->turn_on(); + } else { + this->turn_off(); + } +} + +void Mcp4461Wiper::turn_on() { this->parent_->enable_wiper_(this->wiper_); } + +void Mcp4461Wiper::turn_off() { this->parent_->disable_wiper_(this->wiper_); } + +void Mcp4461Wiper::increase_wiper() { + if (this->parent_->increase_wiper_(this->wiper_)) { + this->state_ = this->update_state(); + ESP_LOGV(TAG, "Increased wiper %u to %u", static_cast(this->wiper_), + static_cast(std::roundf(this->state_ * 256))); + } +} + +void Mcp4461Wiper::decrease_wiper() { + if (this->parent_->decrease_wiper_(this->wiper_)) { + this->state_ = this->update_state(); + ESP_LOGV(TAG, "Decreased wiper %u to %u", static_cast(this->wiper_), + static_cast(std::roundf(this->state_ * 256))); + } +} + +void Mcp4461Wiper::enable_terminal(char terminal) { this->parent_->enable_terminal_(this->wiper_, terminal); } + +void Mcp4461Wiper::disable_terminal(char terminal) { this->parent_->disable_terminal_(this->wiper_, terminal); } + +} // namespace mcp4461 +} // namespace esphome diff --git a/esphome/components/mcp4461/output/mcp4461_output.h b/esphome/components/mcp4461/output/mcp4461_output.h new file mode 100644 index 0000000000..4055cef30a --- /dev/null +++ b/esphome/components/mcp4461/output/mcp4461_output.h @@ -0,0 +1,49 @@ +#pragma once + +#include "../mcp4461.h" +#include "esphome/core/component.h" +#include "esphome/components/output/float_output.h" +#include "esphome/components/i2c/i2c.h" + +namespace esphome { +namespace mcp4461 { + +class Mcp4461Wiper : public output::FloatOutput, public Parented { + public: + Mcp4461Wiper(Mcp4461Component *parent, Mcp4461WiperIdx wiper) : parent_(parent), wiper_(wiper) {} + /// @brief Set level of wiper + /// @param[in] state - The desired float level in range 0-1.0 + void set_level(float state); + /// @brief Enables/Disables current output using bool parameter + /// @param[in] state boolean var representing desired state (true=ON, false=OFF) + void set_state(bool state) override; + /// @brief Enables current output + void turn_on() override; + /// @brief Disables current output + void turn_off() override; + /// @brief Read current device wiper state without updating internal output state + /// @return float - current device state as float in range 0 - 1.0 + float read_state(); + /// @brief Update current output state using device wiper state + /// @return float - current updated output state as float in range 0 - 1.0 + float update_state(); + /// @brief Increase wiper by 1 tap + void increase_wiper(); + /// @brief Decrease wiper by 1 tap + void decrease_wiper(); + /// @brief Enable given terminal + /// @param[in] terminal single char parameter defining desired terminal to enable, one of { 'a', 'b', 'w', 'h' } + void enable_terminal(char terminal); + /// @brief Disable given terminal + /// @param[in] terminal single char parameter defining desired terminal to disable, one of { 'a', 'b', 'w', 'h' } + void disable_terminal(char terminal); + + protected: + void write_state(float state) override; + Mcp4461Component *parent_; + Mcp4461WiperIdx wiper_; + float state_; +}; + +} // namespace mcp4461 +} // namespace esphome diff --git a/tests/components/mcp4461/common.yaml b/tests/components/mcp4461/common.yaml new file mode 100644 index 0000000000..ce1866fdb8 --- /dev/null +++ b/tests/components/mcp4461/common.yaml @@ -0,0 +1,28 @@ +i2c: + - id: i2c_mcp4461 + sda: ${sda_pin} + scl: ${scl_pin} + +mcp4461: + - id: mcp4461_digipot_01 + +output: + - platform: mcp4461 + id: digipot_wiper_1 + mcp4461_id: mcp4461_digipot_01 + channel: A + + - platform: mcp4461 + id: digipot_wiper_2 + mcp4461_id: mcp4461_digipot_01 + channel: B + + - platform: mcp4461 + id: digipot_wiper_3 + mcp4461_id: mcp4461_digipot_01 + channel: C + + - platform: mcp4461 + id: digipot_wiper_4 + mcp4461_id: mcp4461_digipot_01 + channel: D diff --git a/tests/components/mcp4461/test.esp32-ard.yaml b/tests/components/mcp4461/test.esp32-ard.yaml new file mode 100644 index 0000000000..c5deb7ca0a --- /dev/null +++ b/tests/components/mcp4461/test.esp32-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + sda_pin: GPIO16 + scl_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/mcp4461/test.esp32-c3-ard.yaml b/tests/components/mcp4461/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..a87353b78b --- /dev/null +++ b/tests/components/mcp4461/test.esp32-c3-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + sda_pin: GPIO4 + scl_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/mcp4461/test.esp32-c3-idf.yaml b/tests/components/mcp4461/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..a87353b78b --- /dev/null +++ b/tests/components/mcp4461/test.esp32-c3-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + sda_pin: GPIO4 + scl_pin: GPIO5 + +<<: !include common.yaml diff --git a/tests/components/mcp4461/test.esp32-idf.yaml b/tests/components/mcp4461/test.esp32-idf.yaml new file mode 100644 index 0000000000..c5deb7ca0a --- /dev/null +++ b/tests/components/mcp4461/test.esp32-idf.yaml @@ -0,0 +1,5 @@ +substitutions: + sda_pin: GPIO16 + scl_pin: GPIO17 + +<<: !include common.yaml diff --git a/tests/components/mcp4461/test.esp8266-ard.yaml b/tests/components/mcp4461/test.esp8266-ard.yaml new file mode 100644 index 0000000000..a87353b78b --- /dev/null +++ b/tests/components/mcp4461/test.esp8266-ard.yaml @@ -0,0 +1,5 @@ +substitutions: + sda_pin: GPIO4 + scl_pin: GPIO5 + +<<: !include common.yaml From be60d9be9bcc3036e0d07d9387c080834f214cf9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 23:16:17 +1300 Subject: [PATCH 60/88] Bump peter-evans/create-pull-request from 7.0.7 to 7.0.8 (#8362) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/sync-device-classes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-device-classes.yml b/.github/workflows/sync-device-classes.yml index 8303e61a81..02baa42f3e 100644 --- a/.github/workflows/sync-device-classes.yml +++ b/.github/workflows/sync-device-classes.yml @@ -36,7 +36,7 @@ jobs: python ./script/sync-device_class.py - name: Commit changes - uses: peter-evans/create-pull-request@v7.0.7 + uses: peter-evans/create-pull-request@v7.0.8 with: commit-message: "Synchronise Device Classes from Home Assistant" committer: esphomebot From 05e52cae2b00a5ae919f6b41e0997b8f0d1f8ef7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 23:16:31 +1300 Subject: [PATCH 61/88] Bump docker/login-action from 3.3.0 to 3.4.0 in the docker-actions group (#8408) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ccd5c6c1b7..f0dd5c1729 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -95,12 +95,12 @@ jobs: uses: docker/setup-qemu-action@v3.6.0 - name: Log in to docker hub - uses: docker/login-action@v3.3.0 + uses: docker/login-action@v3.4.0 with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Log in to the GitHub container registry - uses: docker/login-action@v3.3.0 + uses: docker/login-action@v3.4.0 with: registry: ghcr.io username: ${{ github.actor }} @@ -187,13 +187,13 @@ jobs: - name: Log in to docker hub if: matrix.registry == 'dockerhub' - uses: docker/login-action@v3.3.0 + uses: docker/login-action@v3.4.0 with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Log in to the GitHub container registry if: matrix.registry == 'ghcr' - uses: docker/login-action@v3.3.0 + uses: docker/login-action@v3.4.0 with: registry: ghcr.io username: ${{ github.actor }} From 1df1e3cf4885f517493e551dd076b9812628cb39 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 23:16:42 +1300 Subject: [PATCH 62/88] Bump actions/download-artifact from 4.1.9 to 4.2.1 (#8434) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f0dd5c1729..14e258c0d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -176,7 +176,7 @@ jobs: - uses: actions/checkout@v4.1.7 - name: Download digests - uses: actions/download-artifact@v4.1.9 + uses: actions/download-artifact@v4.2.1 with: pattern: digests-* path: /tmp/digests From 655075e71b398a02091bcee801f1e210ed664de2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 23:17:08 +1300 Subject: [PATCH 63/88] Bump actions/upload-artifact from 4.6.1 to 4.6.2 (#8435) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 14e258c0d6..7793c574fe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -140,7 +140,7 @@ jobs: echo name=$(cat /tmp/platform) >> $GITHUB_OUTPUT - name: Upload digests - uses: actions/upload-artifact@v4.6.1 + uses: actions/upload-artifact@v4.6.2 with: name: digests-${{ steps.sanitize.outputs.name }} path: /tmp/digests From 6bccc7e3890031f1a377d00308f5d563a0b47dee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 23:17:34 +1300 Subject: [PATCH 64/88] Bump ruamel-yaml from 0.18.6 to 0.18.10 (#8446) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: J. Nick Koston --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 1789bf1dd4..9f9033a6be 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,7 +16,7 @@ esphome-dashboard==20250212.0 aioesphomeapi==29.7.0 zeroconf==0.146.1 puremagic==1.28 -ruamel.yaml==0.18.6 # dashboard_import +ruamel.yaml==0.18.10 # dashboard_import esphome-glyphsets==0.2.0 pillow==10.4.0 freetype-py==2.5.1 From 791740e5547fddf428a7dfb8408fc102a8b2619e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 23:18:01 +1300 Subject: [PATCH 65/88] Bump yamllint from 1.35.1 to 1.37.0 (#8495) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements_dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index 1a98a15ab2..d77ccaff69 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,4 +1,4 @@ # Useful stuff when working in a development environment clang-format==13.0.1 # also change in .pre-commit-config.yaml and Dockerfile when updating clang-tidy==18.1.8 # When updating clang-tidy, also update Dockerfile -yamllint==1.35.1 # also change in .pre-commit-config.yaml when updating +yamllint==1.37.0 # also change in .pre-commit-config.yaml when updating From 4ecc72ed542ba856a164a6c8e679cad083104400 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 23:50:30 +1300 Subject: [PATCH 66/88] Bump pyupgrade from 3.15.2 to 3.19.1 (#8496) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 8ff46a5794..22c275a330 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,7 +1,7 @@ pylint==3.3.6 flake8==7.0.0 # also change in .pre-commit-config.yaml when updating ruff==0.11.2 # also change in .pre-commit-config.yaml when updating -pyupgrade==3.15.2 # also change in .pre-commit-config.yaml when updating +pyupgrade==3.19.1 # also change in .pre-commit-config.yaml when updating pre-commit # Unit tests From 4b0622aa2312dd2f7bbda3c8f31fb721a20d0983 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 10:14:12 -1000 Subject: [PATCH 67/88] Bump voluptuous from 0.14.2 to 0.15.2 (#8506) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 9f9033a6be..721928a989 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ async_timeout==5.0.1; python_version <= "3.10" cryptography==44.0.2 -voluptuous==0.14.2 +voluptuous==0.15.2 PyYAML==6.0.2 paho-mqtt==1.6.1 colorama==0.4.6 From 79f198ebffbd898038d13676e7ad27cea5fd0a5d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 20:47:46 +0000 Subject: [PATCH 68/88] Bump zeroconf from 0.146.1 to 0.146.3 (#8507) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 721928a989..fa0e00d0d4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ esptool==4.8.1 click==8.1.7 esphome-dashboard==20250212.0 aioesphomeapi==29.7.0 -zeroconf==0.146.1 +zeroconf==0.146.3 puremagic==1.28 ruamel.yaml==0.18.10 # dashboard_import esphome-glyphsets==0.2.0 From 864dd690383ce9e98766c7e3a4a487245e15d2ea Mon Sep 17 00:00:00 2001 From: Shivam Maurya <54358380+shvmm@users.noreply.github.com> Date: Thu, 3 Apr 2025 03:08:13 +0530 Subject: [PATCH 69/88] Bump platformio to 6.1.18 (#8430) Co-authored-by: J. Nick Koston --- docker/Dockerfile | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ee375ba690..117ec17ae4 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -55,7 +55,7 @@ RUN \ pip3 install \ --break-system-packages --no-cache-dir \ # Keep platformio version in sync with requirements.txt - platformio==6.1.16 \ + platformio==6.1.18 \ # Change some platformio settings && platformio settings set enable_telemetry No \ && platformio settings set check_platformio_interval 1000000 \ diff --git a/requirements.txt b/requirements.txt index fa0e00d0d4..ef1542ffe9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ tornado==6.4.2 tzlocal==5.3.1 # from time tzdata>=2021.1 # from time pyserial==3.5 -platformio==6.1.18 # When updating platformio, also update Dockerfile +platformio==6.1.18 # When updating platformio, also update /docker/Dockerfile esptool==4.8.1 click==8.1.7 esphome-dashboard==20250212.0 From fe35eee8df2b8cde1b2e32b89341ab797d0d6a82 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 3 Apr 2025 11:08:46 +1300 Subject: [PATCH 70/88] Update emails from nabucasa to OHF (#8508) --- .github/FUNDING.yml | 4 ---- .github/workflows/sync-device-classes.yml | 4 ++-- CODE_OF_CONDUCT.md | 2 +- pyproject.toml | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index a8ca63d158..0000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -# These are supported funding model platforms - -custom: https://www.nabucasa.com diff --git a/.github/workflows/sync-device-classes.yml b/.github/workflows/sync-device-classes.yml index 02baa42f3e..0a0c834a71 100644 --- a/.github/workflows/sync-device-classes.yml +++ b/.github/workflows/sync-device-classes.yml @@ -39,8 +39,8 @@ jobs: uses: peter-evans/create-pull-request@v7.0.8 with: commit-message: "Synchronise Device Classes from Home Assistant" - committer: esphomebot - author: esphomebot + committer: esphomebot + author: esphomebot branch: sync/device-classes delete-branch: true title: "Synchronise Device Classes from Home Assistant" diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index b91a3b4f83..f32d9dafbf 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at esphome@nabucasa.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at esphome@openhomefoundation.org. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. diff --git a/pyproject.toml b/pyproject.toml index eef314c4b7..8dd7def79c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ license = {text = "MIT"} description = "ESPHome is a system to configure your microcontrollers by simple yet powerful configuration files and control them remotely through Home Automation systems." readme = "README.md" authors = [ - {name = "The ESPHome Authors", email = "esphome@nabucasa.com"} + {name = "The ESPHome Authors", email = "esphome@openhomefoundation.org"} ] keywords = ["home", "automation"] classifiers = [ From 82adcd656fd97b122328113cbd1c87a5cb751384 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Wed, 2 Apr 2025 16:04:43 -0700 Subject: [PATCH 71/88] [nau7802] fix bad blocking code (#8070) --- esphome/components/nau7802/nau7802.cpp | 4 ---- esphome/components/nau7802/nau7802.h | 2 -- 2 files changed, 6 deletions(-) diff --git a/esphome/components/nau7802/nau7802.cpp b/esphome/components/nau7802/nau7802.cpp index ea6c0258af..d7149e5697 100644 --- a/esphome/components/nau7802/nau7802.cpp +++ b/esphome/components/nau7802/nau7802.cpp @@ -120,8 +120,6 @@ void NAU7802Sensor::complete_setup_() { // PGA stabilizer cap on output i2c::I2CRegister pwr_reg = this->reg(POWER_REG); pwr_reg |= POWER_PGA_CAP_EN; - - this->setup_complete_ = true; } void NAU7802Sensor::dump_config() { @@ -317,7 +315,5 @@ void NAU7802Sensor::update() { bool NAU7802Sensor::is_data_ready_() { return this->reg(PU_CTRL_REG).get() & PU_CTRL_CYCLE_READY; } -bool NAU7802Sensor::can_proceed() { return this->setup_complete_; } - } // namespace nau7802 } // namespace esphome diff --git a/esphome/components/nau7802/nau7802.h b/esphome/components/nau7802/nau7802.h index 3b0372aa89..17e426ccc6 100644 --- a/esphome/components/nau7802/nau7802.h +++ b/esphome/components/nau7802/nau7802.h @@ -61,7 +61,6 @@ class NAU7802Sensor : public sensor::Sensor, public PollingComponent, public i2c void setup() override; void loop() override; - bool can_proceed() override; void dump_config() override; float get_setup_priority() const override; void update() override; @@ -80,7 +79,6 @@ class NAU7802Sensor : public sensor::Sensor, public PollingComponent, public i2c int32_t offset_calibration_; bool offset_calibration_failed_ = false; bool gain_calibration_failed_ = false; - bool setup_complete_ = false; // // Config values From ef0f969604064176deeec0497e72f689caf81376 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Thu, 3 Apr 2025 03:03:04 -0400 Subject: [PATCH 72/88] [core, qspi_dbi] Clang tidy fixes for 5.3.2 (#8509) --- esphome/components/qspi_dbi/qspi_dbi.cpp | 2 +- esphome/components/qspi_dbi/qspi_dbi.h | 2 +- esphome/core/helpers.cpp | 3 --- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/esphome/components/qspi_dbi/qspi_dbi.cpp b/esphome/components/qspi_dbi/qspi_dbi.cpp index 380c93c400..fda6300d16 100644 --- a/esphome/components/qspi_dbi/qspi_dbi.cpp +++ b/esphome/components/qspi_dbi/qspi_dbi.cpp @@ -1,4 +1,4 @@ -#ifdef USE_ESP_IDF +#if defined(USE_ESP_IDF) && defined(USE_ESP32_VARIANT_ESP32S3) #include "qspi_dbi.h" #include "esphome/core/log.h" diff --git a/esphome/components/qspi_dbi/qspi_dbi.h b/esphome/components/qspi_dbi/qspi_dbi.h index 2c555f115e..f35f0e519c 100644 --- a/esphome/components/qspi_dbi/qspi_dbi.h +++ b/esphome/components/qspi_dbi/qspi_dbi.h @@ -3,7 +3,7 @@ // #pragma once -#ifdef USE_ESP_IDF +#if defined(USE_ESP_IDF) && defined(USE_ESP32_VARIANT_ESP32S3) #include "esphome/components/spi/spi.h" #include "esphome/components/display/display.h" #include "esphome/components/display/display_buffer.h" diff --git a/esphome/core/helpers.cpp b/esphome/core/helpers.cpp index 1472726d31..36bc7f949b 100644 --- a/esphome/core/helpers.cpp +++ b/esphome/core/helpers.cpp @@ -45,9 +45,6 @@ #endif #ifdef USE_ESP32 #include "rom/crc.h" -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 2) -#include "esp_mac.h" -#endif #include "esp_efuse.h" #include "esp_efuse_table.h" #endif From 219ba6152cc033b5da99566537664d842b3faee9 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> Date: Thu, 3 Apr 2025 03:32:17 -0400 Subject: [PATCH 73/88] [CI] Clang tidy fixes for 5.3.2 (#8510) Co-authored-by: Keith Burzinski --- script/clang-tidy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/clang-tidy b/script/clang-tidy index 51705f955b..a857274b01 100755 --- a/script/clang-tidy +++ b/script/clang-tidy @@ -36,6 +36,7 @@ def clang_options(idedata): # clang doesn't support Xtensa (yet?), so compile in 32-bit mode and pretend we're the Xtensa compiler cmd.append("-m32") cmd.append("-D__XTENSA__") + cmd.append("-D_LIBC") else: cmd.append(f"--target={triplet}") @@ -79,6 +80,7 @@ def clang_options(idedata): "-fstrict-volatile-bitfields", "-mlongcalls", "-mtext-section-literals", + "-mdisable-hardware-atomics", "-mfix-esp32-psram-cache-issue", "-mfix-esp32-psram-cache-strategy=memw", "-fno-tree-switch-conversion", From 99d5ca326688cb11844d544b9195f9f63ff3a0e7 Mon Sep 17 00:00:00 2001 From: victorclaessen Date: Fri, 4 Apr 2025 09:59:46 +0200 Subject: [PATCH 74/88] [ethernet_info] return actual ethernet MAC address (#8492) Co-authored-by: clydebarrow <2366188+clydebarrow@users.noreply.github.com> --- esphome/components/ethernet/ethernet_component.cpp | 2 +- esphome/components/ethernet_info/ethernet_info_text_sensor.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/esphome/components/ethernet/ethernet_component.cpp b/esphome/components/ethernet/ethernet_component.cpp index 08f5fa6642..68a6e617fc 100644 --- a/esphome/components/ethernet/ethernet_component.cpp +++ b/esphome/components/ethernet/ethernet_component.cpp @@ -580,7 +580,7 @@ void EthernetComponent::get_eth_mac_address_raw(uint8_t *mac) { std::string EthernetComponent::get_eth_mac_address_pretty() { uint8_t mac[6]; - get_mac_address_raw(mac); + get_eth_mac_address_raw(mac); return str_snprintf("%02X:%02X:%02X:%02X:%02X:%02X", 17, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); } diff --git a/esphome/components/ethernet_info/ethernet_info_text_sensor.h b/esphome/components/ethernet_info/ethernet_info_text_sensor.h index 94eed886e5..2e67694bbd 100644 --- a/esphome/components/ethernet_info/ethernet_info_text_sensor.h +++ b/esphome/components/ethernet_info/ethernet_info_text_sensor.h @@ -62,6 +62,7 @@ class DNSAddressEthernetInfo : public PollingComponent, public text_sensor::Text class MACAddressEthernetInfo : public Component, public text_sensor::TextSensor { public: void setup() override { this->publish_state(ethernet::global_eth_component->get_eth_mac_address_pretty()); } + float get_setup_priority() const override { return setup_priority::ETHERNET; } std::string unique_id() override { return get_mac_address() + "-ethernetinfo-mac"; } void dump_config() override; }; From 5ceba618f6eb32ba1b4d4a6995a2f2a1be4a76df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 5 Apr 2025 21:28:37 +0000 Subject: [PATCH 75/88] Bump setuptools from 76.0.0 to 78.1.0 (#8512) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8dd7def79c..77dcaf1fab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools==76.0.0", "wheel>=0.43,<0.46"] +requires = ["setuptools==78.1.0", "wheel>=0.43,<0.46"] build-backend = "setuptools.build_meta" [project] From f3b1b11ebaf4af7a3cd7c2072e2da3f51fcc83e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 6 Apr 2025 00:58:39 +0000 Subject: [PATCH 76/88] Bump flake8 from 7.0.0 to 7.2.0 (#8493) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: J. Nick Koston --- .pre-commit-config.yaml | 4 ++-- esphome/dashboard/status/mqtt.py | 2 -- requirements_test.txt | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ff34e60fa4..d11aa067bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,11 +12,11 @@ repos: # Run the formatter. - id: ruff-format - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 7.2.0 hooks: - id: flake8 additional_dependencies: - - flake8-docstrings==1.5.0 + - flake8-docstrings==1.7.0 - pydocstyle==5.1.1 files: ^(esphome|tests)/.+\.py$ - repo: https://github.com/pre-commit/pre-commit-hooks diff --git a/esphome/dashboard/status/mqtt.py b/esphome/dashboard/status/mqtt.py index 70eb0b58b5..c3e4883849 100644 --- a/esphome/dashboard/status/mqtt.py +++ b/esphome/dashboard/status/mqtt.py @@ -32,8 +32,6 @@ class MqttStatusThread(threading.Thread): topic = "esphome/discover/#" def on_message(client, userdata, msg): - nonlocal current_entries - payload = msg.payload.decode(errors="backslashreplace") if len(payload) > 0: data = json.loads(payload) diff --git a/requirements_test.txt b/requirements_test.txt index 22c275a330..3e5b15a718 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -1,5 +1,5 @@ pylint==3.3.6 -flake8==7.0.0 # also change in .pre-commit-config.yaml when updating +flake8==7.2.0 # also change in .pre-commit-config.yaml when updating ruff==0.11.2 # also change in .pre-commit-config.yaml when updating pyupgrade==3.19.1 # also change in .pre-commit-config.yaml when updating pre-commit From 23e5cdb30e197d57541be752642524e4b70a05c2 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 6 Apr 2025 14:48:12 -1000 Subject: [PATCH 77/88] Rework max connections for BLE to avoid exceeding the hard limit (#8303) --- esphome/components/ble_client/__init__.py | 5 +- .../components/bluetooth_proxy/__init__.py | 53 +++-- .../components/esp32_ble_tracker/__init__.py | 186 +++++++++++++----- tests/components/bluetooth_proxy/common.yaml | 8 + .../bluetooth_proxy/test.esp32-ard.yaml | 8 + .../bluetooth_proxy/test.esp32-c3-ard.yaml | 8 + .../bluetooth_proxy/test.esp32-c3-idf.yaml | 8 + .../bluetooth_proxy/test.esp32-idf.yaml | 8 + .../esp32_ble_tracker/test.esp32-ard.yaml | 3 + .../esp32_ble_tracker/test.esp32-c3-ard.yaml | 3 + .../esp32_ble_tracker/test.esp32-c3-idf.yaml | 3 + .../esp32_ble_tracker/test.esp32-idf.yaml | 3 + 12 files changed, 224 insertions(+), 72 deletions(-) create mode 100644 tests/components/bluetooth_proxy/common.yaml create mode 100644 tests/components/bluetooth_proxy/test.esp32-ard.yaml create mode 100644 tests/components/bluetooth_proxy/test.esp32-c3-ard.yaml create mode 100644 tests/components/bluetooth_proxy/test.esp32-c3-idf.yaml create mode 100644 tests/components/bluetooth_proxy/test.esp32-idf.yaml diff --git a/esphome/components/ble_client/__init__.py b/esphome/components/ble_client/__init__.py index bc7d517695..37f8ea32b3 100644 --- a/esphome/components/ble_client/__init__.py +++ b/esphome/components/ble_client/__init__.py @@ -67,7 +67,7 @@ CONF_AUTO_CONNECT = "auto_connect" MULTI_CONF = True -CONFIG_SCHEMA = ( +CONFIG_SCHEMA = cv.All( cv.Schema( { cv.GenerateID(): cv.declare_id(BLEClient), @@ -114,7 +114,8 @@ CONFIG_SCHEMA = ( } ) .extend(cv.COMPONENT_SCHEMA) - .extend(esp32_ble_tracker.ESP_BLE_DEVICE_SCHEMA) + .extend(esp32_ble_tracker.ESP_BLE_DEVICE_SCHEMA), + esp32_ble_tracker.consume_connection_slots(1, "ble_client"), ) CONF_BLE_CLIENT_ID = "ble_client_id" diff --git a/esphome/components/bluetooth_proxy/__init__.py b/esphome/components/bluetooth_proxy/__init__.py index edfea50473..04ac9116c7 100644 --- a/esphome/components/bluetooth_proxy/__init__.py +++ b/esphome/components/bluetooth_proxy/__init__.py @@ -8,9 +8,10 @@ AUTO_LOAD = ["esp32_ble_client", "esp32_ble_tracker"] DEPENDENCIES = ["api", "esp32"] CODEOWNERS = ["@jesserockz"] +CONF_CONNECTION_SLOTS = "connection_slots" CONF_CACHE_SERVICES = "cache_services" CONF_CONNECTIONS = "connections" -MAX_CONNECTIONS = 3 +DEFAULT_CONNECTION_SLOTS = 3 bluetooth_proxy_ns = cg.esphome_ns.namespace("bluetooth_proxy") @@ -35,28 +36,42 @@ def validate_connections(config): "Connections can only be used if the proxy is set to active" ) elif config[CONF_ACTIVE]: - conf = config.copy() - conf[CONF_CONNECTIONS] = [CONNECTION_SCHEMA({}) for _ in range(MAX_CONNECTIONS)] - return conf + connection_slots: int = config[CONF_CONNECTION_SLOTS] + esp32_ble_tracker.consume_connection_slots(connection_slots, "bluetooth_proxy")( + config + ) + return { + **config, + CONF_CONNECTIONS: [CONNECTION_SCHEMA({}) for _ in range(connection_slots)], + } return config CONFIG_SCHEMA = cv.All( - cv.Schema( - { - cv.GenerateID(): cv.declare_id(BluetoothProxy), - cv.Optional(CONF_ACTIVE, default=False): cv.boolean, - cv.SplitDefault(CONF_CACHE_SERVICES, esp32_idf=True): cv.All( - cv.only_with_esp_idf, cv.boolean - ), - cv.Optional(CONF_CONNECTIONS): cv.All( - cv.ensure_list(CONNECTION_SCHEMA), - cv.Length(min=1, max=MAX_CONNECTIONS), - ), - } - ) - .extend(esp32_ble_tracker.ESP_BLE_DEVICE_SCHEMA) - .extend(cv.COMPONENT_SCHEMA), + ( + cv.Schema( + { + cv.GenerateID(): cv.declare_id(BluetoothProxy), + cv.Optional(CONF_ACTIVE, default=False): cv.boolean, + cv.SplitDefault(CONF_CACHE_SERVICES, esp32_idf=True): cv.All( + cv.only_with_esp_idf, cv.boolean + ), + cv.Optional( + CONF_CONNECTION_SLOTS, + default=DEFAULT_CONNECTION_SLOTS, + ): cv.All( + cv.positive_int, + cv.Range(min=1, max=esp32_ble_tracker.max_connections()), + ), + cv.Optional(CONF_CONNECTIONS): cv.All( + cv.ensure_list(CONNECTION_SCHEMA), + cv.Length(min=1, max=esp32_ble_tracker.max_connections()), + ), + } + ) + .extend(esp32_ble_tracker.ESP_BLE_DEVICE_SCHEMA) + .extend(cv.COMPONENT_SCHEMA) + ), validate_connections, ) diff --git a/esphome/components/esp32_ble_tracker/__init__.py b/esphome/components/esp32_ble_tracker/__init__.py index 425ce54b9f..68be2cbbe9 100644 --- a/esphome/components/esp32_ble_tracker/__init__.py +++ b/esphome/components/esp32_ble_tracker/__init__.py @@ -1,3 +1,9 @@ +from __future__ import annotations + +from collections.abc import MutableMapping +import logging +from typing import Any, Callable + from esphome import automation import esphome.codegen as cg from esphome.components import esp32_ble @@ -29,11 +35,21 @@ from esphome.core import CORE AUTO_LOAD = ["esp32_ble"] DEPENDENCIES = ["esp32"] +KEY_ESP32_BLE_TRACKER = "esp32_ble_tracker" +KEY_USED_CONNECTION_SLOTS = "used_connection_slots" + +CONF_MAX_CONNECTIONS = "max_connections" CONF_ESP32_BLE_ID = "esp32_ble_id" CONF_SCAN_PARAMETERS = "scan_parameters" CONF_WINDOW = "window" CONF_CONTINUOUS = "continuous" CONF_ON_SCAN_END = "on_scan_end" + +DEFAULT_MAX_CONNECTIONS = 3 +IDF_MAX_CONNECTIONS = 9 + +_LOGGER = logging.getLogger(__name__) + esp32_ble_tracker_ns = cg.esphome_ns.namespace("esp32_ble_tracker") ESP32BLETracker = esp32_ble_tracker_ns.class_( "ESP32BLETracker", @@ -112,61 +128,126 @@ def as_reversed_hex_array(value): ) -CONFIG_SCHEMA = cv.Schema( - { - cv.GenerateID(): cv.declare_id(ESP32BLETracker), - cv.GenerateID(esp32_ble.CONF_BLE_ID): cv.use_id(esp32_ble.ESP32BLE), - cv.Optional(CONF_SCAN_PARAMETERS, default={}): cv.All( - cv.Schema( +def max_connections() -> int: + return IDF_MAX_CONNECTIONS if CORE.using_esp_idf else DEFAULT_MAX_CONNECTIONS + + +def consume_connection_slots( + value: int, consumer: str +) -> Callable[[MutableMapping], MutableMapping]: + def _consume_connection_slots(config: MutableMapping) -> MutableMapping: + data: dict[str, Any] = CORE.data.setdefault(KEY_ESP32_BLE_TRACKER, {}) + slots: list[str] = data.setdefault(KEY_USED_CONNECTION_SLOTS, []) + slots.extend([consumer] * value) + return config + + return _consume_connection_slots + + +CONFIG_SCHEMA = cv.All( + cv.Schema( + { + cv.GenerateID(): cv.declare_id(ESP32BLETracker), + cv.GenerateID(esp32_ble.CONF_BLE_ID): cv.use_id(esp32_ble.ESP32BLE), + cv.Optional(CONF_MAX_CONNECTIONS, default=DEFAULT_MAX_CONNECTIONS): cv.All( + cv.positive_int, cv.Range(min=0, max=max_connections()) + ), + cv.Optional(CONF_SCAN_PARAMETERS, default={}): cv.All( + cv.Schema( + { + cv.Optional( + CONF_DURATION, default="5min" + ): cv.positive_time_period_seconds, + cv.Optional( + CONF_INTERVAL, default="320ms" + ): cv.positive_time_period_milliseconds, + cv.Optional( + CONF_WINDOW, default="30ms" + ): cv.positive_time_period_milliseconds, + cv.Optional(CONF_ACTIVE, default=True): cv.boolean, + cv.Optional(CONF_CONTINUOUS, default=True): cv.boolean, + } + ), + validate_scan_parameters, + ), + cv.Optional(CONF_ON_BLE_ADVERTISE): automation.validate_automation( { - cv.Optional( - CONF_DURATION, default="5min" - ): cv.positive_time_period_seconds, - cv.Optional( - CONF_INTERVAL, default="320ms" - ): cv.positive_time_period_milliseconds, - cv.Optional( - CONF_WINDOW, default="30ms" - ): cv.positive_time_period_milliseconds, - cv.Optional(CONF_ACTIVE, default=True): cv.boolean, - cv.Optional(CONF_CONTINUOUS, default=True): cv.boolean, + cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id( + ESPBTAdvertiseTrigger + ), + cv.Optional(CONF_MAC_ADDRESS): cv.ensure_list(cv.mac_address), } ), - validate_scan_parameters, - ), - cv.Optional(CONF_ON_BLE_ADVERTISE): automation.validate_automation( - { - cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(ESPBTAdvertiseTrigger), - cv.Optional(CONF_MAC_ADDRESS): cv.ensure_list(cv.mac_address), - } - ), - cv.Optional(CONF_ON_BLE_SERVICE_DATA_ADVERTISE): automation.validate_automation( - { - cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id( - BLEServiceDataAdvertiseTrigger - ), - cv.Optional(CONF_MAC_ADDRESS): cv.mac_address, - cv.Required(CONF_SERVICE_UUID): bt_uuid, - } - ), - cv.Optional( - CONF_ON_BLE_MANUFACTURER_DATA_ADVERTISE - ): automation.validate_automation( - { - cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id( - BLEManufacturerDataAdvertiseTrigger - ), - cv.Optional(CONF_MAC_ADDRESS): cv.mac_address, - cv.Required(CONF_MANUFACTURER_ID): bt_uuid, - } - ), - cv.Optional(CONF_ON_SCAN_END): automation.validate_automation( - {cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(BLEEndOfScanTrigger)} - ), - } -).extend(cv.COMPONENT_SCHEMA) + cv.Optional( + CONF_ON_BLE_SERVICE_DATA_ADVERTISE + ): automation.validate_automation( + { + cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id( + BLEServiceDataAdvertiseTrigger + ), + cv.Optional(CONF_MAC_ADDRESS): cv.mac_address, + cv.Required(CONF_SERVICE_UUID): bt_uuid, + } + ), + cv.Optional( + CONF_ON_BLE_MANUFACTURER_DATA_ADVERTISE + ): automation.validate_automation( + { + cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id( + BLEManufacturerDataAdvertiseTrigger + ), + cv.Optional(CONF_MAC_ADDRESS): cv.mac_address, + cv.Required(CONF_MANUFACTURER_ID): bt_uuid, + } + ), + cv.Optional(CONF_ON_SCAN_END): automation.validate_automation( + {cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(BLEEndOfScanTrigger)} + ), + } + ).extend(cv.COMPONENT_SCHEMA), +) -FINAL_VALIDATE_SCHEMA = esp32_ble.validate_variant + +def validate_remaining_connections(config): + data: dict[str, Any] = CORE.data.get(KEY_ESP32_BLE_TRACKER, {}) + slots: list[str] = data.get(KEY_USED_CONNECTION_SLOTS, []) + used_slots = len(slots) + if used_slots <= config[CONF_MAX_CONNECTIONS]: + return config + slot_users = ", ".join(slots) + hard_limit = max_connections() + + if used_slots < hard_limit: + _LOGGER.warning( + "esp32_ble_tracker exceeded `%s`: components attempted to consume %d " + "connection slot(s) out of available configured maximum %d connection " + "slot(s); The system automatically increased `%s` to %d to match the " + "number of used connection slot(s) by components: %s.", + CONF_MAX_CONNECTIONS, + used_slots, + config[CONF_MAX_CONNECTIONS], + CONF_MAX_CONNECTIONS, + used_slots, + slot_users, + ) + config[CONF_MAX_CONNECTIONS] = used_slots + return config + + msg = ( + f"esp32_ble_tracker exceeded `{CONF_MAX_CONNECTIONS}`: " + f"components attempted to consume {used_slots} connection slot(s) " + f"out of available configured maximum {config[CONF_MAX_CONNECTIONS]} " + f"connection slot(s); Decrease the number of BLE clients ({slot_users})" + ) + if config[CONF_MAX_CONNECTIONS] < hard_limit: + msg += f" or increase {CONF_MAX_CONNECTIONS}` to {used_slots}" + msg += f" to stay under the {hard_limit} connection slot(s) limit." + raise cv.Invalid(msg) + + +FINAL_VALIDATE_SCHEMA = cv.All( + validate_remaining_connections, esp32_ble.validate_variant +) ESP_BLE_DEVICE_SCHEMA = cv.Schema( { @@ -238,6 +319,9 @@ async def to_code(config): else: add_idf_sdkconfig_option("CONFIG_BTU_TASK_STACK_SIZE", 8192) add_idf_sdkconfig_option("CONFIG_BT_ACL_CONNECTIONS", 9) + add_idf_sdkconfig_option( + "CONFIG_BTDM_CTRL_BLE_MAX_CONN", config[CONF_MAX_CONNECTIONS] + ) # CONFIG_BT_GATTC_NOTIF_REG_MAX controls the number of # max notifications in 5.x, setting CONFIG_BT_ACL_CONNECTIONS # is enough in 4.x diff --git a/tests/components/bluetooth_proxy/common.yaml b/tests/components/bluetooth_proxy/common.yaml new file mode 100644 index 0000000000..5e84f4a678 --- /dev/null +++ b/tests/components/bluetooth_proxy/common.yaml @@ -0,0 +1,8 @@ +wifi: + ssid: MySSID + password: password1 + +ota: + - platform: esphome + +api: diff --git a/tests/components/bluetooth_proxy/test.esp32-ard.yaml b/tests/components/bluetooth_proxy/test.esp32-ard.yaml new file mode 100644 index 0000000000..bf01b65b6f --- /dev/null +++ b/tests/components/bluetooth_proxy/test.esp32-ard.yaml @@ -0,0 +1,8 @@ +<<: !include common.yaml + +esp32_ble_tracker: + max_connections: 3 + +bluetooth_proxy: + active: true + connection_slots: 2 diff --git a/tests/components/bluetooth_proxy/test.esp32-c3-ard.yaml b/tests/components/bluetooth_proxy/test.esp32-c3-ard.yaml new file mode 100644 index 0000000000..bf01b65b6f --- /dev/null +++ b/tests/components/bluetooth_proxy/test.esp32-c3-ard.yaml @@ -0,0 +1,8 @@ +<<: !include common.yaml + +esp32_ble_tracker: + max_connections: 3 + +bluetooth_proxy: + active: true + connection_slots: 2 diff --git a/tests/components/bluetooth_proxy/test.esp32-c3-idf.yaml b/tests/components/bluetooth_proxy/test.esp32-c3-idf.yaml new file mode 100644 index 0000000000..6c27bd35d0 --- /dev/null +++ b/tests/components/bluetooth_proxy/test.esp32-c3-idf.yaml @@ -0,0 +1,8 @@ +<<: !include common.yaml + +esp32_ble_tracker: + max_connections: 9 + +bluetooth_proxy: + active: true + connection_slots: 9 diff --git a/tests/components/bluetooth_proxy/test.esp32-idf.yaml b/tests/components/bluetooth_proxy/test.esp32-idf.yaml new file mode 100644 index 0000000000..6c27bd35d0 --- /dev/null +++ b/tests/components/bluetooth_proxy/test.esp32-idf.yaml @@ -0,0 +1,8 @@ +<<: !include common.yaml + +esp32_ble_tracker: + max_connections: 9 + +bluetooth_proxy: + active: true + connection_slots: 9 diff --git a/tests/components/esp32_ble_tracker/test.esp32-ard.yaml b/tests/components/esp32_ble_tracker/test.esp32-ard.yaml index dade44d145..070fffd68b 100644 --- a/tests/components/esp32_ble_tracker/test.esp32-ard.yaml +++ b/tests/components/esp32_ble_tracker/test.esp32-ard.yaml @@ -1 +1,4 @@ <<: !include common.yaml + +esp32_ble_tracker: + max_connections: 3 diff --git a/tests/components/esp32_ble_tracker/test.esp32-c3-ard.yaml b/tests/components/esp32_ble_tracker/test.esp32-c3-ard.yaml index dade44d145..070fffd68b 100644 --- a/tests/components/esp32_ble_tracker/test.esp32-c3-ard.yaml +++ b/tests/components/esp32_ble_tracker/test.esp32-c3-ard.yaml @@ -1 +1,4 @@ <<: !include common.yaml + +esp32_ble_tracker: + max_connections: 3 diff --git a/tests/components/esp32_ble_tracker/test.esp32-c3-idf.yaml b/tests/components/esp32_ble_tracker/test.esp32-c3-idf.yaml index dade44d145..5e09f5020e 100644 --- a/tests/components/esp32_ble_tracker/test.esp32-c3-idf.yaml +++ b/tests/components/esp32_ble_tracker/test.esp32-c3-idf.yaml @@ -1 +1,4 @@ <<: !include common.yaml + +esp32_ble_tracker: + max_connections: 9 diff --git a/tests/components/esp32_ble_tracker/test.esp32-idf.yaml b/tests/components/esp32_ble_tracker/test.esp32-idf.yaml index dade44d145..5e09f5020e 100644 --- a/tests/components/esp32_ble_tracker/test.esp32-idf.yaml +++ b/tests/components/esp32_ble_tracker/test.esp32-idf.yaml @@ -1 +1,4 @@ <<: !include common.yaml + +esp32_ble_tracker: + max_connections: 9 From 9637ef35bd99d4d2209374a405306abafe09c6ab Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 7 Apr 2025 19:26:34 +1000 Subject: [PATCH 78/88] [component] Show error message for failed component (#8478) --- esphome/core/component.cpp | 4 +++- esphome/core/component.h | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/esphome/core/component.cpp b/esphome/core/component.cpp index a6224a17c0..b20964b872 100644 --- a/esphome/core/component.cpp +++ b/esphome/core/component.cpp @@ -79,7 +79,7 @@ void Component::call_setup() { this->setup(); } void Component::call_dump_config() { this->dump_config(); if (this->is_failed()) { - ESP_LOGE(TAG, " Component %s is marked FAILED", this->get_component_source()); + ESP_LOGE(TAG, " Component %s is marked FAILED: %s", this->get_component_source(), this->error_message_.c_str()); } } @@ -162,6 +162,8 @@ void Component::status_set_error(const char *message) { this->component_state_ |= STATUS_LED_ERROR; App.app_state_ |= STATUS_LED_ERROR; ESP_LOGE(TAG, "Component %s set Error flag: %s", this->get_component_source(), message); + if (strcmp(message, "unspecified") != 0) + this->error_message_ = message; } void Component::status_clear_warning() { if ((this->component_state_ & STATUS_LED_WARNING) == 0) diff --git a/esphome/core/component.h b/esphome/core/component.h index e6ed55efb7..f5c56459b1 100644 --- a/esphome/core/component.h +++ b/esphome/core/component.h @@ -118,6 +118,11 @@ class Component { */ virtual void mark_failed(); + void mark_failed(const char *message) { + this->status_set_error(message); + this->mark_failed(); + } + bool is_failed() const; bool is_ready() const; @@ -279,6 +284,7 @@ class Component { uint32_t component_state_{0x0000}; ///< State of this component. float setup_priority_override_{NAN}; const char *component_source_{nullptr}; + std::string error_message_{}; }; /** This class simplifies creating components that periodically check a state. From 23dec912ad9aaa651e7d261343d4cfef8e320064 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Mon, 7 Apr 2025 22:49:40 +1000 Subject: [PATCH 79/88] [psram] Allow use of experimental 120MHz octal mode (#8519) --- esphome/components/esp32/__init__.py | 7 ++ esphome/components/psram/__init__.py | 65 +++++++++++++++++-- esphome/components/psram/psram.cpp | 25 +++++-- tests/components/psram/common.yaml | 1 - tests/components/psram/test.esp32-c3-ard.yaml | 1 - tests/components/psram/test.esp32-c3-idf.yaml | 1 - tests/components/psram/test.esp32-s3-ard.yaml | 4 +- tests/components/psram/test.esp32-s3-idf.yaml | 11 +++- 8 files changed, 98 insertions(+), 17 deletions(-) delete mode 100644 tests/components/psram/test.esp32-c3-ard.yaml delete mode 100644 tests/components/psram/test.esp32-c3-idf.yaml diff --git a/esphome/components/esp32/__init__.py b/esphome/components/esp32/__init__.py index d66369f789..912a8bf94b 100644 --- a/esphome/components/esp32/__init__.py +++ b/esphome/components/esp32/__init__.py @@ -67,6 +67,7 @@ AUTO_LOAD = ["preferences"] IS_TARGET_PLATFORM = True CONF_RELEASE = "release" +CONF_ENABLE_IDF_EXPERIMENTAL_FEATURES = "enable_idf_experimental_features" def set_core_data(config): @@ -506,6 +507,7 @@ ESP_IDF_FRAMEWORK_SCHEMA = cv.All( CONF_IGNORE_EFUSE_CUSTOM_MAC, default=False ): cv.boolean, cv.Optional(CONF_IGNORE_EFUSE_MAC_CRC): cv.boolean, + cv.Optional(CONF_ENABLE_IDF_EXPERIMENTAL_FEATURES): cv.boolean, } ), cv.Optional(CONF_COMPONENTS, default=[]): cv.ensure_list( @@ -645,6 +647,11 @@ async def to_code(config): add_idf_sdkconfig_option( "CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE", False ) + if conf[CONF_ADVANCED].get(CONF_ENABLE_IDF_EXPERIMENTAL_FEATURES): + _LOGGER.warning( + "Using experimental features in ESP-IDF may result in unexpected failures." + ) + add_idf_sdkconfig_option("CONFIG_IDF_EXPERIMENTAL_FEATURES", True) cg.add_define( "USE_ESP_IDF_VERSION_CODE", diff --git a/esphome/components/psram/__init__.py b/esphome/components/psram/__init__.py index e83cf3ed99..f268d5747f 100644 --- a/esphome/components/psram/__init__.py +++ b/esphome/components/psram/__init__.py @@ -1,17 +1,40 @@ +import logging + import esphome.codegen as cg -from esphome.components.esp32 import add_idf_sdkconfig_option, get_esp32_variant +from esphome.components.esp32 import ( + CONF_ENABLE_IDF_EXPERIMENTAL_FEATURES, + VARIANT_ESP32, + add_idf_sdkconfig_option, + get_esp32_variant, + only_on_variant, +) +from esphome.components.esp32.const import VARIANT_ESP32S2, VARIANT_ESP32S3 import esphome.config_validation as cv -from esphome.const import CONF_ID, CONF_MODE, CONF_SPEED +from esphome.const import ( + CONF_ADVANCED, + CONF_FRAMEWORK, + CONF_ID, + CONF_MODE, + CONF_SPEED, + PLATFORM_ESP32, +) from esphome.core import CORE +import esphome.final_validate as fv CODEOWNERS = ["@esphome/core"] +DEPENDENCIES = [PLATFORM_ESP32] + +_LOGGER = logging.getLogger(__name__) + psram_ns = cg.esphome_ns.namespace("psram") PsramComponent = psram_ns.class_("PsramComponent", cg.Component) TYPE_QUAD = "quad" TYPE_OCTAL = "octal" +CONF_ENABLE_ECC = "enable_ecc" + SPIRAM_MODES = { TYPE_QUAD: "CONFIG_SPIRAM_MODE_QUAD", TYPE_OCTAL: "CONFIG_SPIRAM_MODE_OCT", @@ -26,7 +49,25 @@ SPIRAM_SPEEDS = { def validate_psram_mode(config): if config[CONF_MODE] == TYPE_OCTAL and config[CONF_SPEED] == 120e6: - raise cv.Invalid("PSRAM 120MHz is not supported in octal mode") + esp32_config = fv.full_config.get()[PLATFORM_ESP32] + if ( + esp32_config[CONF_FRAMEWORK] + .get(CONF_ADVANCED, {}) + .get(CONF_ENABLE_IDF_EXPERIMENTAL_FEATURES) + ): + _LOGGER.warning( + "120MHz PSRAM in octal mode is an experimental feature - use at your own risk" + ) + else: + raise cv.Invalid("PSRAM 120MHz is not supported in octal mode") + if config[CONF_MODE] != TYPE_OCTAL and config[CONF_ENABLE_ECC]: + raise cv.Invalid("ECC is only available in octal mode.") + if config[CONF_MODE] == TYPE_OCTAL: + variant = get_esp32_variant() + if variant != VARIANT_ESP32S3: + raise cv.Invalid( + f"Octal PSRAM is only supported on ESP32-S3, not {variant}" + ) return config @@ -37,19 +78,25 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_MODE, default=TYPE_QUAD): cv.enum( SPIRAM_MODES, lower=True ), + cv.Optional(CONF_ENABLE_ECC, default=False): cv.boolean, cv.Optional(CONF_SPEED, default=40e6): cv.All( cv.frequency, cv.one_of(*SPIRAM_SPEEDS) ), } ), - cv.only_on_esp32, - validate_psram_mode, + only_on_variant( + supported=[VARIANT_ESP32, VARIANT_ESP32S3, VARIANT_ESP32S2], + ), ) +FINAL_VALIDATE_SCHEMA = validate_psram_mode + async def to_code(config): if CORE.using_arduino: cg.add_build_flag("-DBOARD_HAS_PSRAM") + if config[CONF_MODE] == TYPE_OCTAL: + cg.add_platformio_option("board_build.arduino.memory_type", "qio_opi") if CORE.using_esp_idf: add_idf_sdkconfig_option( @@ -62,6 +109,14 @@ async def to_code(config): add_idf_sdkconfig_option(f"{SPIRAM_MODES[config[CONF_MODE]]}", True) add_idf_sdkconfig_option(f"{SPIRAM_SPEEDS[config[CONF_SPEED]]}", True) + if config[CONF_MODE] == TYPE_OCTAL and config[CONF_SPEED] == 120e6: + add_idf_sdkconfig_option("CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240", True) + # This works only on IDF 5.4.x but does no harm on earlier versions + add_idf_sdkconfig_option( + "CONFIG_SPIRAM_TIMING_TUNING_POINT_VIA_TEMPERATURE_SENSOR", True + ) + if config[CONF_ENABLE_ECC]: + add_idf_sdkconfig_option("CONFIG_SPIRAM_ECC_ENABLE", True) cg.add_define("USE_PSRAM") diff --git a/esphome/components/psram/psram.cpp b/esphome/components/psram/psram.cpp index d9a5bd101f..f592ada246 100644 --- a/esphome/components/psram/psram.cpp +++ b/esphome/components/psram/psram.cpp @@ -1,25 +1,36 @@ -#include "psram.h" #ifdef USE_ESP32 +#include "psram.h" +#ifdef USE_ESP_IDF +#include +#endif // USE_ESP_IDF #include "esphome/core/log.h" #include -#include namespace esphome { namespace psram { - static const char *const TAG = "psram"; void PsramComponent::dump_config() { + ESP_LOGCONFIG(TAG, "PSRAM:"); +#ifdef USE_ESP_IDF + bool available = esp_psram_is_initialized(); + + ESP_LOGCONFIG(TAG, " Available: %s", YESNO(available)); + if (available) { + ESP_LOGCONFIG(TAG, " Size: %zu KB", esp_psram_get_size() / 1024); +#if CONFIG_SPIRAM_ECC_ENABLE + ESP_LOGCONFIG(TAG, " ECC enabled: YES"); +#endif + } +#else // Technically this can be false if the PSRAM is full, but heap_caps_get_total_size() isn't always available, and it's // very unlikely for the PSRAM to be full. bool available = heap_caps_get_free_size(MALLOC_CAP_SPIRAM) > 0; - - ESP_LOGCONFIG(TAG, "PSRAM:"); ESP_LOGCONFIG(TAG, " Available: %s", YESNO(available)); -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 1, 0) + if (available) { const size_t psram_total_size_bytes = heap_caps_get_total_size(MALLOC_CAP_SPIRAM); const float psram_total_size_kb = psram_total_size_bytes / 1024.0f; @@ -30,7 +41,7 @@ void PsramComponent::dump_config() { ESP_LOGCONFIG(TAG, " Size: %zu bytes", psram_total_size_bytes); } } -#endif +#endif // USE_ESP_IDF } } // namespace psram diff --git a/tests/components/psram/common.yaml b/tests/components/psram/common.yaml index cfd39f77fe..9c6e3f2a60 100644 --- a/tests/components/psram/common.yaml +++ b/tests/components/psram/common.yaml @@ -1,3 +1,2 @@ psram: - mode: octal speed: 80MHz diff --git a/tests/components/psram/test.esp32-c3-ard.yaml b/tests/components/psram/test.esp32-c3-ard.yaml deleted file mode 100644 index dade44d145..0000000000 --- a/tests/components/psram/test.esp32-c3-ard.yaml +++ /dev/null @@ -1 +0,0 @@ -<<: !include common.yaml diff --git a/tests/components/psram/test.esp32-c3-idf.yaml b/tests/components/psram/test.esp32-c3-idf.yaml deleted file mode 100644 index dade44d145..0000000000 --- a/tests/components/psram/test.esp32-c3-idf.yaml +++ /dev/null @@ -1 +0,0 @@ -<<: !include common.yaml diff --git a/tests/components/psram/test.esp32-s3-ard.yaml b/tests/components/psram/test.esp32-s3-ard.yaml index dade44d145..cfd39f77fe 100644 --- a/tests/components/psram/test.esp32-s3-ard.yaml +++ b/tests/components/psram/test.esp32-s3-ard.yaml @@ -1 +1,3 @@ -<<: !include common.yaml +psram: + mode: octal + speed: 80MHz diff --git a/tests/components/psram/test.esp32-s3-idf.yaml b/tests/components/psram/test.esp32-s3-idf.yaml index dade44d145..e0e7fb52f6 100644 --- a/tests/components/psram/test.esp32-s3-idf.yaml +++ b/tests/components/psram/test.esp32-s3-idf.yaml @@ -1 +1,10 @@ -<<: !include common.yaml +esp32: + framework: + type: esp-idf + advanced: + enable_idf_experimental_features: yes + +psram: + mode: octal + speed: 120MHz + enable_ecc: true From 8269e2c961456a66b97a245eef4a10cdc7b11425 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 8 Apr 2025 12:27:23 -1000 Subject: [PATCH 80/88] Ensure plaintext responds with bad indicator byte before dropping the connection (#8521) --- esphome/components/api/api_frame_helper.cpp | 22 ++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/esphome/components/api/api_frame_helper.cpp b/esphome/components/api/api_frame_helper.cpp index 62f375508c..9e1b1521dd 100644 --- a/esphome/components/api/api_frame_helper.cpp +++ b/esphome/components/api/api_frame_helper.cpp @@ -893,8 +893,28 @@ APIError APIPlaintextFrameHelper::read_packet(ReadPacketBuffer *buffer) { ParsedFrame frame; aerr = try_read_frame_(&frame); - if (aerr != APIError::OK) + if (aerr != APIError::OK) { + if (aerr == APIError::BAD_INDICATOR) { + // Make sure to tell the remote that we don't + // understand the indicator byte so it knows + // we do not support it. + struct iovec iov[1]; + // The \x00 first byte is the marker for plaintext. + // + // The remote will know how to handle the indicator byte, + // but it likely won't understand the rest of the message. + // + // We must send at least 3 bytes to be read, so we add + // a message after the indicator byte to ensures its long + // enough and can aid in debugging. + const char msg[] = "\x00" + "Bad indicator byte"; + iov[0].iov_base = (void *) msg; + iov[0].iov_len = 19; + write_raw_(iov, 1); + } return aerr; + } buffer->container = std::move(frame.msg); buffer->data_offset = 0; From 2291a1dc39f989f26d443d5047057ecc2f6094e6 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 8 Apr 2025 12:58:26 -1000 Subject: [PATCH 81/88] Bump aioesphomeapi to 29.9.0 (#8522) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ef1542ffe9..0ee928569b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ platformio==6.1.18 # When updating platformio, also update /docker/Dockerfile esptool==4.8.1 click==8.1.7 esphome-dashboard==20250212.0 -aioesphomeapi==29.7.0 +aioesphomeapi==29.9.0 zeroconf==0.146.3 puremagic==1.28 ruamel.yaml==0.18.10 # dashboard_import From 1c72fd4674f769af5f7d23ebc78035dab7416732 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 9 Apr 2025 09:00:39 +1000 Subject: [PATCH 82/88] [lvgl] add on_boot trigger (#8498) --- esphome/components/lvgl/__init__.py | 4 +++- esphome/components/lvgl/schemas.py | 28 ++++++++++++++++++------- esphome/components/lvgl/trigger.py | 11 +++++++++- tests/components/lvgl/lvgl-package.yaml | 6 ++++++ 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/esphome/components/lvgl/__init__.py b/esphome/components/lvgl/__init__.py index 22571c2550..a3e4ee83fa 100644 --- a/esphome/components/lvgl/__init__.py +++ b/esphome/components/lvgl/__init__.py @@ -10,6 +10,7 @@ from esphome.const import ( CONF_GROUP, CONF_ID, CONF_LAMBDA, + CONF_ON_BOOT, CONF_ON_IDLE, CONF_PAGES, CONF_TIMEOUT, @@ -50,7 +51,7 @@ from .schemas import ( ) from .styles import add_top_layer, styles_to_code, theme_to_code from .touchscreens import touchscreen_schema, touchscreens_to_code -from .trigger import generate_triggers +from .trigger import add_on_boot_triggers, generate_triggers from .types import ( FontEngine, IdleTrigger, @@ -365,6 +366,7 @@ async def to_code(configs): conf[CONF_TRIGGER_ID], lv_component, False ) await build_automation(resume_trigger, [], conf) + await add_on_boot_triggers(config.get(CONF_ON_BOOT, ())) # This must be done after all widgets are created for comp in helpers.lvgl_components_required: diff --git a/esphome/components/lvgl/schemas.py b/esphome/components/lvgl/schemas.py index ae50d5b2e1..6321ae276f 100644 --- a/esphome/components/lvgl/schemas.py +++ b/esphome/components/lvgl/schemas.py @@ -6,6 +6,7 @@ from esphome.const import ( CONF_FORMAT, CONF_GROUP, CONF_ID, + CONF_ON_BOOT, CONF_ON_VALUE, CONF_STATE, CONF_TEXT, @@ -14,6 +15,7 @@ from esphome.const import ( CONF_TYPE, ) from esphome.core import TimePeriod +from esphome.core.config import StartupTrigger from esphome.schema_extractors import SCHEMA_EXTRACT from . import defines as df, lv_validation as lvalid @@ -216,14 +218,24 @@ def automation_schema(typ: LvType): events = events + (CONF_ON_VALUE,) args = typ.get_arg_type() if isinstance(typ, LvType) else [] args.append(lv_event_t_ptr) - return { - cv.Optional(event): validate_automation( - { - cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(Trigger.template(*args)), - } - ) - for event in events - } + return cv.Schema( + { + cv.Optional(event): validate_automation( + { + cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id( + Trigger.template(*args) + ), + } + ) + for event in events + } + ).extend( + { + cv.Optional(CONF_ON_BOOT): validate_automation( + {cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(StartupTrigger)} + ) + } + ) def base_update_schema(widget_type, parts): diff --git a/esphome/components/lvgl/trigger.py b/esphome/components/lvgl/trigger.py index b76f90fecd..283c9a5e56 100644 --- a/esphome/components/lvgl/trigger.py +++ b/esphome/components/lvgl/trigger.py @@ -1,6 +1,6 @@ from esphome import automation import esphome.codegen as cg -from esphome.const import CONF_ID, CONF_ON_VALUE, CONF_TRIGGER_ID +from esphome.const import CONF_ID, CONF_ON_BOOT, CONF_ON_VALUE, CONF_TRIGGER_ID from .defines import ( CONF_ALIGN, @@ -28,6 +28,13 @@ from .types import LV_EVENT from .widgets import LvScrActType, get_scr_act, widget_map +async def add_on_boot_triggers(triggers): + for conf in triggers: + trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], 390) + await cg.register_component(trigger, conf) + await automation.build_automation(trigger, [], conf) + + async def generate_triggers(): """ Generate LVGL triggers for all defined widgets @@ -75,6 +82,8 @@ async def generate_triggers(): UPDATE_EVENT, ) + await add_on_boot_triggers(w.config.get(CONF_ON_BOOT, ())) + # Generate align to directives while we're here if align_to := w.config.get(CONF_ALIGN_TO): target = widget_map[align_to[CONF_ID]].obj diff --git a/tests/components/lvgl/lvgl-package.yaml b/tests/components/lvgl/lvgl-package.yaml index c527f51b1e..3dde14194e 100644 --- a/tests/components/lvgl/lvgl-package.yaml +++ b/tests/components/lvgl/lvgl-package.yaml @@ -24,6 +24,8 @@ lvgl: logger.log: LVGL is Paused on_resume: logger.log: LVGL has resumed + on_boot: + logger.log: LVGL has started bg_color: light_blue disp_bg_color: color_id disp_bg_image: cat_image @@ -210,6 +212,10 @@ lvgl: src: !lambda "return {dog_image, cat_image};" duration: 2s - label: + on_boot: + lvgl.label.update: + id: hello_label + text: Goodbye Cruel World id: hello_label text: Hello world text_color: 0xFF8000 From 6240bfff97181629a1b2f2089560f752074310c1 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 9 Apr 2025 09:03:29 +1000 Subject: [PATCH 83/88] [lvgl] Make line points templatable (#8502) --- esphome/components/lvgl/__init__.py | 1 + esphome/components/lvgl/automation.py | 2 +- esphome/components/lvgl/defines.py | 4 ++ esphome/components/lvgl/lvcode.py | 4 -- esphome/components/lvgl/lvgl_esphome.h | 14 +++++++ esphome/components/lvgl/schemas.py | 29 ++++++++++++- esphome/components/lvgl/widgets/line.py | 54 ++++++++++--------------- tests/components/lvgl/lvgl-package.yaml | 10 +++++ 8 files changed, 80 insertions(+), 38 deletions(-) diff --git a/esphome/components/lvgl/__init__.py b/esphome/components/lvgl/__init__.py index a3e4ee83fa..f3cb809e7e 100644 --- a/esphome/components/lvgl/__init__.py +++ b/esphome/components/lvgl/__init__.py @@ -375,6 +375,7 @@ async def to_code(configs): add_define("LV_COLOR_SCREEN_TRANSP", "1") for use in helpers.lv_uses: add_define(f"LV_USE_{use.upper()}") + cg.add_define(f"USE_LVGL_{use.upper()}") lv_conf_h_file = CORE.relative_src_path(LV_CONF_FILENAME) write_file_if_changed(lv_conf_h_file, generate_lv_conf_h()) cg.add_build_flag("-DLV_CONF_H=1") diff --git a/esphome/components/lvgl/automation.py b/esphome/components/lvgl/automation.py index 168fc03cb7..b0979b2848 100644 --- a/esphome/components/lvgl/automation.py +++ b/esphome/components/lvgl/automation.py @@ -17,6 +17,7 @@ from .defines import ( CONF_SHOW_SNOW, PARTS, literal, + static_cast, ) from .lv_validation import lv_bool, lv_color, lv_image, opacity from .lvcode import ( @@ -32,7 +33,6 @@ from .lvcode import ( lv_expr, lv_obj, lvgl_comp, - static_cast, ) from .schemas import DISP_BG_SCHEMA, LIST_ACTION_SCHEMA, LVGL_SCHEMA, base_update_schema from .types import ( diff --git a/esphome/components/lvgl/defines.py b/esphome/components/lvgl/defines.py index a713124bb3..03599de284 100644 --- a/esphome/components/lvgl/defines.py +++ b/esphome/components/lvgl/defines.py @@ -35,6 +35,10 @@ def literal(arg): return arg +def static_cast(type, value): + return literal(f"static_cast<{type}>({value})") + + def call_lambda(lamb: LambdaExpression): expr = lamb.content.strip() if expr.startswith("return") and expr.endswith(";"): diff --git a/esphome/components/lvgl/lvcode.py b/esphome/components/lvgl/lvcode.py index 6b98cc4251..0ab5f9e18e 100644 --- a/esphome/components/lvgl/lvcode.py +++ b/esphome/components/lvgl/lvcode.py @@ -285,10 +285,6 @@ class LvExpr(MockLv): pass -def static_cast(type, value): - return literal(f"static_cast<{type}>({value})") - - # Top level mock for generic lv_ calls to be recorded lv = MockLv("lv_") # Just generate an expression diff --git a/esphome/components/lvgl/lvgl_esphome.h b/esphome/components/lvgl/lvgl_esphome.h index 69fa808d53..be6379249f 100644 --- a/esphome/components/lvgl/lvgl_esphome.h +++ b/esphome/components/lvgl/lvgl_esphome.h @@ -90,6 +90,7 @@ inline void lv_animimg_set_src(lv_obj_t *img, std::vector images // Parent class for things that wrap an LVGL object class LvCompound { public: + virtual ~LvCompound() = default; virtual void set_obj(lv_obj_t *lv_obj) { this->obj = lv_obj; } lv_obj_t *obj{}; }; @@ -330,6 +331,19 @@ class LVEncoderListener : public Parented { }; #endif // USE_LVGL_KEY_LISTENER +#ifdef USE_LVGL_LINE +class LvLineType : public LvCompound { + public: + std::vector get_points() { return this->points_; } + void set_points(std::vector points) { + this->points_ = std::move(points); + lv_line_set_points(this->obj, this->points_.data(), this->points_.size()); + } + + protected: + std::vector points_{}; +}; +#endif #if defined(USE_LVGL_DROPDOWN) || defined(LV_USE_ROLLER) class LvSelectable : public LvCompound { public: diff --git a/esphome/components/lvgl/schemas.py b/esphome/components/lvgl/schemas.py index 6321ae276f..89c9502d27 100644 --- a/esphome/components/lvgl/schemas.py +++ b/esphome/components/lvgl/schemas.py @@ -19,7 +19,7 @@ from esphome.core.config import StartupTrigger from esphome.schema_extractors import SCHEMA_EXTRACT from . import defines as df, lv_validation as lvalid -from .defines import CONF_TIME_FORMAT, LV_GRAD_DIR +from .defines import CONF_TIME_FORMAT, CONF_X, CONF_Y, LV_GRAD_DIR from .helpers import add_lv_use, requires_component, validate_printf from .lv_validation import lv_color, lv_font, lv_gradient, lv_image, opacity from .lvcode import LvglComponent, lv_event_t_ptr @@ -87,6 +87,33 @@ ENCODER_SCHEMA = cv.Schema( } ) + +def point_shorthand(value): + """ + A shorthand for a point in the form of x,y + :param value: The value to check + :return: The value as a tuple of x,y + """ + if isinstance(value, str): + try: + x, y = map(int, value.split(",")) + return {CONF_X: x, CONF_Y: y} + except ValueError: + pass + raise cv.Invalid("Invalid point format, should be , ") + + +POINT_SCHEMA = cv.Any( + cv.Schema( + { + cv.Required(CONF_X): cv.templatable(cv.int_), + cv.Required(CONF_Y): cv.templatable(cv.int_), + } + ), + point_shorthand, +) + + # All LVGL styles and their validators STYLE_PROPS = { "align": df.CHILD_ALIGNMENTS.one_of, diff --git a/esphome/components/lvgl/widgets/line.py b/esphome/components/lvgl/widgets/line.py index 0156fb1780..220e3a3b57 100644 --- a/esphome/components/lvgl/widgets/line.py +++ b/esphome/components/lvgl/widgets/line.py @@ -1,11 +1,11 @@ -import functools - import esphome.codegen as cg import esphome.config_validation as cv +from esphome.core import Lambda -from ..defines import CONF_MAIN -from ..lvcode import lv -from ..types import LvType +from ..defines import CONF_MAIN, CONF_X, CONF_Y, call_lambda +from ..lvcode import lv_add +from ..schemas import POINT_SCHEMA +from ..types import LvCompound, LvType from . import Widget, WidgetType CONF_LINE = "line" @@ -15,47 +15,37 @@ CONF_POINT_LIST_ID = "point_list_id" lv_point_t = cg.global_ns.struct("lv_point_t") -def point_list(il): - il = cv.string(il) - nl = il.replace(" ", "").split(",") - return [int(n) for n in nl] - - -def cv_point_list(value): - if not isinstance(value, list): - raise cv.Invalid("List of points required") - values = [point_list(v) for v in value] - if not functools.reduce(lambda f, v: f and len(v) == 2, values, True): - raise cv.Invalid("Points must be a list of x,y integer pairs") - return values - - LINE_SCHEMA = { - cv.Required(CONF_POINTS): cv_point_list, - cv.GenerateID(CONF_POINT_LIST_ID): cv.declare_id(lv_point_t), + cv.Required(CONF_POINTS): cv.ensure_list(POINT_SCHEMA), } -LINE_MODIFY_SCHEMA = { - cv.Optional(CONF_POINTS): cv_point_list, - cv.GenerateID(CONF_POINT_LIST_ID): cv.declare_id(lv_point_t), -} + +async def process_coord(coord): + if isinstance(coord, Lambda): + coord = call_lambda( + await cg.process_lambda(coord, (), return_type="lv_coord_t") + ) + if not coord.endswith("()"): + coord = f"static_cast({coord})" + return cg.RawExpression(coord) + return cg.safe_exp(coord) class LineType(WidgetType): def __init__(self): super().__init__( CONF_LINE, - LvType("lv_line_t"), + LvType("LvLineType", parents=(LvCompound,)), (CONF_MAIN,), LINE_SCHEMA, - modify_schema=LINE_MODIFY_SCHEMA, ) async def to_code(self, w: Widget, config): - """For a line object, create and add the points""" - if data := config.get(CONF_POINTS): - points = cg.static_const_array(config[CONF_POINT_LIST_ID], data) - lv.line_set_points(w.obj, points, len(data)) + points = [ + [await process_coord(p[CONF_X]), await process_coord(p[CONF_Y])] + for p in config[CONF_POINTS] + ] + lv_add(w.var.set_points(points)) line_spec = LineType() diff --git a/tests/components/lvgl/lvgl-package.yaml b/tests/components/lvgl/lvgl-package.yaml index 3dde14194e..3048ad1951 100644 --- a/tests/components/lvgl/lvgl-package.yaml +++ b/tests/components/lvgl/lvgl-package.yaml @@ -614,6 +614,8 @@ lvgl: align: center points: - 5, 5 + - x: !lambda return random_uint32() % 100; + y: !lambda return random_uint32() % 100; - 70, 70 - 120, 10 - 180, 60 @@ -622,6 +624,14 @@ lvgl: - lvgl.line.update: id: lv_line_id line_color: 0xFFFF + points: + - 5, 5 + - x: !lambda return random_uint32() % 100; + y: !lambda return random_uint32() % 100; + - 70, 70 + - 120, 10 + - 180, 60 + - 240, 10 - lvgl.page.next: - switch: align: right_mid From a866370a2e0a415b7c77c929e5480d20bbbacdf8 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 9 Apr 2025 09:07:59 +1000 Subject: [PATCH 84/88] [spi] Implement octal mode (#8386) --- esphome/components/qspi_dbi/display.py | 2 +- esphome/components/spi/__init__.py | 81 ++++++++++++--------- esphome/components/spi/spi.h | 1 + esphome/components/spi/spi_esp_idf.cpp | 18 +++-- tests/components/spi/test.esp32-s3-idf.yaml | 42 +++++++---- 5 files changed, 88 insertions(+), 56 deletions(-) diff --git a/esphome/components/qspi_dbi/display.py b/esphome/components/qspi_dbi/display.py index ab6dd66cf2..8c29991f37 100644 --- a/esphome/components/qspi_dbi/display.py +++ b/esphome/components/qspi_dbi/display.py @@ -113,7 +113,7 @@ BASE_SCHEMA = display.FULL_DISPLAY_SCHEMA.extend( cs_pin_required=False, default_mode="MODE0", default_data_rate=10e6, - quad=True, + mode=spi.TYPE_QUAD, ) ) ) diff --git a/esphome/components/spi/__init__.py b/esphome/components/spi/__init__.py index 3e6d680b89..5b28b3546b 100644 --- a/esphome/components/spi/__init__.py +++ b/esphome/components/spi/__init__.py @@ -37,6 +37,7 @@ CODEOWNERS = ["@esphome/core", "@clydebarrow"] spi_ns = cg.esphome_ns.namespace("spi") SPIComponent = spi_ns.class_("SPIComponent", cg.Component) QuadSPIComponent = spi_ns.class_("QuadSPIComponent", cg.Component) +OctalSPIComponent = spi_ns.class_("OctalSPIComponent", cg.Component) SPIDevice = spi_ns.class_("SPIDevice") SPIDataRate = spi_ns.enum("SPIDataRate") SPIMode = spi_ns.enum("SPIMode") @@ -78,6 +79,13 @@ CONF_INTERFACE = "interface" CONF_INTERFACE_INDEX = "interface_index" TYPE_SINGLE = "single" TYPE_QUAD = "quad" +TYPE_OCTAL = "octal" + +TYPE_CLASS = { + TYPE_SINGLE: SPIComponent, + TYPE_QUAD: QuadSPIComponent, + TYPE_OCTAL: OctalSPIComponent, +} # RP2040 SPI pin assignments are complicated; # refer to GPIO function select table in https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf @@ -230,7 +238,7 @@ def validate_spi_config(config): ): raise cv.Invalid("Invalid pin selections for hardware SPI interface") if CONF_DATA_PINS in spi and CONF_INTERFACE_INDEX not in spi: - raise cv.Invalid("Quad mode requires a hardware interface") + raise cv.Invalid("Quad and octal modes requires a hardware interface") return config @@ -251,7 +259,7 @@ def get_spi_interface(index): return "new SPIClass(HSPI)" -SPI_SCHEMA = cv.All( +SPI_SINGLE_SCHEMA = cv.All( cv.Schema( { cv.GenerateID(): cv.declare_id(SPIComponent), @@ -266,7 +274,7 @@ SPI_SCHEMA = cv.All( lower=True, ), cv.Optional(CONF_DATA_PINS): cv.invalid( - "'data_pins' should be used with 'type: quad' only" + "'data_pins' should be used with 'type: quad or octal' only" ), } ), @@ -274,38 +282,41 @@ SPI_SCHEMA = cv.All( cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_RP2040]), ) -SPI_QUAD_SCHEMA = cv.All( - cv.Schema( - { - cv.GenerateID(): cv.declare_id(QuadSPIComponent), - cv.Required(CONF_CLK_PIN): pins.gpio_output_pin_schema, - cv.Required(CONF_DATA_PINS): cv.All( - cv.ensure_list(pins.internal_gpio_output_pin_number), - cv.Length(min=4, max=4), - ), - cv.Optional(CONF_INTERFACE, default="hardware"): cv.one_of( - *sum(get_hw_interface_list(), ["hardware"]), - lower=True, - ), - cv.Optional(CONF_MISO_PIN): cv.invalid( - "'miso_pin' should not be used with quad SPI" - ), - cv.Optional(CONF_MOSI_PIN): cv.invalid( - "'mosi_pin' should not be used with quad SPI" - ), - } - ), - cv.only_on([PLATFORM_ESP32]), - cv.only_with_esp_idf, -) + +def spi_mode_schema(mode): + if mode == TYPE_SINGLE: + return SPI_SINGLE_SCHEMA + pin_count = 4 if mode == TYPE_QUAD else 8 + return cv.All( + cv.Schema( + { + cv.GenerateID(): cv.declare_id(TYPE_CLASS[mode]), + cv.Required(CONF_CLK_PIN): pins.gpio_output_pin_schema, + cv.Required(CONF_DATA_PINS): cv.All( + cv.ensure_list(pins.internal_gpio_output_pin_number), + cv.Length(min=pin_count, max=pin_count), + ), + cv.Optional(CONF_INTERFACE, default="hardware"): cv.one_of( + *sum(get_hw_interface_list(), ["hardware"]), + lower=True, + ), + cv.Optional(CONF_MISO_PIN): cv.invalid( + f"'miso_pin' should not be used with {mode} SPI" + ), + cv.Optional(CONF_MOSI_PIN): cv.invalid( + f"'mosi_pin' should not be used with {mode} SPI" + ), + } + ), + cv.only_on([PLATFORM_ESP32]), + cv.only_with_esp_idf, + ) + CONFIG_SCHEMA = cv.All( cv.ensure_list( cv.typed_schema( - { - TYPE_SINGLE: SPI_SCHEMA, - TYPE_QUAD: SPI_QUAD_SCHEMA, - }, + {k: spi_mode_schema(k) for k in TYPE_CLASS}, default_type=TYPE_SINGLE, ) ), @@ -344,19 +355,17 @@ def spi_device_schema( cs_pin_required=True, default_data_rate=cv.UNDEFINED, default_mode=cv.UNDEFINED, - quad=False, + mode=TYPE_SINGLE, ): """Create a schema for an SPI device. :param cs_pin_required: If true, make the CS_PIN required in the config. :param default_data_rate: Optional data_rate to use as default :param default_mode Optional. The default SPI mode to use. - :param quad If set, will require an SPI component configured as quad data bits. + :param mode Choose single, quad or octal mode. :return: The SPI device schema, `extend` this in your config schema. """ schema = { - cv.GenerateID(CONF_SPI_ID): cv.use_id( - QuadSPIComponent if quad else SPIComponent - ), + cv.GenerateID(CONF_SPI_ID): cv.use_id(TYPE_CLASS[mode]), cv.Optional(CONF_DATA_RATE, default=default_data_rate): SPI_DATA_RATE_SCHEMA, cv.Optional(CONF_SPI_MODE, default=default_mode): cv.enum( SPI_MODE_OPTIONS, upper=True diff --git a/esphome/components/spi/spi.h b/esphome/components/spi/spi.h index 64463747a2..378d95e7b9 100644 --- a/esphome/components/spi/spi.h +++ b/esphome/components/spi/spi.h @@ -369,6 +369,7 @@ class SPIComponent : public Component { }; using QuadSPIComponent = SPIComponent; +using OctalSPIComponent = SPIComponent; /** * Base class for SPIDevice, un-templated. */ diff --git a/esphome/components/spi/spi_esp_idf.cpp b/esphome/components/spi/spi_esp_idf.cpp index 55680f72d3..a78da2cd9a 100644 --- a/esphome/components/spi/spi_esp_idf.cpp +++ b/esphome/components/spi/spi_esp_idf.cpp @@ -211,11 +211,19 @@ class SPIBusHw : public SPIBus { buscfg.data1_io_num = data_pins[1]; buscfg.data2_io_num = data_pins[2]; buscfg.data3_io_num = data_pins[3]; - buscfg.data4_io_num = -1; - buscfg.data5_io_num = -1; - buscfg.data6_io_num = -1; - buscfg.data7_io_num = -1; - buscfg.flags |= SPICOMMON_BUSFLAG_QUAD; + if (data_pins.size() == 8) { + buscfg.data4_io_num = data_pins[4]; + buscfg.data5_io_num = data_pins[5]; + buscfg.data6_io_num = data_pins[6]; + buscfg.data7_io_num = data_pins[7]; + buscfg.flags |= SPICOMMON_BUSFLAG_OCTAL; + } else { + buscfg.data4_io_num = -1; + buscfg.data5_io_num = -1; + buscfg.data6_io_num = -1; + buscfg.data7_io_num = -1; + buscfg.flags |= SPICOMMON_BUSFLAG_QUAD; + } } buscfg.max_transfer_sz = MAX_TRANSFER_SIZE; auto err = spi_bus_initialize(channel, &buscfg, SPI_DMA_CH_AUTO); diff --git a/tests/components/spi/test.esp32-s3-idf.yaml b/tests/components/spi/test.esp32-s3-idf.yaml index d394c5d7a4..061e3dd44a 100644 --- a/tests/components/spi/test.esp32-s3-idf.yaml +++ b/tests/components/spi/test.esp32-s3-idf.yaml @@ -1,22 +1,36 @@ spi: - - id: spi_id_1 - type: single - clk_pin: - number: GPIO0 - ignore_strapping_warning: true - allow_other_uses: false - mosi_pin: GPIO6 - interface: hardware - id: quad_spi type: quad interface: spi3 - clk_pin: 47 + clk_pin: + number: 47 data_pins: - - number: 40 - allow_other_uses: false - - 41 - - 42 - - 43 + - allow_other_uses: true + number: 40 + - allow_other_uses: true + number: 41 + - allow_other_uses: true + number: 42 + - allow_other_uses: true + number: 43 + - id: octal_spi + type: octal + interface: hardware + clk_pin: + number: 0 + data_pins: + - 36 + - 37 + - 38 + - 39 + - allow_other_uses: true + number: 40 + - allow_other_uses: true + number: 41 + - allow_other_uses: true + number: 42 + - allow_other_uses: true + number: 43 - id: spi_id_3 interface: any clk_pin: 8 From 399c9ba4be0ba0d0005bd9fbd363730ac5512592 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 23:38:06 +0000 Subject: [PATCH 85/88] Bump pytest from 8.2.0 to 8.3.5 (#8528) --- requirements_test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_test.txt b/requirements_test.txt index 3e5b15a718..e43df6703f 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -5,7 +5,7 @@ pyupgrade==3.19.1 # also change in .pre-commit-config.yaml when updating pre-commit # Unit tests -pytest==8.2.0 +pytest==8.3.5 pytest-cov==6.0.0 pytest-mock==3.14.0 pytest-asyncio==0.26.0 From 8c5adfb33f8dd45d9332ab6222c0c90e5f2e929d Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 9 Apr 2025 01:03:38 +0100 Subject: [PATCH 86/88] real_time_clock: Apply timezone immediately in set_timezone() (#8531) --- esphome/components/time/real_time_clock.cpp | 4 ---- esphome/components/time/real_time_clock.h | 7 ++++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/esphome/components/time/real_time_clock.cpp b/esphome/components/time/real_time_clock.cpp index 2b9a95c6bd..11e39e8f67 100644 --- a/esphome/components/time/real_time_clock.cpp +++ b/esphome/components/time/real_time_clock.cpp @@ -21,10 +21,6 @@ namespace time { static const char *const TAG = "time"; RealTimeClock::RealTimeClock() = default; -void RealTimeClock::call_setup() { - this->apply_timezone_(); - PollingComponent::call_setup(); -} void RealTimeClock::synchronize_epoch_(uint32_t epoch) { // Update UTC epoch time. struct timeval timev { diff --git a/esphome/components/time/real_time_clock.h b/esphome/components/time/real_time_clock.h index a17168ae6f..401798a568 100644 --- a/esphome/components/time/real_time_clock.h +++ b/esphome/components/time/real_time_clock.h @@ -21,7 +21,10 @@ class RealTimeClock : public PollingComponent { explicit RealTimeClock(); /// Set the time zone. - void set_timezone(const std::string &tz) { this->timezone_ = tz; } + void set_timezone(const std::string &tz) { + this->timezone_ = tz; + this->apply_timezone_(); + } /// Get the time zone currently in use. std::string get_timezone() { return this->timezone_; } @@ -35,8 +38,6 @@ class RealTimeClock : public PollingComponent { /// Get the current time as the UTC epoch since January 1st 1970. time_t timestamp_now() { return ::time(nullptr); } - void call_setup() override; - void add_on_time_sync_callback(std::function callback) { this->time_sync_callback_.add(std::move(callback)); }; From 1f7a84cc8e85b4fbcbaa11bfa4358ece59521219 Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Wed, 9 Apr 2025 10:15:39 +1000 Subject: [PATCH 87/88] [lvgl] Implement canvas widget (#8504) --- esphome/components/lvgl/__init__.py | 16 +- esphome/components/lvgl/defines.py | 2 +- esphome/components/lvgl/lv_validation.py | 26 +- esphome/components/lvgl/lvcode.py | 13 +- esphome/components/lvgl/lvgl_esphome.h | 5 + esphome/components/lvgl/schemas.py | 66 ++-- esphome/components/lvgl/styles.py | 53 ++- esphome/components/lvgl/widgets/canvas.py | 403 ++++++++++++++++++++++ esphome/components/lvgl/widgets/line.py | 6 +- tests/components/lvgl/lvgl-package.yaml | 108 ++++++ 10 files changed, 631 insertions(+), 67 deletions(-) create mode 100644 esphome/components/lvgl/widgets/canvas.py diff --git a/esphome/components/lvgl/__init__.py b/esphome/components/lvgl/__init__.py index f3cb809e7e..30fa58c380 100644 --- a/esphome/components/lvgl/__init__.py +++ b/esphome/components/lvgl/__init__.py @@ -39,14 +39,13 @@ from .lvcode import LvContext, LvglComponent, lvgl_static from .schemas import ( DISP_BG_SCHEMA, FLEX_OBJ_SCHEMA, + FULL_STYLE_SCHEMA, GRID_CELL_SCHEMA, LAYOUT_SCHEMAS, - STYLE_SCHEMA, WIDGET_TYPES, any_widget_schema, container_schema, create_modify_schema, - grid_alignments, obj_schema, ) from .styles import add_top_layer, styles_to_code, theme_to_code @@ -74,6 +73,7 @@ from .widgets.animimg import animimg_spec from .widgets.arc import arc_spec from .widgets.button import button_spec from .widgets.buttonmatrix import buttonmatrix_spec +from .widgets.canvas import canvas_spec from .widgets.checkbox import checkbox_spec from .widgets.dropdown import dropdown_spec from .widgets.img import img_spec @@ -126,6 +126,7 @@ for w_type in ( keyboard_spec, tileview_spec, qr_code_spec, + canvas_spec, ): WIDGET_TYPES[w_type.name] = w_type @@ -421,15 +422,8 @@ LVGL_SCHEMA = cv.All( "big_endian", "little_endian" ), cv.Optional(df.CONF_STYLE_DEFINITIONS): cv.ensure_list( - cv.Schema({cv.Required(CONF_ID): cv.declare_id(lv_style_t)}) - .extend(STYLE_SCHEMA) - .extend( - { - cv.Optional(df.CONF_GRID_CELL_X_ALIGN): grid_alignments, - cv.Optional(df.CONF_GRID_CELL_Y_ALIGN): grid_alignments, - cv.Optional(df.CONF_PAD_ROW): lvalid.pixels, - cv.Optional(df.CONF_PAD_COLUMN): lvalid.pixels, - } + cv.Schema({cv.Required(CONF_ID): cv.declare_id(lv_style_t)}).extend( + FULL_STYLE_SCHEMA ) ), cv.Optional(CONF_ON_IDLE): validate_automation( diff --git a/esphome/components/lvgl/defines.py b/esphome/components/lvgl/defines.py index 03599de284..7dedb55418 100644 --- a/esphome/components/lvgl/defines.py +++ b/esphome/components/lvgl/defines.py @@ -29,7 +29,7 @@ def add_define(macro, value="1"): lv_defines[macro] = value -def literal(arg): +def literal(arg) -> MockObj: if isinstance(arg, str): return MockObj(arg) return arg diff --git a/esphome/components/lvgl/lv_validation.py b/esphome/components/lvgl/lv_validation.py index f91ed893f2..a3b7cc8ed3 100644 --- a/esphome/components/lvgl/lv_validation.py +++ b/esphome/components/lvgl/lv_validation.py @@ -254,11 +254,27 @@ def pixels_or_percent_validator(value): pixels_or_percent = LValidator(pixels_or_percent_validator, uint32, retmapper=literal) -def zoom(value): +def pixels_validator(value): + if isinstance(value, str) and value.lower().endswith("px"): + value = value[:-2] + return cv.positive_int(value) + + +pixels = LValidator(pixels_validator, uint32, retmapper=literal) + + +def zoom_validator(value): value = cv.float_range(0.1, 10.0)(value) + return value + + +def zoom_retmapper(value): return int(value * 256) +zoom = LValidator(zoom_validator, uint32, retmapper=zoom_retmapper) + + def angle(value): """ Validation for an angle in degrees, converted to an integer representing 0.1deg units @@ -286,14 +302,6 @@ def size_validator(value): size = LValidator(size_validator, uint32, retmapper=literal) -def pixels_validator(value): - if isinstance(value, str) and value.lower().endswith("px"): - return cv.int_(value[:-2]) - return cv.int_(value) - - -pixels = LValidator(pixels_validator, uint32, retmapper=literal) - radius_consts = LvConstant("LV_RADIUS_", "CIRCLE") diff --git a/esphome/components/lvgl/lvcode.py b/esphome/components/lvgl/lvcode.py index 0ab5f9e18e..c8d744dfc8 100644 --- a/esphome/components/lvgl/lvcode.py +++ b/esphome/components/lvgl/lvcode.py @@ -206,11 +206,16 @@ class LocalVariable(MockObj): def __enter__(self): CodeContext.start_block() - CodeContext.append( - VariableDeclarationExpression(self.base.type, self.modifier, self.base.id) - ) if self.rhs is not None: - CodeContext.append(AssignmentExpression(None, "", self.base, self.rhs)) + CodeContext.append( + AssignmentExpression(self.base.type, self.modifier, self.base, self.rhs) + ) + else: + CodeContext.append( + VariableDeclarationExpression( + self.base.type, self.modifier, self.base.id + ) + ) return MockObj(self.base) def __exit__(self, *args): diff --git a/esphome/components/lvgl/lvgl_esphome.h b/esphome/components/lvgl/lvgl_esphome.h index be6379249f..8ffdbf1eda 100644 --- a/esphome/components/lvgl/lvgl_esphome.h +++ b/esphome/components/lvgl/lvgl_esphome.h @@ -63,6 +63,11 @@ inline void lv_disp_set_bg_image(lv_disp_t *disp, esphome::image::Image *image) inline void lv_obj_set_style_bg_img_src(lv_obj_t *obj, esphome::image::Image *image, lv_style_selector_t selector) { lv_obj_set_style_bg_img_src(obj, image->get_lv_img_dsc(), selector); } +inline void lv_canvas_draw_img(lv_obj_t *canvas, lv_coord_t x, lv_coord_t y, image::Image *image, + lv_draw_img_dsc_t *dsc) { + lv_canvas_draw_img(canvas, x, y, image->get_lv_img_dsc(), dsc); +} + #ifdef USE_LVGL_METER inline lv_meter_indicator_t *lv_meter_add_needle_img(lv_obj_t *obj, lv_meter_scale_t *scale, esphome::image::Image *src, lv_coord_t pivot_x, lv_coord_t pivot_y) { diff --git a/esphome/components/lvgl/schemas.py b/esphome/components/lvgl/schemas.py index 89c9502d27..c05dfae8c7 100644 --- a/esphome/components/lvgl/schemas.py +++ b/esphome/components/lvgl/schemas.py @@ -87,31 +87,29 @@ ENCODER_SCHEMA = cv.Schema( } ) +POINT_SCHEMA = cv.Schema( + { + cv.Required(CONF_X): cv.templatable(cv.int_), + cv.Required(CONF_Y): cv.templatable(cv.int_), + } +) -def point_shorthand(value): + +def point_schema(value): """ A shorthand for a point in the form of x,y :param value: The value to check :return: The value as a tuple of x,y """ - if isinstance(value, str): - try: - x, y = map(int, value.split(",")) - return {CONF_X: x, CONF_Y: y} - except ValueError: - pass - raise cv.Invalid("Invalid point format, should be , ") - - -POINT_SCHEMA = cv.Any( - cv.Schema( - { - cv.Required(CONF_X): cv.templatable(cv.int_), - cv.Required(CONF_Y): cv.templatable(cv.int_), - } - ), - point_shorthand, -) + if isinstance(value, dict): + return POINT_SCHEMA(value) + try: + x, y = map(int, value.split(",")) + return {CONF_X: x, CONF_Y: y} + except ValueError: + pass + # not raising this in the catch block because pylint doesn't like it + raise cv.Invalid("Invalid point format, should be , ") # All LVGL styles and their validators @@ -132,6 +130,7 @@ STYLE_PROPS = { "bg_image_recolor": lvalid.lv_color, "bg_image_recolor_opa": lvalid.opacity, "bg_image_src": lvalid.lv_image, + "bg_image_tiled": lvalid.lv_bool, "bg_main_stop": lvalid.stop_value, "bg_opa": lvalid.opacity, "border_color": lvalid.lv_color, @@ -146,9 +145,9 @@ STYLE_PROPS = { "height": lvalid.size, "image_recolor": lvalid.lv_color, "image_recolor_opa": lvalid.opacity, - "line_width": cv.positive_int, - "line_dash_width": cv.positive_int, - "line_dash_gap": cv.positive_int, + "line_width": lvalid.lv_positive_int, + "line_dash_width": lvalid.lv_positive_int, + "line_dash_gap": lvalid.lv_positive_int, "line_rounded": lvalid.lv_bool, "line_color": lvalid.lv_color, "opa": lvalid.opacity, @@ -176,8 +175,8 @@ STYLE_PROPS = { "LV_TEXT_DECOR_", "NONE", "UNDERLINE", "STRIKETHROUGH" ).several_of, "text_font": lv_font, - "text_letter_space": cv.positive_int, - "text_line_space": cv.positive_int, + "text_letter_space": lvalid.lv_positive_int, + "text_line_space": lvalid.lv_positive_int, "text_opa": lvalid.opacity, "transform_angle": lvalid.lv_angle, "transform_height": lvalid.pixels_or_percent, @@ -201,10 +200,15 @@ STYLE_REMAP = { "bg_image_recolor": "bg_img_recolor", "bg_image_recolor_opa": "bg_img_recolor_opa", "bg_image_src": "bg_img_src", + "bg_image_tiled": "bg_img_tiled", "image_recolor": "img_recolor", "image_recolor_opa": "img_recolor_opa", } +cell_alignments = df.LV_CELL_ALIGNMENTS.one_of +grid_alignments = df.LV_GRID_ALIGNMENTS.one_of +flex_alignments = df.LV_FLEX_ALIGNMENTS.one_of + # Complete object style schema STYLE_SCHEMA = cv.Schema({cv.Optional(k): v for k, v in STYLE_PROPS.items()}).extend( { @@ -215,6 +219,16 @@ STYLE_SCHEMA = cv.Schema({cv.Optional(k): v for k, v in STYLE_PROPS.items()}).ex } ) +# Also allow widget specific properties for use in style definitions +FULL_STYLE_SCHEMA = STYLE_SCHEMA.extend( + { + cv.Optional(df.CONF_GRID_CELL_X_ALIGN): grid_alignments, + cv.Optional(df.CONF_GRID_CELL_Y_ALIGN): grid_alignments, + cv.Optional(df.CONF_PAD_ROW): lvalid.pixels, + cv.Optional(df.CONF_PAD_COLUMN): lvalid.pixels, + } +) + # Object states. Top level properties apply to MAIN STATE_SCHEMA = cv.Schema( {cv.Optional(state): STYLE_SCHEMA for state in df.STATES} @@ -346,10 +360,6 @@ grid_spec = cv.Any( lvalid.size, df.LvConstant("LV_GRID_", "CONTENT").one_of, grid_free_space ) -cell_alignments = df.LV_CELL_ALIGNMENTS.one_of -grid_alignments = df.LV_GRID_ALIGNMENTS.one_of -flex_alignments = df.LV_FLEX_ALIGNMENTS.one_of - LAYOUT_SCHEMA = { cv.Optional(df.CONF_LAYOUT): cv.typed_schema( { diff --git a/esphome/components/lvgl/styles.py b/esphome/components/lvgl/styles.py index 6332e0976f..b59ff513e2 100644 --- a/esphome/components/lvgl/styles.py +++ b/esphome/components/lvgl/styles.py @@ -1,4 +1,6 @@ +from esphome import automation import esphome.codegen as cg +import esphome.config_validation as cv from esphome.const import CONF_ID from esphome.core import ID from esphome.cpp_generator import MockObj @@ -12,25 +14,54 @@ from .defines import ( ) from .helpers import add_lv_use from .lvcode import LambdaContext, LocalVariable, lv, lv_assign, lv_variable -from .schemas import ALL_STYLES, STYLE_REMAP -from .types import lv_lambda_t, lv_obj_t, lv_obj_t_ptr -from .widgets import Widget, add_widgets, set_obj_properties, theme_widget_map +from .schemas import ALL_STYLES, FULL_STYLE_SCHEMA, STYLE_REMAP +from .types import ObjUpdateAction, lv_lambda_t, lv_obj_t, lv_obj_t_ptr, lv_style_t +from .widgets import ( + Widget, + add_widgets, + set_obj_properties, + theme_widget_map, + wait_for_widgets, +) from .widgets.obj import obj_spec +async def style_set(svar, style): + for prop, validator in ALL_STYLES.items(): + if (value := style.get(prop)) is not None: + if isinstance(validator, LValidator): + value = await validator.process(value) + if isinstance(value, list): + value = "|".join(value) + remapped_prop = STYLE_REMAP.get(prop, prop) + lv.call(f"style_set_{remapped_prop}", svar, literal(value)) + + async def styles_to_code(config): """Convert styles to C__ code.""" for style in config.get(CONF_STYLE_DEFINITIONS, ()): svar = cg.new_Pvariable(style[CONF_ID]) lv.style_init(svar) - for prop, validator in ALL_STYLES.items(): - if (value := style.get(prop)) is not None: - if isinstance(validator, LValidator): - value = await validator.process(value) - if isinstance(value, list): - value = "|".join(value) - remapped_prop = STYLE_REMAP.get(prop, prop) - lv.call(f"style_set_{remapped_prop}", svar, literal(value)) + await style_set(svar, style) + + +@automation.register_action( + "lvgl.style.update", + ObjUpdateAction, + FULL_STYLE_SCHEMA.extend( + { + cv.Required(CONF_ID): cv.use_id(lv_style_t), + } + ), +) +async def style_update_to_code(config, action_id, template_arg, args): + await wait_for_widgets() + style = await cg.get_variable(config[CONF_ID]) + async with LambdaContext(parameters=args, where=action_id) as context: + await style_set(style, config) + + var = cg.new_Pvariable(action_id, template_arg, await context.get_lambda()) + return var async def theme_to_code(config): diff --git a/esphome/components/lvgl/widgets/canvas.py b/esphome/components/lvgl/widgets/canvas.py new file mode 100644 index 0000000000..bc26558624 --- /dev/null +++ b/esphome/components/lvgl/widgets/canvas.py @@ -0,0 +1,403 @@ +from esphome import automation, codegen as cg, config_validation as cv +from esphome.components.display_menu_base import CONF_LABEL +from esphome.const import CONF_COLOR, CONF_HEIGHT, CONF_ID, CONF_TEXT, CONF_WIDTH +from esphome.cpp_generator import Literal, MockObj + +from ..automation import action_to_code +from ..defines import ( + CONF_END_ANGLE, + CONF_MAIN, + CONF_OPA, + CONF_PIVOT_X, + CONF_PIVOT_Y, + CONF_POINTS, + CONF_SRC, + CONF_START_ANGLE, + CONF_X, + CONF_Y, + literal, +) +from ..lv_validation import ( + lv_angle, + lv_bool, + lv_color, + lv_image, + lv_text, + opacity, + pixels, + size, +) +from ..lvcode import LocalVariable, lv, lv_assign +from ..schemas import STYLE_PROPS, STYLE_REMAP, TEXT_SCHEMA, point_schema +from ..types import LvType, ObjUpdateAction, WidgetType +from . import Widget, get_widgets +from .line import lv_point_t, process_coord + +CONF_CANVAS = "canvas" +CONF_BUFFER_ID = "buffer_id" +CONF_MAX_WIDTH = "max_width" +CONF_TRANSPARENT = "transparent" +CONF_RADIUS = "radius" + +lv_canvas_t = LvType("lv_canvas_t") + + +class CanvasType(WidgetType): + def __init__(self): + super().__init__( + CONF_CANVAS, + lv_canvas_t, + (CONF_MAIN,), + cv.Schema( + { + cv.Required(CONF_WIDTH): size, + cv.Required(CONF_HEIGHT): size, + cv.Optional(CONF_TRANSPARENT, default=False): cv.boolean, + } + ), + ) + + def get_uses(self): + return "img", CONF_LABEL + + async def to_code(self, w: Widget, config): + width = config[CONF_WIDTH] + height = config[CONF_HEIGHT] + use_alpha = "_ALPHA" if config[CONF_TRANSPARENT] else "" + lv.canvas_set_buffer( + w.obj, + lv.custom_mem_alloc( + literal(f"LV_CANVAS_BUF_SIZE_TRUE_COLOR{use_alpha}({width}, {height})") + ), + width, + height, + literal(f"LV_IMG_CF_TRUE_COLOR{use_alpha}"), + ) + + +canvas_spec = CanvasType() + + +@automation.register_action( + "lvgl.canvas.fill", + ObjUpdateAction, + cv.Schema( + { + cv.GenerateID(CONF_ID): cv.use_id(lv_canvas_t), + cv.Required(CONF_COLOR): lv_color, + cv.Optional(CONF_OPA, default="COVER"): opacity, + }, + ), +) +async def canvas_fill(config, action_id, template_arg, args): + widget = await get_widgets(config) + color = await lv_color.process(config[CONF_COLOR]) + opa = await opacity.process(config[CONF_OPA]) + + async def do_fill(w: Widget): + lv.canvas_fill_bg(w.obj, color, opa) + + return await action_to_code(widget, do_fill, action_id, template_arg, args) + + +@automation.register_action( + "lvgl.canvas.set_pixels", + ObjUpdateAction, + cv.Schema( + { + cv.GenerateID(CONF_ID): cv.use_id(lv_canvas_t), + cv.Required(CONF_COLOR): lv_color, + cv.Optional(CONF_OPA): opacity, + cv.Required(CONF_POINTS): cv.ensure_list(point_schema), + }, + ), +) +async def canvas_set_pixel(config, action_id, template_arg, args): + widget = await get_widgets(config) + color = await lv_color.process(config[CONF_COLOR]) + opa = await opacity.process(config.get(CONF_OPA)) + points = [ + ( + await pixels.process(p[CONF_X]), + await pixels.process(p[CONF_Y]), + ) + for p in config[CONF_POINTS] + ] + + async def do_set_pixels(w: Widget): + if isinstance(color, MockObj): + for point in points: + x, y = point + lv.canvas_set_px_color(w.obj, x, y, color) + else: + with LocalVariable("color", "lv_color_t", color, modifier="") as color_var: + for point in points: + x, y = point + lv.canvas_set_px_color(w.obj, x, y, color_var) + if opa: + if isinstance(opa, Literal): + for point in points: + x, y = point + lv.canvas_set_px_opa(w.obj, x, y, opa) + else: + with LocalVariable("opa", "lv_opa_t", opa, modifier="") as opa_var: + for point in points: + x, y = point + lv.canvas_set_px_opa(w.obj, x, y, opa_var) + + return await action_to_code(widget, do_set_pixels, action_id, template_arg, args) + + +DRAW_SCHEMA = cv.Schema( + { + cv.GenerateID(CONF_ID): cv.use_id(lv_canvas_t), + cv.Required(CONF_X): pixels, + cv.Required(CONF_Y): pixels, + } +) +DRAW_OPA_SCHEMA = DRAW_SCHEMA.extend( + { + cv.Optional(CONF_OPA): opacity, + } +) + + +async def draw_to_code(config, dsc_type, props, do_draw, action_id, template_arg, args): + widget = await get_widgets(config) + x = await pixels.process(config.get(CONF_X)) + y = await pixels.process(config.get(CONF_Y)) + + async def action_func(w: Widget): + with LocalVariable("dsc", f"lv_draw_{dsc_type}_dsc_t", modifier="") as dsc: + dsc_addr = literal(f"&{dsc}") + lv.call(f"draw_{dsc_type}_dsc_init", dsc_addr) + if CONF_OPA in config: + opa = await opacity.process(config[CONF_OPA]) + lv_assign(dsc.opa, opa) + for prop, validator in props.items(): + if prop in config: + value = await validator.process(config[prop]) + mapped_prop = STYLE_REMAP.get(prop, prop) + lv_assign(getattr(dsc, mapped_prop), value) + await do_draw(w, x, y, dsc_addr) + + return await action_to_code(widget, action_func, action_id, template_arg, args) + + +RECT_PROPS = { + p: STYLE_PROPS[p] + for p in ( + "radius", + "bg_opa", + "bg_color", + "bg_grad", + "border_color", + "border_width", + "border_opa", + "outline_color", + "outline_width", + "outline_pad", + "outline_opa", + "shadow_color", + "shadow_width", + "shadow_ofs_x", + "shadow_ofs_y", + "shadow_spread", + "shadow_opa", + ) +} + + +@automation.register_action( + "lvgl.canvas.draw_rectangle", + ObjUpdateAction, + DRAW_SCHEMA.extend( + { + cv.Required(CONF_WIDTH): cv.templatable(cv.int_), + cv.Required(CONF_HEIGHT): cv.templatable(cv.int_), + }, + ).extend({cv.Optional(prop): STYLE_PROPS[prop] for prop in RECT_PROPS}), +) +async def canvas_draw_rect(config, action_id, template_arg, args): + width = await pixels.process(config[CONF_WIDTH]) + height = await pixels.process(config[CONF_HEIGHT]) + + async def do_draw_rect(w: Widget, x, y, dsc_addr): + lv.canvas_draw_rect(w.obj, x, y, width, height, dsc_addr) + + return await draw_to_code( + config, "rect", RECT_PROPS, do_draw_rect, action_id, template_arg, args + ) + + +TEXT_PROPS = { + p: STYLE_PROPS[f"text_{p}"] + for p in ( + "font", + "color", + # "sel_color", + # "sel_bg_color", + "line_space", + "letter_space", + "align", + "decor", + ) +} + + +@automation.register_action( + "lvgl.canvas.draw_text", + ObjUpdateAction, + TEXT_SCHEMA.extend(DRAW_OPA_SCHEMA) + .extend( + { + cv.Required(CONF_MAX_WIDTH): cv.templatable(cv.int_), + }, + ) + .extend({cv.Optional(prop): STYLE_PROPS[f"text_{prop}"] for prop in TEXT_PROPS}), +) +async def canvas_draw_text(config, action_id, template_arg, args): + text = await lv_text.process(config[CONF_TEXT]) + max_width = await pixels.process(config[CONF_MAX_WIDTH]) + + async def do_draw_text(w: Widget, x, y, dsc_addr): + lv.canvas_draw_text(w.obj, x, y, max_width, dsc_addr, text) + + return await draw_to_code( + config, "label", TEXT_PROPS, do_draw_text, action_id, template_arg, args + ) + + +IMG_PROPS = { + "angle": STYLE_PROPS["transform_angle"], + "zoom": STYLE_PROPS["transform_zoom"], + "recolor": STYLE_PROPS["image_recolor"], + "recolor_opa": STYLE_PROPS["image_recolor_opa"], + "opa": STYLE_PROPS["opa"], +} + + +@automation.register_action( + "lvgl.canvas.draw_image", + ObjUpdateAction, + DRAW_OPA_SCHEMA.extend( + { + cv.Required(CONF_SRC): lv_image, + cv.Optional(CONF_PIVOT_X, default=0): pixels, + cv.Optional(CONF_PIVOT_Y, default=0): pixels, + }, + ).extend({cv.Optional(prop): validator for prop, validator in IMG_PROPS.items()}), +) +async def canvas_draw_image(config, action_id, template_arg, args): + src = await lv_image.process(config[CONF_SRC]) + pivot_x = await pixels.process(config[CONF_PIVOT_X]) + pivot_y = await pixels.process(config[CONF_PIVOT_Y]) + + async def do_draw_image(w: Widget, x, y, dsc_addr): + dsc = MockObj(f"(*{dsc_addr})") + if pivot_x or pivot_y: + # pylint :disable=no-member + lv_assign(dsc.pivot, literal(f"{{{pivot_x}, {pivot_y}}}")) + lv.canvas_draw_img(w.obj, x, y, src, dsc_addr) + + return await draw_to_code( + config, "img", IMG_PROPS, do_draw_image, action_id, template_arg, args + ) + + +LINE_PROPS = { + "width": STYLE_PROPS["line_width"], + "color": STYLE_PROPS["line_color"], + "dash-width": STYLE_PROPS["line_dash_width"], + "dash-gap": STYLE_PROPS["line_dash_gap"], + "round_start": lv_bool, + "round_end": lv_bool, +} + + +@automation.register_action( + "lvgl.canvas.draw_line", + ObjUpdateAction, + cv.Schema( + { + cv.GenerateID(CONF_ID): cv.use_id(lv_canvas_t), + cv.Optional(CONF_OPA): opacity, + cv.Required(CONF_POINTS): cv.ensure_list(point_schema), + }, + ).extend({cv.Optional(prop): validator for prop, validator in LINE_PROPS.items()}), +) +async def canvas_draw_line(config, action_id, template_arg, args): + points = [ + [await process_coord(p[CONF_X]), await process_coord(p[CONF_Y])] + for p in config[CONF_POINTS] + ] + + async def do_draw_line(w: Widget, x, y, dsc_addr): + with LocalVariable( + "points", cg.std_vector.template(lv_point_t), points, modifier="" + ) as points_var: + lv.canvas_draw_line(w.obj, points_var.data(), points_var.size(), dsc_addr) + + return await draw_to_code( + config, "line", LINE_PROPS, do_draw_line, action_id, template_arg, args + ) + + +@automation.register_action( + "lvgl.canvas.draw_polygon", + ObjUpdateAction, + cv.Schema( + { + cv.GenerateID(CONF_ID): cv.use_id(lv_canvas_t), + cv.Required(CONF_POINTS): cv.ensure_list(point_schema), + }, + ).extend({cv.Optional(prop): STYLE_PROPS[prop] for prop in RECT_PROPS}), +) +async def canvas_draw_polygon(config, action_id, template_arg, args): + points = [ + [await process_coord(p[CONF_X]), await process_coord(p[CONF_Y])] + for p in config[CONF_POINTS] + ] + + async def do_draw_polygon(w: Widget, x, y, dsc_addr): + with LocalVariable( + "points", cg.std_vector.template(lv_point_t), points, modifier="" + ) as points_var: + lv.canvas_draw_polygon( + w.obj, points_var.data(), points_var.size(), dsc_addr + ) + + return await draw_to_code( + config, "rect", RECT_PROPS, do_draw_polygon, action_id, template_arg, args + ) + + +ARC_PROPS = { + "width": STYLE_PROPS["arc_width"], + "color": STYLE_PROPS["arc_color"], + "rounded": STYLE_PROPS["arc_rounded"], +} + + +@automation.register_action( + "lvgl.canvas.draw_arc", + ObjUpdateAction, + DRAW_OPA_SCHEMA.extend( + { + cv.Required(CONF_RADIUS): pixels, + cv.Required(CONF_START_ANGLE): lv_angle, + cv.Required(CONF_END_ANGLE): lv_angle, + } + ).extend({cv.Optional(prop): validator for prop, validator in ARC_PROPS.items()}), +) +async def canvas_draw_arc(config, action_id, template_arg, args): + radius = await size.process(config[CONF_RADIUS]) + start_angle = await lv_angle.process(config[CONF_START_ANGLE]) + end_angle = await lv_angle.process(config[CONF_END_ANGLE]) + + async def do_draw_arc(w: Widget, x, y, dsc_addr): + lv.canvas_draw_arc(w.obj, x, y, radius, start_angle, end_angle, dsc_addr) + + return await draw_to_code( + config, "arc", ARC_PROPS, do_draw_arc, action_id, template_arg, args + ) diff --git a/esphome/components/lvgl/widgets/line.py b/esphome/components/lvgl/widgets/line.py index 220e3a3b57..94fdfe2346 100644 --- a/esphome/components/lvgl/widgets/line.py +++ b/esphome/components/lvgl/widgets/line.py @@ -4,7 +4,7 @@ from esphome.core import Lambda from ..defines import CONF_MAIN, CONF_X, CONF_Y, call_lambda from ..lvcode import lv_add -from ..schemas import POINT_SCHEMA +from ..schemas import point_schema from ..types import LvCompound, LvType from . import Widget, WidgetType @@ -16,14 +16,14 @@ lv_point_t = cg.global_ns.struct("lv_point_t") LINE_SCHEMA = { - cv.Required(CONF_POINTS): cv.ensure_list(POINT_SCHEMA), + cv.Required(CONF_POINTS): cv.ensure_list(point_schema), } async def process_coord(coord): if isinstance(coord, Lambda): coord = call_lambda( - await cg.process_lambda(coord, (), return_type="lv_coord_t") + await cg.process_lambda(coord, [], return_type="lv_coord_t") ) if not coord.endswith("()"): coord = f"static_cast({coord})" diff --git a/tests/components/lvgl/lvgl-package.yaml b/tests/components/lvgl/lvgl-package.yaml index 3048ad1951..78c261c01d 100644 --- a/tests/components/lvgl/lvgl-package.yaml +++ b/tests/components/lvgl/lvgl-package.yaml @@ -130,6 +130,10 @@ lvgl: on_click: then: - lvgl.widget.hide: message_box + - lvgl.style.update: + id: style_test + bg_color: blue + bg_opa: !lambda return 0.5; - id: simple_msgbox title: Simple @@ -510,6 +514,110 @@ lvgl: - id: page2 widgets: + - canvas: + id: canvas_id + align: center + width: 400 + height: 400 + transparent: true + on_boot: + - lvgl.canvas.fill: + color: blue + opa: 50% + - lvgl.canvas.draw_rectangle: + x: 20 + y: 20 + width: 150 + height: 150 + bg_color: green + bg_opa: cover + radius: 5 + border_color: black + border_width: 4 + border_opa: 80% + shadow_color: black + shadow_width: 10 + shadow_ofs_x: 5 + shadow_ofs_y: 5 + shadow_spread: 4 + shadow_opa: cover + outline_color: red + outline_width: 4 + outline_pad: 4 + outline_opa: cover + - lvgl.canvas.set_pixels: + color: red + points: + - x: 100 + y: 100 + - 100,101 + - 100,102 + - 100,103 + - 100,104 + - lvgl.canvas.set_pixels: + opa: 50% + color: !lambda return lv_color_make(255,255,255); + points: + - x: !lambda return random_uint32() % 200; + y: !lambda return random_uint32() % 200; + - 121,120 + - 122,120 + - 123,120 + - 124,120 + - 125,120 + + - lvgl.canvas.draw_text: + x: 100 + y: 100 + font: montserrat_18 + color: white + opa: cover + decor: underline + letter_space: 1 + line_space: 2 + text: Canvas Text + align: center + max_width: 150 + - lvgl.canvas.draw_image: + src: cat_image + x: 100 + y: 100 + angle: 90 + zoom: 2.0 + pivot_x: 25 + pivot_y: 25 + - lvgl.canvas.draw_line: + color: blue + width: 4 + round_end: true + round_start: false + points: + - 50,50 + - 50, 200 + - 200, 200 + - 200, 50 + - 50,50 + - lvgl.canvas.draw_polygon: + bg_color: teal + border_color: white + border_width: 2 + border_opa: cover + points: + - 150,150 + - 150, 300 + - 300, 300 + - 350, 250 + - lvgl.canvas.draw_arc: + x: 200 + y: 200 + radius: 40 + opa: 50% + color: purple + width: 6 + rounded: true + start_angle: 10 + end_angle: !lambda return 900; + - qrcode: id: lv_qr align: left_mid From 4a1cbfc533f6cbdedefb2ff41d351cbcc7a5267e Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Wed, 9 Apr 2025 14:19:05 +1200 Subject: [PATCH 88/88] Bump version to 2025.4.0b1 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index f6f9b7df80..1d7f501c9e 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2025.4.0-dev" +__version__ = "2025.4.0b1" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" VALID_SUBSTITUTIONS_CHARACTERS = (