From 0b5a1748f7d143fdce636aa5794db04028d457b9 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 26 Sep 2026 01:33:25 +0100 Subject: [PATCH] [tinyusb] Use register_apply_condition for tinyusb.is_mounted (#19702) --- esphome/components/tinyusb/__init__.py | 5 ++--- esphome/components/tinyusb/tinyusb_component.h | 10 ---------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/esphome/components/tinyusb/__init__.py b/esphome/components/tinyusb/__init__.py index 422a994238..1b819088ca 100644 --- a/esphome/components/tinyusb/__init__.py +++ b/esphome/components/tinyusb/__init__.py @@ -36,7 +36,6 @@ _USB_CLASS_COMPONENTS = ("usb_cdc_acm",) tinyusb_ns = cg.esphome_ns.namespace("tinyusb") TinyUSB = tinyusb_ns.class_("TinyUSB", cg.Component) -IsMountedCondition = tinyusb_ns.class_("IsMountedCondition", automation.Condition) _CALLBACK_AUTOMATIONS = ( automation.CallbackAutomation( @@ -134,8 +133,8 @@ async def to_code(config: ConfigType) -> None: add_idf_sdkconfig_option("CONFIG_TINYUSB_DESC_BCD_DEVICE", 0x0100) -automation.register_simple_condition( +automation.register_apply_condition( "tinyusb.is_mounted", - IsMountedCondition, cv.Schema({cv.GenerateID(): cv.use_id(TinyUSB)}), + "is_mounted()", ) diff --git a/esphome/components/tinyusb/tinyusb_component.h b/esphome/components/tinyusb/tinyusb_component.h index f7f574ec6d..030356bc03 100644 --- a/esphome/components/tinyusb/tinyusb_component.h +++ b/esphome/components/tinyusb/tinyusb_component.h @@ -1,7 +1,6 @@ #pragma once #if defined(USE_ESP32_VARIANT_ESP32P4) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || \ defined(USE_ESP32_VARIANT_ESP32S31) || defined(USE_ESP32_VARIANT_ESP32H4) -#include "esphome/core/automation.h" #include "esphome/core/component.h" #include "esphome/core/helpers.h" @@ -87,15 +86,6 @@ class TinyUSB final : public Component { }; }; -template class IsMountedCondition final : public Condition { - public: - explicit IsMountedCondition(TinyUSB *parent) : parent_(parent) {} - bool check(const Ts &...) override { return this->parent_->is_mounted(); } - - protected: - TinyUSB *parent_; -}; - } // namespace esphome::tinyusb #endif // USE_ESP32_VARIANT_ESP32P4 || USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3 || // USE_ESP32_VARIANT_ESP32S31 || USE_ESP32_VARIANT_ESP32H4