From 22fec4329f30877c69b1e43c984f4692f5b97a2f Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Mon, 20 Oct 2025 16:02:03 +1300 Subject: [PATCH] [fan] Clean up deprecated code from 2022.2 (#11392) --- esphome/components/fan/__init__.py | 1 - esphome/components/fan/automation.h | 4 ++-- esphome/components/fan/fan_state.cpp | 16 ------------- esphome/components/fan/fan_state.h | 34 ---------------------------- esphome/components/mqtt/mqtt_fan.h | 2 +- esphome/core/application.h | 2 +- esphome/core/controller.h | 2 +- 7 files changed, 5 insertions(+), 56 deletions(-) delete mode 100644 esphome/components/fan/fan_state.cpp delete mode 100644 esphome/components/fan/fan_state.h diff --git a/esphome/components/fan/__init__.py b/esphome/components/fan/__init__.py index da8bf850c7..245c9f04b4 100644 --- a/esphome/components/fan/__init__.py +++ b/esphome/components/fan/__init__.py @@ -38,7 +38,6 @@ IS_PLATFORM_COMPONENT = True fan_ns = cg.esphome_ns.namespace("fan") Fan = fan_ns.class_("Fan", cg.EntityBase) -FanState = fan_ns.class_("Fan", Fan, cg.Component) FanDirection = fan_ns.enum("FanDirection", is_class=True) FAN_DIRECTION_ENUM = { diff --git a/esphome/components/fan/automation.h b/esphome/components/fan/automation.h index d480a2ef44..90661c307c 100644 --- a/esphome/components/fan/automation.h +++ b/esphome/components/fan/automation.h @@ -1,8 +1,8 @@ #pragma once -#include "esphome/core/component.h" #include "esphome/core/automation.h" -#include "fan_state.h" +#include "esphome/core/component.h" +#include "fan.h" namespace esphome { namespace fan { diff --git a/esphome/components/fan/fan_state.cpp b/esphome/components/fan/fan_state.cpp deleted file mode 100644 index 7c1658fb2e..0000000000 --- a/esphome/components/fan/fan_state.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "fan_state.h" - -namespace esphome { -namespace fan { - -static const char *const TAG = "fan"; - -void FanState::setup() { - auto restore = this->restore_state_(); - if (restore) - restore->to_call(*this).perform(); -} -float FanState::get_setup_priority() const { return setup_priority::DATA - 1.0f; } - -} // namespace fan -} // namespace esphome diff --git a/esphome/components/fan/fan_state.h b/esphome/components/fan/fan_state.h deleted file mode 100644 index 5926e700b0..0000000000 --- a/esphome/components/fan/fan_state.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include "esphome/core/component.h" -#include "fan.h" - -namespace esphome { -namespace fan { - -enum ESPDEPRECATED("LegacyFanDirection members are deprecated, use FanDirection instead.", - "2022.2") LegacyFanDirection { - FAN_DIRECTION_FORWARD = 0, - FAN_DIRECTION_REVERSE = 1 -}; - -class ESPDEPRECATED("FanState is deprecated, use Fan instead.", "2022.2") FanState : public Fan, public Component { - public: - FanState() = default; - - /// Get the traits of this fan. - FanTraits get_traits() override { return this->traits_; } - /// Set the traits of this fan (i.e. what features it supports). - void set_traits(const FanTraits &traits) { this->traits_ = traits; } - - void setup() override; - float get_setup_priority() const override; - - protected: - void control(const FanCall &call) override { this->publish_state(); } - - FanTraits traits_{}; -}; - -} // namespace fan -} // namespace esphome diff --git a/esphome/components/mqtt/mqtt_fan.h b/esphome/components/mqtt/mqtt_fan.h index fdcec0782d..78641d224f 100644 --- a/esphome/components/mqtt/mqtt_fan.h +++ b/esphome/components/mqtt/mqtt_fan.h @@ -5,7 +5,7 @@ #ifdef USE_MQTT #ifdef USE_FAN -#include "esphome/components/fan/fan_state.h" +#include "esphome/components/fan/fan.h" #include "mqtt_component.h" namespace esphome { diff --git a/esphome/core/application.h b/esphome/core/application.h index 6e7f1b49f2..29a734f000 100644 --- a/esphome/core/application.h +++ b/esphome/core/application.h @@ -39,7 +39,7 @@ #include "esphome/components/text_sensor/text_sensor.h" #endif #ifdef USE_FAN -#include "esphome/components/fan/fan_state.h" +#include "esphome/components/fan/fan.h" #endif #ifdef USE_CLIMATE #include "esphome/components/climate/climate.h" diff --git a/esphome/core/controller.h b/esphome/core/controller.h index 1a5b9ea6b4..b475e326ee 100644 --- a/esphome/core/controller.h +++ b/esphome/core/controller.h @@ -5,7 +5,7 @@ #include "esphome/components/binary_sensor/binary_sensor.h" #endif #ifdef USE_FAN -#include "esphome/components/fan/fan_state.h" +#include "esphome/components/fan/fan.h" #endif #ifdef USE_LIGHT #include "esphome/components/light/light_state.h"