Mark user-configurable classes as final (part 19/21)

Add the C++ `final` specifier to leaf, user-configurable component classes and
automation action/trigger/condition primitives so that classes meant to be
terminal cannot be subclassed by external components. Only classes never used as
a base anywhere in the tree are marked. Part 19 of 21, split alphabetically by
component (uart .. wl_134).
This commit is contained in:
Jesse Hills
2026-06-15 13:22:46 +12:00
parent a25ac28ae5
commit ec6cc105f4
47 changed files with 94 additions and 93 deletions

View File

@@ -7,7 +7,7 @@
namespace esphome::uart { namespace esphome::uart {
template<typename... Ts> class UARTWriteAction : public Action<Ts...>, public Parented<UARTComponent> { template<typename... Ts> class UARTWriteAction final : public Action<Ts...>, public Parented<UARTComponent> {
public: public:
void set_data_template(std::vector<uint8_t> (*func)(Ts...)) { void set_data_template(std::vector<uint8_t> (*func)(Ts...)) {
// Stateless lambdas (generated by ESPHome) implicitly convert to function pointers // Stateless lambdas (generated by ESPHome) implicitly convert to function pointers

View File

@@ -8,7 +8,7 @@
namespace esphome::uart { namespace esphome::uart {
class UARTButton : public button::Button, public UARTDevice, public Component { class UARTButton final : public button::Button, public UARTDevice, public Component {
public: public:
void set_data(std::vector<uint8_t> &&data) { this->data_ = std::move(data); } void set_data(std::vector<uint8_t> &&data) { this->data_ = std::move(data); }
void set_data(std::initializer_list<uint8_t> data) { this->data_ = std::vector<uint8_t>(data); } void set_data(std::initializer_list<uint8_t> data) { this->data_ = std::vector<uint8_t>(data); }

View File

@@ -7,7 +7,7 @@
namespace esphome::uart { namespace esphome::uart {
class UARTEvent : public event::Event, public UARTDevice, public Component { class UARTEvent final : public event::Event, public UARTDevice, public Component {
public: public:
void setup() override; void setup() override;
void loop() override; void loop() override;

View File

@@ -20,7 +20,7 @@ static const uint16_t MAX_PACKET_SIZE = 508;
static const uint8_t FLAG_BYTE = 0x7E; static const uint8_t FLAG_BYTE = 0x7E;
static const uint8_t CONTROL_BYTE = 0x7D; static const uint8_t CONTROL_BYTE = 0x7D;
class UARTTransport : public packet_transport::PacketTransport, public UARTDevice { class UARTTransport final : public packet_transport::PacketTransport, public UARTDevice {
public: public:
void loop() override; void loop() override;
float get_setup_priority() const override { return setup_priority::PROCESSOR; } float get_setup_priority() const override { return setup_priority::PROCESSOR; }

View File

@@ -9,7 +9,7 @@
namespace esphome::uart { namespace esphome::uart {
class UARTSwitch : public switch_::Switch, public UARTDevice, public Component { class UARTSwitch final : public switch_::Switch, public UARTDevice, public Component {
public: public:
void loop() override; void loop() override;

View File

@@ -46,7 +46,7 @@ class ESP8266SoftwareSerial {
ISRInternalGPIOPin rx_pin_; ISRInternalGPIOPin rx_pin_;
}; };
class ESP8266UartComponent : public UARTComponent, public Component { class ESP8266UartComponent final : public UARTComponent, public Component {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -16,7 +16,7 @@ namespace esphome::uart {
/// Thread safety: All public methods must only be called from the main loop. /// Thread safety: All public methods must only be called from the main loop.
/// The ESP-IDF UART driver API does not guarantee thread safety, and ESPHome's /// The ESP-IDF UART driver API does not guarantee thread safety, and ESPHome's
/// peek byte state (has_peek_/peek_byte_) is not synchronized. /// peek byte state (has_peek_/peek_byte_) is not synchronized.
class IDFUARTComponent : public UARTComponent, public Component { class IDFUARTComponent final : public UARTComponent, public Component {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -8,7 +8,7 @@
namespace esphome::uart { namespace esphome::uart {
class HostUartComponent : public UARTComponent, public Component { class HostUartComponent final : public UARTComponent, public Component {
public: public:
virtual ~HostUartComponent(); virtual ~HostUartComponent();
void setup() override; void setup() override;

View File

@@ -10,7 +10,7 @@
namespace esphome::uart { namespace esphome::uart {
class LibreTinyUARTComponent : public UARTComponent, public Component { class LibreTinyUARTComponent final : public UARTComponent, public Component {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -13,7 +13,7 @@
namespace esphome::uart { namespace esphome::uart {
class RP2040UartComponent : public UARTComponent, public Component { class RP2040UartComponent final : public UARTComponent, public Component {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -18,7 +18,7 @@ namespace esphome::uart {
/// 'appropriate time' means exactly, is determined by a number of /// 'appropriate time' means exactly, is determined by a number of
/// configurable constraints. E.g. when a given number of bytes is gathered /// configurable constraints. E.g. when a given number of bytes is gathered
/// and/or when no more data has been seen for a given time interval. /// and/or when no more data has been seen for a given time interval.
class UARTDebugger : public Component, public Trigger<UARTDirection, std::vector<uint8_t>, StringRef> { class UARTDebugger final : public Component, public Trigger<UARTDirection, std::vector<uint8_t>, StringRef> {
public: public:
explicit UARTDebugger(UARTComponent *parent); explicit UARTDebugger(UARTComponent *parent);
void loop() override; void loop() override;
@@ -73,7 +73,7 @@ class UARTDebugger : public Component, public Trigger<UARTDirection, std::vector
/// debugger is used to reverse engineer a serial protocol, for which no /// debugger is used to reverse engineer a serial protocol, for which no
/// specific UARTDevice implementation exists (yet), but for which the /// specific UARTDevice implementation exists (yet), but for which the
/// incoming bytes must be read to drive the debugger. /// incoming bytes must be read to drive the debugger.
class UARTDummyReceiver : public Component, public UARTDevice { class UARTDummyReceiver final : public Component, public UARTDevice {
public: public:
UARTDummyReceiver(UARTComponent *parent) : UARTDevice(parent) {} UARTDummyReceiver(UARTComponent *parent) : UARTDevice(parent) {}
void loop() override; void loop() override;

View File

@@ -8,7 +8,7 @@
namespace esphome::udp { namespace esphome::udp {
template<typename... Ts> class UDPWriteAction : public Action<Ts...>, public Parented<UDPComponent> { template<typename... Ts> class UDPWriteAction final : public Action<Ts...>, public Parented<UDPComponent> {
public: public:
void set_data_template(std::vector<uint8_t> (*func)(Ts...)) { void set_data_template(std::vector<uint8_t> (*func)(Ts...)) {
this->data_.func = func; this->data_.func = func;

View File

@@ -8,7 +8,7 @@
namespace esphome::udp { namespace esphome::udp {
class UDPTransport : public packet_transport::PacketTransport, public Parented<UDPComponent> { class UDPTransport final : public packet_transport::PacketTransport, public Parented<UDPComponent> {
public: public:
void setup() override; void setup() override;

View File

@@ -18,7 +18,7 @@
namespace esphome::udp { namespace esphome::udp {
static const size_t MAX_PACKET_SIZE = 508; static const size_t MAX_PACKET_SIZE = 508;
class UDPComponent : public Component { class UDPComponent final : public Component {
public: public:
void set_addresses(std::initializer_list<const char *> addresses) { this->addresses_ = addresses; } void set_addresses(std::initializer_list<const char *> addresses) { this->addresses_ = addresses; }
/// Prevent accidental use of std::string which would dangle /// Prevent accidental use of std::string which would dangle

View File

@@ -24,7 +24,7 @@ static const uint8_t COMMAND_CALIBRATE_PROBE = 20;
static const uint8_t COMMAND_MEASURE_TEMP = 40; static const uint8_t COMMAND_MEASURE_TEMP = 40;
static const uint8_t COMMAND_MEASURE_EC = 80; static const uint8_t COMMAND_MEASURE_EC = 80;
class UFireECComponent : public PollingComponent, public i2c::I2CDevice { class UFireECComponent final : public PollingComponent, public i2c::I2CDevice {
public: public:
void setup() override; void setup() override;
void update() override; void update() override;
@@ -58,7 +58,7 @@ class UFireECComponent : public PollingComponent, public i2c::I2CDevice {
float temperature_coefficient_{0.0}; float temperature_coefficient_{0.0};
}; };
template<typename... Ts> class UFireECCalibrateProbeAction : public Action<Ts...> { template<typename... Ts> class UFireECCalibrateProbeAction final : public Action<Ts...> {
public: public:
UFireECCalibrateProbeAction(UFireECComponent *parent) : parent_(parent) {} UFireECCalibrateProbeAction(UFireECComponent *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(float, solution) TEMPLATABLE_VALUE(float, solution)
@@ -72,7 +72,7 @@ template<typename... Ts> class UFireECCalibrateProbeAction : public Action<Ts...
UFireECComponent *parent_; UFireECComponent *parent_;
}; };
template<typename... Ts> class UFireECResetAction : public Action<Ts...> { template<typename... Ts> class UFireECResetAction final : public Action<Ts...> {
public: public:
UFireECResetAction(UFireECComponent *parent) : parent_(parent) {} UFireECResetAction(UFireECComponent *parent) : parent_(parent) {}

View File

@@ -29,7 +29,7 @@ static const uint8_t COMMAND_CALIBRATE_LOW = 10;
static const uint8_t COMMAND_MEASURE_TEMP = 40; static const uint8_t COMMAND_MEASURE_TEMP = 40;
static const uint8_t COMMAND_MEASURE_MV = 80; static const uint8_t COMMAND_MEASURE_MV = 80;
class UFireISEComponent : public PollingComponent, public i2c::I2CDevice { class UFireISEComponent final : public PollingComponent, public i2c::I2CDevice {
public: public:
void setup() override; void setup() override;
void update() override; void update() override;
@@ -58,7 +58,7 @@ class UFireISEComponent : public PollingComponent, public i2c::I2CDevice {
sensor::Sensor *ph_sensor_{nullptr}; sensor::Sensor *ph_sensor_{nullptr};
}; };
template<typename... Ts> class UFireISECalibrateProbeLowAction : public Action<Ts...> { template<typename... Ts> class UFireISECalibrateProbeLowAction final : public Action<Ts...> {
public: public:
UFireISECalibrateProbeLowAction(UFireISEComponent *parent) : parent_(parent) {} UFireISECalibrateProbeLowAction(UFireISEComponent *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(float, solution) TEMPLATABLE_VALUE(float, solution)
@@ -69,7 +69,7 @@ template<typename... Ts> class UFireISECalibrateProbeLowAction : public Action<T
UFireISEComponent *parent_; UFireISEComponent *parent_;
}; };
template<typename... Ts> class UFireISECalibrateProbeHighAction : public Action<Ts...> { template<typename... Ts> class UFireISECalibrateProbeHighAction final : public Action<Ts...> {
public: public:
UFireISECalibrateProbeHighAction(UFireISEComponent *parent) : parent_(parent) {} UFireISECalibrateProbeHighAction(UFireISEComponent *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(float, solution) TEMPLATABLE_VALUE(float, solution)
@@ -80,7 +80,7 @@ template<typename... Ts> class UFireISECalibrateProbeHighAction : public Action<
UFireISEComponent *parent_; UFireISEComponent *parent_;
}; };
template<typename... Ts> class UFireISEResetAction : public Action<Ts...> { template<typename... Ts> class UFireISEResetAction final : public Action<Ts...> {
public: public:
UFireISEResetAction(UFireISEComponent *parent) : parent_(parent) {} UFireISEResetAction(UFireISEComponent *parent) : parent_(parent) {}

View File

@@ -12,7 +12,7 @@ enum ULN2003StepMode {
ULN2003_STEP_MODE_WAVE_DRIVE, ULN2003_STEP_MODE_WAVE_DRIVE,
}; };
class ULN2003 : public stepper::Stepper, public Component { class ULN2003 final : public stepper::Stepper, public Component {
public: public:
void set_pin_a(GPIOPin *pin_a) { pin_a_ = pin_a; } void set_pin_a(GPIOPin *pin_a) { pin_a_ = pin_a; }
void set_pin_b(GPIOPin *pin_b) { pin_b_ = pin_b; } void set_pin_b(GPIOPin *pin_b) { pin_b_ = pin_b; }

View File

@@ -18,7 +18,7 @@ struct UltrasonicSensorStore {
volatile bool echo_end{false}; volatile bool echo_end{false};
}; };
class UltrasonicSensorComponent : public sensor::Sensor, public PollingComponent { class UltrasonicSensorComponent final : public sensor::Sensor, public PollingComponent {
public: public:
void set_trigger_pin(InternalGPIOPin *trigger_pin) { this->trigger_pin_ = trigger_pin; } void set_trigger_pin(InternalGPIOPin *trigger_pin) { this->trigger_pin_ = trigger_pin; }
void set_echo_pin(InternalGPIOPin *echo_pin) { this->echo_pin_ = echo_pin; } void set_echo_pin(InternalGPIOPin *echo_pin) { this->echo_pin_ = echo_pin; }

View File

@@ -6,19 +6,19 @@
namespace esphome::update { namespace esphome::update {
template<typename... Ts> class PerformAction : public Action<Ts...>, public Parented<UpdateEntity> { template<typename... Ts> class PerformAction final : public Action<Ts...>, public Parented<UpdateEntity> {
TEMPLATABLE_VALUE(bool, force) TEMPLATABLE_VALUE(bool, force)
public: public:
void play(const Ts &...x) override { this->parent_->perform(this->force_.value(x...)); } void play(const Ts &...x) override { this->parent_->perform(this->force_.value(x...)); }
}; };
template<typename... Ts> class CheckAction : public Action<Ts...>, public Parented<UpdateEntity> { template<typename... Ts> class CheckAction final : public Action<Ts...>, public Parented<UpdateEntity> {
public: public:
void play(const Ts &...x) override { this->parent_->check(); } void play(const Ts &...x) override { this->parent_->check(); }
}; };
template<typename... Ts> class IsAvailableCondition : public Condition<Ts...>, public Parented<UpdateEntity> { template<typename... Ts> class IsAvailableCondition final : public Condition<Ts...>, public Parented<UpdateEntity> {
public: public:
bool check(const Ts &...x) override { return this->parent_->state == UPDATE_STATE_AVAILABLE; } bool check(const Ts &...x) override { return this->parent_->state == UPDATE_STATE_AVAILABLE; }
}; };

View File

@@ -6,7 +6,7 @@
namespace esphome::uponor_smatrix { namespace esphome::uponor_smatrix {
class UponorSmatrixClimate : public climate::Climate, public Component, public UponorSmatrixDevice { class UponorSmatrixClimate final : public climate::Climate, public Component, public UponorSmatrixDevice {
public: public:
void dump_config() override; void dump_config() override;
void loop() override; void loop() override;

View File

@@ -6,7 +6,7 @@
namespace esphome::uponor_smatrix { namespace esphome::uponor_smatrix {
class UponorSmatrixSensor : public sensor::Sensor, public Component, public UponorSmatrixDevice { class UponorSmatrixSensor final : public sensor::Sensor, public Component, public UponorSmatrixDevice {
SUB_SENSOR(temperature) SUB_SENSOR(temperature)
SUB_SENSOR(external_temperature) SUB_SENSOR(external_temperature)
SUB_SENSOR(humidity) SUB_SENSOR(humidity)

View File

@@ -62,7 +62,7 @@ struct UponorSmatrixData {
class UponorSmatrixDevice; class UponorSmatrixDevice;
class UponorSmatrixComponent : public uart::UARTDevice, public Component { class UponorSmatrixComponent final : public uart::UARTDevice, public Component {
public: public:
UponorSmatrixComponent() = default; UponorSmatrixComponent() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::uptime { namespace esphome::uptime {
class UptimeSecondsSensor : public sensor::Sensor, public PollingComponent { class UptimeSecondsSensor final : public sensor::Sensor, public PollingComponent {
public: public:
void update() override; void update() override;
void dump_config() override; void dump_config() override;

View File

@@ -10,7 +10,7 @@
namespace esphome::uptime { namespace esphome::uptime {
class UptimeTimestampSensor : public sensor::Sensor, public Component { class UptimeTimestampSensor final : public sensor::Sensor, public Component {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -7,7 +7,7 @@
namespace esphome::uptime { namespace esphome::uptime {
class UptimeTextSensor : public text_sensor::TextSensor, public PollingComponent { class UptimeTextSensor final : public text_sensor::TextSensor, public PollingComponent {
public: public:
UptimeTextSensor(const char *days_text, const char *hours_text, const char *minutes_text, const char *seconds_text, UptimeTextSensor(const char *days_text, const char *hours_text, const char *minutes_text, const char *seconds_text,
const char *separator, bool expand) const char *separator, bool expand)

View File

@@ -50,7 +50,7 @@ struct CDCEvent {
class USBCDCACMComponent; class USBCDCACMComponent;
/// Represents a single CDC ACM interface instance /// Represents a single CDC ACM interface instance
class USBCDCACMInstance : public uart::UARTComponent, public Parented<USBCDCACMComponent> { class USBCDCACMInstance final : public uart::UARTComponent, public Parented<USBCDCACMComponent> {
public: public:
void setup(); void setup();
void loop(); void loop();
@@ -111,7 +111,7 @@ class USBCDCACMInstance : public uart::UARTComponent, public Parented<USBCDCACMC
}; };
/// Main USB CDC ACM component that manages the USB device and all CDC interfaces /// Main USB CDC ACM component that manages the USB device and all CDC interfaces
class USBCDCACMComponent : public Component { class USBCDCACMComponent final : public Component {
public: public:
USBCDCACMComponent(); USBCDCACMComponent();

View File

@@ -183,7 +183,7 @@ class USBClient : public Component {
uint16_t vid_{}; uint16_t vid_{};
uint16_t pid_{}; uint16_t pid_{};
}; };
class USBHost : public Component { class USBHost final : public Component {
public: public:
float get_setup_priority() const override { return setup_priority::BUS; } float get_setup_priority() const override { return setup_priority::BUS; }
void loop() override; void loop() override;

View File

@@ -125,7 +125,7 @@ struct UsbOutputChunk {
void release() {} void release() {}
}; };
class USBUartChannel : public uart::UARTComponent, public Parented<USBUartComponent> { class USBUartChannel final : public uart::UARTComponent, public Parented<USBUartComponent> {
friend class USBUartComponent; friend class USBUartComponent;
friend class USBUartTypeCdcAcm; friend class USBUartTypeCdcAcm;
friend class USBUartTypeCP210X; friend class USBUartTypeCP210X;

View File

@@ -6,7 +6,7 @@
namespace esphome::valve { namespace esphome::valve {
template<typename... Ts> class OpenAction : public Action<Ts...> { template<typename... Ts> class OpenAction final : public Action<Ts...> {
public: public:
explicit OpenAction(Valve *valve) : valve_(valve) {} explicit OpenAction(Valve *valve) : valve_(valve) {}
@@ -16,7 +16,7 @@ template<typename... Ts> class OpenAction : public Action<Ts...> {
Valve *valve_; Valve *valve_;
}; };
template<typename... Ts> class CloseAction : public Action<Ts...> { template<typename... Ts> class CloseAction final : public Action<Ts...> {
public: public:
explicit CloseAction(Valve *valve) : valve_(valve) {} explicit CloseAction(Valve *valve) : valve_(valve) {}
@@ -26,7 +26,7 @@ template<typename... Ts> class CloseAction : public Action<Ts...> {
Valve *valve_; Valve *valve_;
}; };
template<typename... Ts> class StopAction : public Action<Ts...> { template<typename... Ts> class StopAction final : public Action<Ts...> {
public: public:
explicit StopAction(Valve *valve) : valve_(valve) {} explicit StopAction(Valve *valve) : valve_(valve) {}
@@ -36,7 +36,7 @@ template<typename... Ts> class StopAction : public Action<Ts...> {
Valve *valve_; Valve *valve_;
}; };
template<typename... Ts> class ToggleAction : public Action<Ts...> { template<typename... Ts> class ToggleAction final : public Action<Ts...> {
public: public:
explicit ToggleAction(Valve *valve) : valve_(valve) {} explicit ToggleAction(Valve *valve) : valve_(valve) {}
@@ -58,7 +58,7 @@ template<typename... Ts> class ToggleAction : public Action<Ts...> {
// (e.g. `const T & &` if Ts already carries a reference, or `const const // (e.g. `const T & &` if Ts already carries a reference, or `const const
// T &` if Ts already carries a const). This keeps trigger args no-copy // T &` if Ts already carries a const). This keeps trigger args no-copy
// regardless of whether the trigger supplies `T`, `T &`, or `const T &`. // regardless of whether the trigger supplies `T`, `T &`, or `const T &`.
template<typename... Ts> class ControlAction : public Action<Ts...> { template<typename... Ts> class ControlAction final : public Action<Ts...> {
public: public:
using ApplyFn = void (*)(ValveCall &, const std::remove_cvref_t<Ts> &...); using ApplyFn = void (*)(ValveCall &, const std::remove_cvref_t<Ts> &...);
ControlAction(Valve *valve, ApplyFn apply) : valve_(valve), apply_(apply) {} ControlAction(Valve *valve, ApplyFn apply) : valve_(valve), apply_(apply) {}
@@ -74,7 +74,7 @@ template<typename... Ts> class ControlAction : public Action<Ts...> {
ApplyFn apply_; ApplyFn apply_;
}; };
template<typename... Ts> class ValveIsOpenCondition : public Condition<Ts...> { template<typename... Ts> class ValveIsOpenCondition final : public Condition<Ts...> {
public: public:
ValveIsOpenCondition(Valve *valve) : valve_(valve) {} ValveIsOpenCondition(Valve *valve) : valve_(valve) {}
bool check(const Ts &...x) override { return this->valve_->is_fully_open(); } bool check(const Ts &...x) override { return this->valve_->is_fully_open(); }
@@ -83,7 +83,7 @@ template<typename... Ts> class ValveIsOpenCondition : public Condition<Ts...> {
Valve *valve_; Valve *valve_;
}; };
template<typename... Ts> class ValveIsClosedCondition : public Condition<Ts...> { template<typename... Ts> class ValveIsClosedCondition final : public Condition<Ts...> {
public: public:
ValveIsClosedCondition(Valve *valve) : valve_(valve) {} ValveIsClosedCondition(Valve *valve) : valve_(valve) {}
bool check(const Ts &...x) override { return this->valve_->is_fully_closed(); } bool check(const Ts &...x) override { return this->valve_->is_fully_closed(); }
@@ -92,7 +92,7 @@ template<typename... Ts> class ValveIsClosedCondition : public Condition<Ts...>
Valve *valve_; Valve *valve_;
}; };
class ValveOpenTrigger : public Trigger<> { class ValveOpenTrigger final : public Trigger<> {
public: public:
ValveOpenTrigger(Valve *a_valve) : valve_(a_valve) { ValveOpenTrigger(Valve *a_valve) : valve_(a_valve) {
a_valve->add_on_state_callback([this]() { a_valve->add_on_state_callback([this]() {
@@ -106,7 +106,7 @@ class ValveOpenTrigger : public Trigger<> {
Valve *valve_; Valve *valve_;
}; };
class ValveClosedTrigger : public Trigger<> { class ValveClosedTrigger final : public Trigger<> {
public: public:
ValveClosedTrigger(Valve *a_valve) : valve_(a_valve) { ValveClosedTrigger(Valve *a_valve) : valve_(a_valve) {
a_valve->add_on_state_callback([this]() { a_valve->add_on_state_callback([this]() {

View File

@@ -5,7 +5,7 @@
namespace esphome::vbus { namespace esphome::vbus {
class DeltaSolBSPlusBSensor : public VBusListener, public Component { class DeltaSolBSPlusBSensor final : public VBusListener, public Component {
public: public:
void dump_config() override; void dump_config() override;
void set_relay1_bsensor(binary_sensor::BinarySensor *bsensor) { this->relay1_bsensor_ = bsensor; } void set_relay1_bsensor(binary_sensor::BinarySensor *bsensor) { this->relay1_bsensor_ = bsensor; }
@@ -38,7 +38,7 @@ class DeltaSolBSPlusBSensor : public VBusListener, public Component {
void handle_message(std::vector<uint8_t> &message) override; void handle_message(std::vector<uint8_t> &message) override;
}; };
class DeltaSolBS2009BSensor : public VBusListener, public Component { class DeltaSolBS2009BSensor final : public VBusListener, public Component {
public: public:
void dump_config() override; void dump_config() override;
void set_s1_error_bsensor(binary_sensor::BinarySensor *bsensor) { this->s1_error_bsensor_ = bsensor; } void set_s1_error_bsensor(binary_sensor::BinarySensor *bsensor) { this->s1_error_bsensor_ = bsensor; }
@@ -59,7 +59,7 @@ class DeltaSolBS2009BSensor : public VBusListener, public Component {
void handle_message(std::vector<uint8_t> &message) override; void handle_message(std::vector<uint8_t> &message) override;
}; };
class DeltaSolCBSensor : public VBusListener, public Component { class DeltaSolCBSensor final : public VBusListener, public Component {
public: public:
void dump_config() override; void dump_config() override;
void set_s1_error_bsensor(binary_sensor::BinarySensor *bsensor) { this->s1_error_bsensor_ = bsensor; } void set_s1_error_bsensor(binary_sensor::BinarySensor *bsensor) { this->s1_error_bsensor_ = bsensor; }
@@ -76,7 +76,7 @@ class DeltaSolCBSensor : public VBusListener, public Component {
void handle_message(std::vector<uint8_t> &message) override; void handle_message(std::vector<uint8_t> &message) override;
}; };
class DeltaSolCS2BSensor : public VBusListener, public Component { class DeltaSolCS2BSensor final : public VBusListener, public Component {
public: public:
void dump_config() override; void dump_config() override;
void set_s1_error_bsensor(binary_sensor::BinarySensor *bsensor) { this->s1_error_bsensor_ = bsensor; } void set_s1_error_bsensor(binary_sensor::BinarySensor *bsensor) { this->s1_error_bsensor_ = bsensor; }
@@ -93,7 +93,7 @@ class DeltaSolCS2BSensor : public VBusListener, public Component {
void handle_message(std::vector<uint8_t> &message) override; void handle_message(std::vector<uint8_t> &message) override;
}; };
class DeltaSolCS4BSensor : public VBusListener, public Component { class DeltaSolCS4BSensor final : public VBusListener, public Component {
public: public:
void dump_config() override; void dump_config() override;
void set_s1_error_bsensor(binary_sensor::BinarySensor *bsensor) { this->s1_error_bsensor_ = bsensor; } void set_s1_error_bsensor(binary_sensor::BinarySensor *bsensor) { this->s1_error_bsensor_ = bsensor; }
@@ -110,7 +110,7 @@ class DeltaSolCS4BSensor : public VBusListener, public Component {
void handle_message(std::vector<uint8_t> &message) override; void handle_message(std::vector<uint8_t> &message) override;
}; };
class DeltaSolCSPlusBSensor : public VBusListener, public Component { class DeltaSolCSPlusBSensor final : public VBusListener, public Component {
public: public:
void dump_config() override; void dump_config() override;
void set_s1_error_bsensor(binary_sensor::BinarySensor *bsensor) { this->s1_error_bsensor_ = bsensor; } void set_s1_error_bsensor(binary_sensor::BinarySensor *bsensor) { this->s1_error_bsensor_ = bsensor; }
@@ -127,7 +127,7 @@ class DeltaSolCSPlusBSensor : public VBusListener, public Component {
void handle_message(std::vector<uint8_t> &message) override; void handle_message(std::vector<uint8_t> &message) override;
}; };
class DeltaSolBS2BSensor : public VBusListener, public Component { class DeltaSolBS2BSensor final : public VBusListener, public Component {
public: public:
void dump_config() override; void dump_config() override;
void set_s1_error_bsensor(binary_sensor::BinarySensor *bsensor) { this->s1_error_bsensor_ = bsensor; } void set_s1_error_bsensor(binary_sensor::BinarySensor *bsensor) { this->s1_error_bsensor_ = bsensor; }
@@ -146,7 +146,7 @@ class DeltaSolBS2BSensor : public VBusListener, public Component {
class VBusCustomSubBSensor; class VBusCustomSubBSensor;
class VBusCustomBSensor : public VBusListener, public Component { class VBusCustomBSensor final : public VBusListener, public Component {
public: public:
void dump_config() override; void dump_config() override;
void set_bsensors(std::vector<VBusCustomSubBSensor *> bsensors) { this->bsensors_ = std::move(bsensors); }; void set_bsensors(std::vector<VBusCustomSubBSensor *> bsensors) { this->bsensors_ = std::move(bsensors); };
@@ -156,7 +156,7 @@ class VBusCustomBSensor : public VBusListener, public Component {
void handle_message(std::vector<uint8_t> &message) override; void handle_message(std::vector<uint8_t> &message) override;
}; };
class VBusCustomSubBSensor : public binary_sensor::BinarySensor, public Component { class VBusCustomSubBSensor final : public binary_sensor::BinarySensor, public Component {
public: public:
void set_message_parser(message_parser_t parser) { this->message_parser_ = std::move(parser); }; void set_message_parser(message_parser_t parser) { this->message_parser_ = std::move(parser); };
void parse_message(std::vector<uint8_t> &message); void parse_message(std::vector<uint8_t> &message);

View File

@@ -25,7 +25,7 @@ class VBusListener {
virtual void handle_message(std::vector<uint8_t> &message) = 0; virtual void handle_message(std::vector<uint8_t> &message) = 0;
}; };
class VBus : public uart::UARTDevice, public Component { class VBus final : public uart::UARTDevice, public Component {
public: public:
void dump_config() override; void dump_config() override;
void loop() override; void loop() override;

View File

@@ -59,7 +59,7 @@ enum VEML3235ComponentGain {
VEML3235_GAIN_4X = 0b11, VEML3235_GAIN_4X = 0b11,
}; };
class VEML3235Sensor : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice { class VEML3235Sensor final : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -95,7 +95,7 @@ union PSMRegister {
} __attribute__((packed)); } __attribute__((packed));
}; };
class VEML7700Component : public PollingComponent, public i2c::I2CDevice { class VEML7700Component final : public PollingComponent, public i2c::I2CDevice {
public: public:
// //
// EspHome framework functions // EspHome framework functions

View File

@@ -22,7 +22,7 @@ struct SequenceStepTimeouts {
enum VcselPeriodType { VCSEL_PERIOD_PRE_RANGE, VCSEL_PERIOD_FINAL_RANGE }; enum VcselPeriodType { VCSEL_PERIOD_PRE_RANGE, VCSEL_PERIOD_FINAL_RANGE };
class VL53L0XSensor : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice { class VL53L0XSensor final : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
public: public:
VL53L0XSensor(); VL53L0XSensor();

View File

@@ -110,7 +110,7 @@ enum class MediaPlayerResponseState {
}; };
#endif #endif
class VoiceAssistant : public Component { class VoiceAssistant final : public Component {
public: public:
VoiceAssistant(); VoiceAssistant();
@@ -353,7 +353,7 @@ class VoiceAssistant : public Component {
#endif #endif
}; };
template<typename... Ts> class StartAction : public Action<Ts...>, public Parented<VoiceAssistant> { template<typename... Ts> class StartAction final : public Action<Ts...>, public Parented<VoiceAssistant> {
TEMPLATABLE_VALUE(std::string, wake_word); TEMPLATABLE_VALUE(std::string, wake_word);
public: public:
@@ -368,22 +368,22 @@ template<typename... Ts> class StartAction : public Action<Ts...>, public Parent
bool silence_detection_; bool silence_detection_;
}; };
template<typename... Ts> class StartContinuousAction : public Action<Ts...>, public Parented<VoiceAssistant> { template<typename... Ts> class StartContinuousAction final : public Action<Ts...>, public Parented<VoiceAssistant> {
public: public:
void play(const Ts &...x) override { this->parent_->request_start(true, true); } void play(const Ts &...x) override { this->parent_->request_start(true, true); }
}; };
template<typename... Ts> class StopAction : public Action<Ts...>, public Parented<VoiceAssistant> { template<typename... Ts> class StopAction final : public Action<Ts...>, public Parented<VoiceAssistant> {
public: public:
void play(const Ts &...x) override { this->parent_->request_stop(); } void play(const Ts &...x) override { this->parent_->request_stop(); }
}; };
template<typename... Ts> class IsRunningCondition : public Condition<Ts...>, public Parented<VoiceAssistant> { template<typename... Ts> class IsRunningCondition final : public Condition<Ts...>, public Parented<VoiceAssistant> {
public: public:
bool check(const Ts &...x) override { return this->parent_->is_running() || this->parent_->is_continuous(); } bool check(const Ts &...x) override { return this->parent_->is_running() || this->parent_->is_continuous(); }
}; };
template<typename... Ts> class ConnectedCondition : public Condition<Ts...>, public Parented<VoiceAssistant> { template<typename... Ts> class ConnectedCondition final : public Condition<Ts...>, public Parented<VoiceAssistant> {
public: public:
bool check(const Ts &...x) override { return this->parent_->get_api_connection() != nullptr; } bool check(const Ts &...x) override { return this->parent_->get_api_connection() != nullptr; }
}; };

View File

@@ -11,7 +11,7 @@
namespace esphome::wake_on_lan { namespace esphome::wake_on_lan {
class WakeOnLanButton : public button::Button, public Component { class WakeOnLanButton final : public button::Button, public Component {
public: public:
void set_macaddr(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f); void set_macaddr(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f);

View File

@@ -88,7 +88,7 @@ class AuthMiddlewareHandler : public MiddlewareHandler {
} // namespace internal } // namespace internal
class WebServerBase { class WebServerBase final {
public: public:
void init() { void init() {
if (this->initialized_) { if (this->initialized_) {

View File

@@ -266,7 +266,7 @@ class WeikaiComponent : public Component {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// @brief Helper class to expose a WeiKai family IO pin as an internal GPIO pin. /// @brief Helper class to expose a WeiKai family IO pin as an internal GPIO pin.
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class WeikaiGPIOPin : public GPIOPin { class WeikaiGPIOPin final : public GPIOPin {
public: public:
void set_parent(WeikaiComponent *parent) { this->parent_ = parent; } void set_parent(WeikaiComponent *parent) { this->parent_ = parent; }
void set_pin(uint8_t pin) { this->pin_ = pin; } void set_pin(uint8_t pin) { this->pin_ = pin; }
@@ -293,7 +293,7 @@ class WeikaiGPIOPin : public GPIOPin {
/// uart::UARTComponent virtual class. This class is common to the different members of the Weikai /// uart::UARTComponent virtual class. This class is common to the different members of the Weikai
/// components family and therefore avoid code duplication. /// components family and therefore avoid code duplication.
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
class WeikaiChannel : public uart::UARTComponent { class WeikaiChannel final : public uart::UARTComponent {
public: public:
/// @brief We belongs to this WeikaiComponent /// @brief We belongs to this WeikaiComponent
/// @param parent pointer to the component we belongs to /// @param parent pointer to the component we belongs to

View File

@@ -38,7 +38,7 @@ class WeikaiRegisterI2C : public weikai::WeikaiRegister {
/// @brief The WeikaiComponentI2C class stores the information to the WeiKai component /// @brief The WeikaiComponentI2C class stores the information to the WeiKai component
/// connected through an I2C bus. /// connected through an I2C bus.
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
class WeikaiComponentI2C : public weikai::WeikaiComponent, public i2c::I2CDevice { class WeikaiComponentI2C final : public weikai::WeikaiComponent, public i2c::I2CDevice {
public: public:
weikai::WeikaiRegister &reg(uint8_t reg, uint8_t channel) override { weikai::WeikaiRegister &reg(uint8_t reg, uint8_t channel) override {
reg_i2c_.register_ = reg; reg_i2c_.register_ = reg;

View File

@@ -31,7 +31,7 @@ class WeikaiRegisterSPI : public weikai::WeikaiRegister {
/// @brief The WeikaiComponentSPI class stores the information to the WeiKai component /// @brief The WeikaiComponentSPI class stores the information to the WeiKai component
/// connected through an SPI bus. /// connected through an SPI bus.
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
class WeikaiComponentSPI : public weikai::WeikaiComponent, class WeikaiComponentSPI final : public weikai::WeikaiComponent,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_1MHZ> { spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_1MHZ> {
public: public:

View File

@@ -16,7 +16,7 @@ const float WHIRLPOOL_DG11J1_3A_TEMP_MIN = 18.0;
const float WHIRLPOOL_DG11J1_91_TEMP_MAX = 30.0; const float WHIRLPOOL_DG11J1_91_TEMP_MAX = 30.0;
const float WHIRLPOOL_DG11J1_91_TEMP_MIN = 16.0; const float WHIRLPOOL_DG11J1_91_TEMP_MIN = 16.0;
class WhirlpoolClimate : public climate_ir::ClimateIR { class WhirlpoolClimate final : public climate_ir::ClimateIR {
public: public:
WhirlpoolClimate(); WhirlpoolClimate();

View File

@@ -12,7 +12,7 @@ const uint8_t TEMP_MAX_C = 32; // Celsius
const uint8_t TEMP_MIN_F = 61; // Fahrenheit const uint8_t TEMP_MIN_F = 61; // Fahrenheit
const uint8_t TEMP_MAX_F = 89; // Fahrenheit const uint8_t TEMP_MAX_F = 89; // Fahrenheit
class Whynter : public climate_ir::ClimateIR { class Whynter final : public climate_ir::ClimateIR {
public: public:
Whynter() Whynter()
: climate_ir::ClimateIR(TEMP_MIN_C, TEMP_MAX_C, 1.0, true, true, : climate_ir::ClimateIR(TEMP_MIN_C, TEMP_MAX_C, 1.0, true, true,

View File

@@ -21,13 +21,13 @@ struct WiegandStore {
static void d1_gpio_intr(WiegandStore *arg); static void d1_gpio_intr(WiegandStore *arg);
}; };
class WiegandTagTrigger : public Trigger<std::string> {}; class WiegandTagTrigger final : public Trigger<std::string> {};
class WiegandRawTrigger : public Trigger<uint8_t, uint64_t> {}; class WiegandRawTrigger final : public Trigger<uint8_t, uint64_t> {};
class WiegandKeyTrigger : public Trigger<uint8_t> {}; class WiegandKeyTrigger final : public Trigger<uint8_t> {};
class Wiegand : public key_provider::KeyProvider, public Component { class Wiegand final : public key_provider::KeyProvider, public Component {
public: public:
float get_setup_priority() const override { return setup_priority::HARDWARE; } float get_setup_priority() const override { return setup_priority::HARDWARE; }
void setup() override; void setup() override;

View File

@@ -6,32 +6,32 @@
namespace esphome::wifi { namespace esphome::wifi {
template<typename... Ts> class WiFiConnectedCondition : public Condition<Ts...> { template<typename... Ts> class WiFiConnectedCondition final : public Condition<Ts...> {
public: public:
bool check(const Ts &...x) override { return global_wifi_component->is_connected(); } bool check(const Ts &...x) override { return global_wifi_component->is_connected(); }
}; };
template<typename... Ts> class WiFiEnabledCondition : public Condition<Ts...> { template<typename... Ts> class WiFiEnabledCondition final : public Condition<Ts...> {
public: public:
bool check(const Ts &...x) override { return !global_wifi_component->is_disabled(); } bool check(const Ts &...x) override { return !global_wifi_component->is_disabled(); }
}; };
template<typename... Ts> class WiFiAPActiveCondition : public Condition<Ts...> { template<typename... Ts> class WiFiAPActiveCondition final : public Condition<Ts...> {
public: public:
bool check(const Ts &...x) override { return global_wifi_component->is_ap_active(); } bool check(const Ts &...x) override { return global_wifi_component->is_ap_active(); }
}; };
template<typename... Ts> class WiFiEnableAction : public Action<Ts...> { template<typename... Ts> class WiFiEnableAction final : public Action<Ts...> {
public: public:
void play(const Ts &...x) override { global_wifi_component->enable(); } void play(const Ts &...x) override { global_wifi_component->enable(); }
}; };
template<typename... Ts> class WiFiDisableAction : public Action<Ts...> { template<typename... Ts> class WiFiDisableAction final : public Action<Ts...> {
public: public:
void play(const Ts &...x) override { global_wifi_component->disable(); } void play(const Ts &...x) override { global_wifi_component->disable(); }
}; };
template<typename... Ts> class WiFiConfigureAction : public Action<Ts...>, public Component { template<typename... Ts> class WiFiConfigureAction final : public Action<Ts...>, public Component {
public: public:
TEMPLATABLE_VALUE(std::string, ssid) TEMPLATABLE_VALUE(std::string, ssid)
TEMPLATABLE_VALUE(std::string, password) TEMPLATABLE_VALUE(std::string, password)

View File

@@ -10,9 +10,9 @@
namespace esphome::wifi_signal { namespace esphome::wifi_signal {
#ifdef USE_WIFI_CONNECT_STATE_LISTENERS #ifdef USE_WIFI_CONNECT_STATE_LISTENERS
class WiFiSignalSensor : public sensor::Sensor, public PollingComponent, public wifi::WiFiConnectStateListener { class WiFiSignalSensor final : public sensor::Sensor, public PollingComponent, public wifi::WiFiConnectStateListener {
#else #else
class WiFiSignalSensor : public sensor::Sensor, public PollingComponent { class WiFiSignalSensor final : public sensor::Sensor, public PollingComponent {
#endif #endif
public: public:
#ifdef USE_WIFI_CONNECT_STATE_LISTENERS #ifdef USE_WIFI_CONNECT_STATE_LISTENERS

View File

@@ -32,7 +32,7 @@ struct AllowedIP {
}; };
/// Main Wireguard component class. /// Main Wireguard component class.
class Wireguard : public PollingComponent { class Wireguard final : public PollingComponent {
public: public:
void setup() override; void setup() override;
void loop() override; void loop() override;
@@ -165,25 +165,26 @@ static constexpr size_t MASK_KEY_BUFFER_SIZE = 12;
void mask_key_to(char *buffer, size_t len, const char *key); void mask_key_to(char *buffer, size_t len, const char *key);
/// Condition to check if remote peer is online. /// Condition to check if remote peer is online.
template<typename... Ts> class WireguardPeerOnlineCondition : public Condition<Ts...>, public Parented<Wireguard> { template<typename... Ts>
class WireguardPeerOnlineCondition final : public Condition<Ts...>, public Parented<Wireguard> {
public: public:
bool check(const Ts &...x) override { return this->parent_->is_peer_up(); } bool check(const Ts &...x) override { return this->parent_->is_peer_up(); }
}; };
/// Condition to check if Wireguard component is enabled. /// Condition to check if Wireguard component is enabled.
template<typename... Ts> class WireguardEnabledCondition : public Condition<Ts...>, public Parented<Wireguard> { template<typename... Ts> class WireguardEnabledCondition final : public Condition<Ts...>, public Parented<Wireguard> {
public: public:
bool check(const Ts &...x) override { return this->parent_->is_enabled(); } bool check(const Ts &...x) override { return this->parent_->is_enabled(); }
}; };
/// Action to enable Wireguard component. /// Action to enable Wireguard component.
template<typename... Ts> class WireguardEnableAction : public Action<Ts...>, public Parented<Wireguard> { template<typename... Ts> class WireguardEnableAction final : public Action<Ts...>, public Parented<Wireguard> {
public: public:
void play(const Ts &...x) override { this->parent_->enable(); } void play(const Ts &...x) override { this->parent_->enable(); }
}; };
/// Action to disable Wireguard component. /// Action to disable Wireguard component.
template<typename... Ts> class WireguardDisableAction : public Action<Ts...>, public Parented<Wireguard> { template<typename... Ts> class WireguardDisableAction final : public Action<Ts...>, public Parented<Wireguard> {
public: public:
void play(const Ts &...x) override { this->parent_->disable(); } void play(const Ts &...x) override { this->parent_->disable(); }
}; };

View File

@@ -8,7 +8,7 @@
namespace esphome::wl_134 { namespace esphome::wl_134 {
class Wl134Component : public text_sensor::TextSensor, public Component, public uart::UARTDevice { class Wl134Component final : public text_sensor::TextSensor, public Component, public uart::UARTDevice {
public: public:
enum Rfid134Error { enum Rfid134Error {
RFID134_ERROR_NONE, RFID134_ERROR_NONE,