Mark user-configurable classes as final (part 15/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 15 of 21, split alphabetically by
component (script .. slow_pwm).
This commit is contained in:
Jesse Hills
2026-06-15 13:21:46 +12:00
parent a25ac28ae5
commit ebe867b1f9
57 changed files with 92 additions and 88 deletions

View File

@@ -207,7 +207,7 @@ template<typename... Ts> class ParallelScript : public Script<Ts...> {
template<class S, typename... Ts> class ScriptExecuteAction; template<class S, typename... Ts> class ScriptExecuteAction;
template<class... As, typename... Ts> class ScriptExecuteAction<Script<As...>, Ts...> : public Action<Ts...> { template<class... As, typename... Ts> class ScriptExecuteAction<Script<As...>, Ts...> final : public Action<Ts...> {
public: public:
ScriptExecuteAction(Script<As...> *script) : script_(script) {} ScriptExecuteAction(Script<As...> *script) : script_(script) {}
@@ -245,7 +245,7 @@ template<class... As, typename... Ts> class ScriptExecuteAction<Script<As...>, T
Args args_; Args args_;
}; };
template<class C, typename... Ts> class ScriptStopAction : public Action<Ts...> { template<class C, typename... Ts> class ScriptStopAction final : public Action<Ts...> {
public: public:
ScriptStopAction(C *script) : script_(script) {} ScriptStopAction(C *script) : script_(script) {}
@@ -255,7 +255,7 @@ template<class C, typename... Ts> class ScriptStopAction : public Action<Ts...>
C *script_; C *script_;
}; };
template<class C, typename... Ts> class IsRunningCondition : public Condition<Ts...> { template<class C, typename... Ts> class IsRunningCondition final : public Condition<Ts...> {
public: public:
explicit IsRunningCondition(C *parent) : parent_(parent) {} explicit IsRunningCondition(C *parent) : parent_(parent) {}
@@ -272,7 +272,7 @@ template<class C, typename... Ts> class IsRunningCondition : public Condition<Ts
* (e.g., rapid button presses, high-frequency sensor updates), so we use * (e.g., rapid button presses, high-frequency sensor updates), so we use
* queue-based storage for correctness. * queue-based storage for correctness.
*/ */
template<class C, typename... Ts> class ScriptWaitAction : public Action<Ts...>, public Component { template<class C, typename... Ts> class ScriptWaitAction final : public Action<Ts...>, public Component {
public: public:
ScriptWaitAction(C *script) : script_(script) {} ScriptWaitAction(C *script) : script_(script) {}

View File

@@ -13,7 +13,7 @@ namespace esphome::sdl {
constexpr static const char *const TAG = "sdl"; constexpr static const char *const TAG = "sdl";
class Sdl : public display::Display { class Sdl final : public display::Display {
public: public:
display::DisplayType get_display_type() override { return display::DISPLAY_TYPE_COLOR; } display::DisplayType get_display_type() override { return display::DISPLAY_TYPE_COLOR; }
void update() override; void update() override;

View File

@@ -6,7 +6,7 @@
namespace esphome::sdl { namespace esphome::sdl {
class SdlTouchscreen : public touchscreen::Touchscreen, public Parented<Sdl> { class SdlTouchscreen final : public touchscreen::Touchscreen, public Parented<Sdl> {
public: public:
void setup() override { void setup() override {
this->x_raw_max_ = this->display_->get_width(); this->x_raw_max_ = this->display_->get_width();

View File

@@ -8,7 +8,7 @@
namespace esphome::sdm_meter { namespace esphome::sdm_meter {
class SDMMeter : public PollingComponent, public modbus::ModbusDevice { class SDMMeter final : public PollingComponent, public modbus::ModbusDevice {
public: public:
void set_voltage_sensor(uint8_t phase, sensor::Sensor *voltage_sensor) { void set_voltage_sensor(uint8_t phase, sensor::Sensor *voltage_sensor) {
this->phases_[phase].setup = true; this->phases_[phase].setup = true;

View File

@@ -8,7 +8,9 @@ namespace esphome::sdp3x {
enum MeasurementMode { MASS_FLOW_AVG, DP_AVG }; enum MeasurementMode { MASS_FLOW_AVG, DP_AVG };
class SDP3XComponent : public PollingComponent, public sensirion_common::SensirionI2CDevice, public sensor::Sensor { class SDP3XComponent final : public PollingComponent,
public sensirion_common::SensirionI2CDevice,
public sensor::Sensor {
public: public:
/// Schedule temperature+pressure readings. /// Schedule temperature+pressure readings.
void update() override; void update() override;

View File

@@ -7,7 +7,7 @@
namespace esphome::sds011 { namespace esphome::sds011 {
class SDS011Component : public Component, public uart::UARTDevice { class SDS011Component final : public Component, public uart::UARTDevice {
public: public:
SDS011Component() = default; SDS011Component() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class CustomSetEndButton : public button::Button, public Parented<MR24HPC1Component> { class CustomSetEndButton final : public button::Button, public Parented<MR24HPC1Component> {
public: public:
CustomSetEndButton() = default; CustomSetEndButton() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class RestartButton : public button::Button, public Parented<MR24HPC1Component> { class RestartButton final : public button::Button, public Parented<MR24HPC1Component> {
public: public:
RestartButton() = default; RestartButton() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class CustomModeNumber : public number::Number, public Parented<MR24HPC1Component> { class CustomModeNumber final : public number::Number, public Parented<MR24HPC1Component> {
public: public:
CustomModeNumber() = default; CustomModeNumber() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class CustomUnmanTimeNumber : public number::Number, public Parented<MR24HPC1Component> { class CustomUnmanTimeNumber final : public number::Number, public Parented<MR24HPC1Component> {
public: public:
CustomUnmanTimeNumber() = default; CustomUnmanTimeNumber() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class ExistenceThresholdNumber : public number::Number, public Parented<MR24HPC1Component> { class ExistenceThresholdNumber final : public number::Number, public Parented<MR24HPC1Component> {
public: public:
ExistenceThresholdNumber() = default; ExistenceThresholdNumber() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class MotionThresholdNumber : public number::Number, public Parented<MR24HPC1Component> { class MotionThresholdNumber final : public number::Number, public Parented<MR24HPC1Component> {
public: public:
MotionThresholdNumber() = default; MotionThresholdNumber() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class MotionTriggerTimeNumber : public number::Number, public Parented<MR24HPC1Component> { class MotionTriggerTimeNumber final : public number::Number, public Parented<MR24HPC1Component> {
public: public:
MotionTriggerTimeNumber() = default; MotionTriggerTimeNumber() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class MotionToRestTimeNumber : public number::Number, public Parented<MR24HPC1Component> { class MotionToRestTimeNumber final : public number::Number, public Parented<MR24HPC1Component> {
public: public:
MotionToRestTimeNumber() = default; MotionToRestTimeNumber() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class SensitivityNumber : public number::Number, public Parented<MR24HPC1Component> { class SensitivityNumber final : public number::Number, public Parented<MR24HPC1Component> {
public: public:
SensitivityNumber() = default; SensitivityNumber() = default;

View File

@@ -92,8 +92,8 @@ static const char *const S_BOUNDARY_STR[10] = {"0.5m", "1.0m", "1.5m", "2.0m", "
"3.0m", "3.5m", "4.0m", "4.5m", "5.0m"}; // uint: m "3.0m", "3.5m", "4.0m", "4.5m", "5.0m"}; // uint: m
static const float S_PRESENCE_OF_DETECTION_RANGE_STR[7] = {0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f}; // uint: m static const float S_PRESENCE_OF_DETECTION_RANGE_STR[7] = {0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f}; // uint: m
class MR24HPC1Component : public Component, class MR24HPC1Component final : public Component,
public uart::UARTDevice { // The class name must be the name defined by text_sensor.py public uart::UARTDevice { // The class name must be the name defined by text_sensor.py
#ifdef USE_TEXT_SENSOR #ifdef USE_TEXT_SENSOR
SUB_TEXT_SENSOR(heartbeat_state) SUB_TEXT_SENSOR(heartbeat_state)
SUB_TEXT_SENSOR(product_model) SUB_TEXT_SENSOR(product_model)

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class ExistenceBoundarySelect : public select::Select, public Parented<MR24HPC1Component> { class ExistenceBoundarySelect final : public select::Select, public Parented<MR24HPC1Component> {
public: public:
ExistenceBoundarySelect() = default; ExistenceBoundarySelect() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class MotionBoundarySelect : public select::Select, public Parented<MR24HPC1Component> { class MotionBoundarySelect final : public select::Select, public Parented<MR24HPC1Component> {
public: public:
MotionBoundarySelect() = default; MotionBoundarySelect() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class SceneModeSelect : public select::Select, public Parented<MR24HPC1Component> { class SceneModeSelect final : public select::Select, public Parented<MR24HPC1Component> {
public: public:
SceneModeSelect() = default; SceneModeSelect() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class UnmanTimeSelect : public select::Select, public Parented<MR24HPC1Component> { class UnmanTimeSelect final : public select::Select, public Parented<MR24HPC1Component> {
public: public:
UnmanTimeSelect() = default; UnmanTimeSelect() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr24hpc1 { namespace esphome::seeed_mr24hpc1 {
class UnderlyOpenFunctionSwitch : public switch_::Switch, public Parented<MR24HPC1Component> { class UnderlyOpenFunctionSwitch final : public switch_::Switch, public Parented<MR24HPC1Component> {
public: public:
UnderlyOpenFunctionSwitch() = default; UnderlyOpenFunctionSwitch() = default;

View File

@@ -21,8 +21,8 @@ static const uint16_t HEART_RATE_TYPE_BUFFER = 0x0A15;
static const uint16_t DISTANCE_TYPE_BUFFER = 0x0A16; static const uint16_t DISTANCE_TYPE_BUFFER = 0x0A16;
static const uint16_t PRINT_CLOUD_BUFFER = 0x0A04; static const uint16_t PRINT_CLOUD_BUFFER = 0x0A04;
class MR60BHA2Component : public Component, class MR60BHA2Component final : public Component,
public uart::UARTDevice { // The class name must be the name defined by text_sensor.py public uart::UARTDevice { // The class name must be the name defined by text_sensor.py
#ifdef USE_BINARY_SENSOR #ifdef USE_BINARY_SENSOR
SUB_BINARY_SENSOR(has_target); SUB_BINARY_SENSOR(has_target);
#endif #endif

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr60fda2 { namespace esphome::seeed_mr60fda2 {
class GetRadarParametersButton : public button::Button, public Parented<MR60FDA2Component> { class GetRadarParametersButton final : public button::Button, public Parented<MR60FDA2Component> {
public: public:
GetRadarParametersButton() = default; GetRadarParametersButton() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr60fda2 { namespace esphome::seeed_mr60fda2 {
class ResetRadarButton : public button::Button, public Parented<MR60FDA2Component> { class ResetRadarButton final : public button::Button, public Parented<MR60FDA2Component> {
public: public:
ResetRadarButton() = default; ResetRadarButton() = default;

View File

@@ -56,8 +56,8 @@ static const char *const INSTALL_HEIGHT_STR[7] = {"2.4m", "2.5m", "2.6", "2.7m",
static const char *const HEIGHT_THRESHOLD_STR[7] = {"0.0m", "0.1m", "0.2m", "0.3m", "0.4m", "0.5m", "0.6m"}; static const char *const HEIGHT_THRESHOLD_STR[7] = {"0.0m", "0.1m", "0.2m", "0.3m", "0.4m", "0.5m", "0.6m"};
static const char *const SENSITIVITY_STR[3] = {"1", "2", "3"}; static const char *const SENSITIVITY_STR[3] = {"1", "2", "3"};
class MR60FDA2Component : public Component, class MR60FDA2Component final : public Component,
public uart::UARTDevice { // The class name must be the name defined by text_sensor.py public uart::UARTDevice { // The class name must be the name defined by text_sensor.py
#ifdef USE_BINARY_SENSOR #ifdef USE_BINARY_SENSOR
SUB_BINARY_SENSOR(people_exist) SUB_BINARY_SENSOR(people_exist)
SUB_BINARY_SENSOR(fall_detected) SUB_BINARY_SENSOR(fall_detected)

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr60fda2 { namespace esphome::seeed_mr60fda2 {
class HeightThresholdSelect : public select::Select, public Parented<MR60FDA2Component> { class HeightThresholdSelect final : public select::Select, public Parented<MR60FDA2Component> {
public: public:
HeightThresholdSelect() = default; HeightThresholdSelect() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr60fda2 { namespace esphome::seeed_mr60fda2 {
class InstallHeightSelect : public select::Select, public Parented<MR60FDA2Component> { class InstallHeightSelect final : public select::Select, public Parented<MR60FDA2Component> {
public: public:
InstallHeightSelect() = default; InstallHeightSelect() = default;

View File

@@ -5,7 +5,7 @@
namespace esphome::seeed_mr60fda2 { namespace esphome::seeed_mr60fda2 {
class SensitivitySelect : public select::Select, public Parented<MR60FDA2Component> { class SensitivitySelect final : public select::Select, public Parented<MR60FDA2Component> {
public: public:
SensitivitySelect() = default; SensitivitySelect() = default;

View File

@@ -15,7 +15,7 @@ namespace esphome::selec_meter {
public: \ public: \
void set_##name##_sensor(sensor::Sensor *(name)) { this->name##_sensor_ = name; } void set_##name##_sensor(sensor::Sensor *(name)) { this->name##_sensor_ = name; }
class SelecMeter : public PollingComponent, public modbus::ModbusDevice { class SelecMeter final : public PollingComponent, public modbus::ModbusDevice {
public: public:
SELEC_METER_SENSOR(total_active_energy) SELEC_METER_SENSOR(total_active_energy)
SELEC_METER_SENSOR(import_active_energy) SELEC_METER_SENSOR(import_active_energy)

View File

@@ -6,7 +6,7 @@
namespace esphome::select { namespace esphome::select {
class SelectStateTrigger : public Trigger<StringRef, size_t> { class SelectStateTrigger final : public Trigger<StringRef, size_t> {
public: public:
explicit SelectStateTrigger(Select *parent) : parent_(parent) { explicit SelectStateTrigger(Select *parent) : parent_(parent) {
parent->add_on_state_callback( parent->add_on_state_callback(
@@ -17,7 +17,7 @@ class SelectStateTrigger : public Trigger<StringRef, size_t> {
Select *parent_; Select *parent_;
}; };
template<typename... Ts> class SelectSetAction : public Action<Ts...> { template<typename... Ts> class SelectSetAction final : public Action<Ts...> {
public: public:
explicit SelectSetAction(Select *select) : select_(select) {} explicit SelectSetAction(Select *select) : select_(select) {}
TEMPLATABLE_VALUE(std::string, option) TEMPLATABLE_VALUE(std::string, option)
@@ -32,7 +32,7 @@ template<typename... Ts> class SelectSetAction : public Action<Ts...> {
Select *select_; Select *select_;
}; };
template<typename... Ts> class SelectSetIndexAction : public Action<Ts...> { template<typename... Ts> class SelectSetIndexAction final : public Action<Ts...> {
public: public:
explicit SelectSetIndexAction(Select *select) : select_(select) {} explicit SelectSetIndexAction(Select *select) : select_(select) {}
TEMPLATABLE_VALUE(size_t, index) TEMPLATABLE_VALUE(size_t, index)
@@ -47,7 +47,7 @@ template<typename... Ts> class SelectSetIndexAction : public Action<Ts...> {
Select *select_; Select *select_;
}; };
template<typename... Ts> class SelectOperationAction : public Action<Ts...> { template<typename... Ts> class SelectOperationAction final : public Action<Ts...> {
public: public:
explicit SelectOperationAction(Select *select) : select_(select) {} explicit SelectOperationAction(Select *select) : select_(select) {}
TEMPLATABLE_VALUE(bool, cycle) TEMPLATABLE_VALUE(bool, cycle)
@@ -66,7 +66,7 @@ template<typename... Ts> class SelectOperationAction : public Action<Ts...> {
Select *select_; Select *select_;
}; };
template<size_t N, typename... Ts> class SelectIsCondition : public Condition<Ts...> { template<size_t N, typename... Ts> class SelectIsCondition final : public Condition<Ts...> {
public: public:
SelectIsCondition(Select *parent, const char *const *option_list) : parent_(parent), option_list_(option_list) {} SelectIsCondition(Select *parent, const char *const *option_list) : parent_(parent), option_list_(option_list) {}
@@ -85,7 +85,7 @@ template<size_t N, typename... Ts> class SelectIsCondition : public Condition<Ts
const char *const *option_list_; const char *const *option_list_;
}; };
template<typename... Ts> class SelectIsCondition<0, Ts...> : public Condition<Ts...> { template<typename... Ts> class SelectIsCondition<0, Ts...> final : public Condition<Ts...> {
public: public:
SelectIsCondition(Select *parent, std::function<bool(const StringRef &, const Ts &...)> &&f) SelectIsCondition(Select *parent, std::function<bool(const StringRef &, const Ts &...)> &&f)
: parent_(parent), f_(f) {} : parent_(parent), f_(f) {}

View File

@@ -20,7 +20,7 @@ static const uint8_t SET_REGISTER = 0x04;
static const uint8_t SENSOR_PASS_READ_REG = 0x07; static const uint8_t SENSOR_PASS_READ_REG = 0x07;
static const uint8_t SENSOR_AUTO_READ_REG = 0x09; static const uint8_t SENSOR_AUTO_READ_REG = 0x09;
class Sen0321Sensor : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice { class Sen0321Sensor final : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
public: public:
void update() override; void update() override;
void dump_config() override; void dump_config() override;

View File

@@ -63,7 +63,7 @@ using person_sensor_results_t = struct __attribute__((__packed__)) {
uint16_t checksum; // Bytes 38-39. uint16_t checksum; // Bytes 38-39.
}; };
class Sen21231Sensor : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice { class Sen21231Sensor final : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
public: public:
void update() override; void update() override;
void dump_config() override; void dump_config() override;

View File

@@ -6,7 +6,7 @@
namespace esphome::sen5x { namespace esphome::sen5x {
template<typename... Ts> class StartFanAction : public Action<Ts...> { template<typename... Ts> class StartFanAction final : public Action<Ts...> {
public: public:
explicit StartFanAction(SEN5XComponent *sen5x) : sen5x_(sen5x) {} explicit StartFanAction(SEN5XComponent *sen5x) : sen5x_(sen5x) {}

View File

@@ -44,7 +44,7 @@ struct TemperatureCompensation {
// Prevents wear of the flash because of too many write operations // Prevents wear of the flash because of too many write operations
static const uint32_t SHORTEST_BASELINE_STORE_INTERVAL = 2 * 60 * 60 * 1000; static const uint32_t SHORTEST_BASELINE_STORE_INTERVAL = 2 * 60 * 60 * 1000;
class SEN5XComponent : public PollingComponent, public sensirion_common::SensirionI2CDevice { class SEN5XComponent final : public PollingComponent, public sensirion_common::SensirionI2CDevice {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -6,7 +6,7 @@
namespace esphome::sen6x { namespace esphome::sen6x {
class SEN6XComponent : public PollingComponent, public sensirion_common::SensirionI2CDevice { class SEN6XComponent final : public PollingComponent, public sensirion_common::SensirionI2CDevice {
SUB_SENSOR(pm_1_0) SUB_SENSOR(pm_1_0)
SUB_SENSOR(pm_2_5) SUB_SENSOR(pm_2_5)
SUB_SENSOR(pm_4_0) SUB_SENSOR(pm_4_0)

View File

@@ -10,7 +10,7 @@
namespace esphome::sendspin_ { namespace esphome::sendspin_ {
#ifdef USE_SENDSPIN_CONTROLLER #ifdef USE_SENDSPIN_CONTROLLER
template<typename... Ts> class SendspinSwitchCommandAction : public Action<Ts...>, public Parented<SendspinHub> { template<typename... Ts> class SendspinSwitchCommandAction final : public Action<Ts...>, public Parented<SendspinHub> {
public: public:
void play(const Ts &...x) override { void play(const Ts &...x) override {
// Clear any EXTERNAL_SOURCE state so the switch command is followed // Clear any EXTERNAL_SOURCE state so the switch command is followed

View File

@@ -9,7 +9,7 @@
namespace esphome::sendspin_ { namespace esphome::sendspin_ {
class SendspinMediaPlayer : public SendspinChild, public media_player::MediaPlayer { class SendspinMediaPlayer final : public SendspinChild, public media_player::MediaPlayer {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -10,13 +10,13 @@
namespace esphome::sendspin_ { namespace esphome::sendspin_ {
template<typename... Ts> template<typename... Ts>
class EnableStaticDelayAdjustmentAction : public Action<Ts...>, public Parented<SendspinMediaSource> { class EnableStaticDelayAdjustmentAction final : public Action<Ts...>, public Parented<SendspinMediaSource> {
public: public:
void play(const Ts &...x) override { this->parent_->set_static_delay_adjustable(true); } void play(const Ts &...x) override { this->parent_->set_static_delay_adjustable(true); }
}; };
template<typename... Ts> template<typename... Ts>
class DisableStaticDelayAdjustmentAction : public Action<Ts...>, public Parented<SendspinMediaSource> { class DisableStaticDelayAdjustmentAction final : public Action<Ts...>, public Parented<SendspinMediaSource> {
public: public:
void play(const Ts &...x) override { this->parent_->set_static_delay_adjustable(false); } void play(const Ts &...x) override { this->parent_->set_static_delay_adjustable(false); }
}; };

View File

@@ -17,9 +17,9 @@ namespace esphome::sendspin_ {
/// Implements PlayerRoleListener to receive audio data from the sendspin-cpp library's /// Implements PlayerRoleListener to receive audio data from the sendspin-cpp library's
/// SyncTask and bridges it to ESPHome's MediaSource output pipeline. Also forwards /// SyncTask and bridges it to ESPHome's MediaSource output pipeline. Also forwards
/// transport commands to the hub's controller role. /// transport commands to the hub's controller role.
class SendspinMediaSource : public SendspinChild, class SendspinMediaSource final : public SendspinChild,
public media_source::MediaSource, public media_source::MediaSource,
public sendspin::PlayerRoleListener { public sendspin::PlayerRoleListener {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -11,7 +11,7 @@
namespace esphome::sendspin_ { namespace esphome::sendspin_ {
class SendspinTrackProgressSensor : public sensor::Sensor, public SendspinPollingChild { class SendspinTrackProgressSensor final : public sensor::Sensor, public SendspinPollingChild {
public: public:
void dump_config() override; void dump_config() override;
void setup() override; void setup() override;
@@ -24,7 +24,7 @@ enum class SendspinNumericMetadataTypes {
TRACK, TRACK,
}; };
class SendspinMetadataSensor : public sensor::Sensor, public SendspinChild { class SendspinMetadataSensor final : public sensor::Sensor, public SendspinChild {
public: public:
void dump_config() override; void dump_config() override;
void setup() override; void setup() override;

View File

@@ -18,7 +18,7 @@ enum class SendspinTextMetadataTypes {
ALBUM_ARTIST, ALBUM_ARTIST,
}; };
class SendspinTextSensor : public SendspinChild, public text_sensor::TextSensor { class SendspinTextSensor final : public SendspinChild, public text_sensor::TextSensor {
public: public:
void dump_config() override; void dump_config() override;
void setup() override; void setup() override;

View File

@@ -18,7 +18,7 @@ enum SenseAirStatus : uint8_t {
RESERVED = 1 << 7 RESERVED = 1 << 7
}; };
class SenseAirComponent : public PollingComponent, public uart::UARTDevice { class SenseAirComponent final : public PollingComponent, public uart::UARTDevice {
public: public:
void set_co2_sensor(sensor::Sensor *co2_sensor) { co2_sensor_ = co2_sensor; } void set_co2_sensor(sensor::Sensor *co2_sensor) { co2_sensor_ = co2_sensor; }
@@ -37,7 +37,7 @@ class SenseAirComponent : public PollingComponent, public uart::UARTDevice {
sensor::Sensor *co2_sensor_{nullptr}; sensor::Sensor *co2_sensor_{nullptr};
}; };
template<typename... Ts> class SenseAirBackgroundCalibrationAction : public Action<Ts...> { template<typename... Ts> class SenseAirBackgroundCalibrationAction final : public Action<Ts...> {
public: public:
SenseAirBackgroundCalibrationAction(SenseAirComponent *senseair) : senseair_(senseair) {} SenseAirBackgroundCalibrationAction(SenseAirComponent *senseair) : senseair_(senseair) {}
@@ -47,7 +47,7 @@ template<typename... Ts> class SenseAirBackgroundCalibrationAction : public Acti
SenseAirComponent *senseair_; SenseAirComponent *senseair_;
}; };
template<typename... Ts> class SenseAirBackgroundCalibrationResultAction : public Action<Ts...> { template<typename... Ts> class SenseAirBackgroundCalibrationResultAction final : public Action<Ts...> {
public: public:
SenseAirBackgroundCalibrationResultAction(SenseAirComponent *senseair) : senseair_(senseair) {} SenseAirBackgroundCalibrationResultAction(SenseAirComponent *senseair) : senseair_(senseair) {}
@@ -57,7 +57,7 @@ template<typename... Ts> class SenseAirBackgroundCalibrationResultAction : publi
SenseAirComponent *senseair_; SenseAirComponent *senseair_;
}; };
template<typename... Ts> class SenseAirABCEnableAction : public Action<Ts...> { template<typename... Ts> class SenseAirABCEnableAction final : public Action<Ts...> {
public: public:
SenseAirABCEnableAction(SenseAirComponent *senseair) : senseair_(senseair) {} SenseAirABCEnableAction(SenseAirComponent *senseair) : senseair_(senseair) {}
@@ -67,7 +67,7 @@ template<typename... Ts> class SenseAirABCEnableAction : public Action<Ts...> {
SenseAirComponent *senseair_; SenseAirComponent *senseair_;
}; };
template<typename... Ts> class SenseAirABCDisableAction : public Action<Ts...> { template<typename... Ts> class SenseAirABCDisableAction final : public Action<Ts...> {
public: public:
SenseAirABCDisableAction(SenseAirComponent *senseair) : senseair_(senseair) {} SenseAirABCDisableAction(SenseAirComponent *senseair) : senseair_(senseair) {}
@@ -77,7 +77,7 @@ template<typename... Ts> class SenseAirABCDisableAction : public Action<Ts...> {
SenseAirComponent *senseair_; SenseAirComponent *senseair_;
}; };
template<typename... Ts> class SenseAirABCGetPeriodAction : public Action<Ts...> { template<typename... Ts> class SenseAirABCGetPeriodAction final : public Action<Ts...> {
public: public:
SenseAirABCGetPeriodAction(SenseAirComponent *senseair) : senseair_(senseair) {} SenseAirABCGetPeriodAction(SenseAirComponent *senseair) : senseair_(senseair) {}

View File

@@ -6,21 +6,21 @@
namespace esphome::sensor { namespace esphome::sensor {
class SensorStateTrigger : public Trigger<float> { class SensorStateTrigger final : public Trigger<float> {
public: public:
explicit SensorStateTrigger(Sensor *parent) { explicit SensorStateTrigger(Sensor *parent) {
parent->add_on_state_callback([this](float value) { this->trigger(value); }); parent->add_on_state_callback([this](float value) { this->trigger(value); });
} }
}; };
class SensorRawStateTrigger : public Trigger<float> { class SensorRawStateTrigger final : public Trigger<float> {
public: public:
explicit SensorRawStateTrigger(Sensor *parent) { explicit SensorRawStateTrigger(Sensor *parent) {
parent->add_on_raw_state_callback([this](float value) { this->trigger(value); }); parent->add_on_raw_state_callback([this](float value) { this->trigger(value); });
} }
}; };
template<typename... Ts> class SensorPublishAction : public Action<Ts...> { template<typename... Ts> class SensorPublishAction final : public Action<Ts...> {
public: public:
SensorPublishAction(Sensor *sensor) : sensor_(sensor) {} SensorPublishAction(Sensor *sensor) : sensor_(sensor) {}
TEMPLATABLE_VALUE(float, state) TEMPLATABLE_VALUE(float, state)
@@ -31,7 +31,7 @@ template<typename... Ts> class SensorPublishAction : public Action<Ts...> {
Sensor *sensor_; Sensor *sensor_;
}; };
class ValueRangeTrigger : public Trigger<float>, public Component { class ValueRangeTrigger final : public Trigger<float>, public Component {
public: public:
explicit ValueRangeTrigger(Sensor *parent) : parent_(parent) {} explicit ValueRangeTrigger(Sensor *parent) : parent_(parent) {}
@@ -83,7 +83,7 @@ class ValueRangeTrigger : public Trigger<float>, public Component {
TemplatableFn<float, float> max_{[](float) -> float { return NAN; }}; TemplatableFn<float, float> max_{[](float) -> float { return NAN; }};
}; };
template<typename... Ts> class SensorInRangeCondition : public Condition<Ts...> { template<typename... Ts> class SensorInRangeCondition final : public Condition<Ts...> {
public: public:
SensorInRangeCondition(Sensor *parent) : parent_(parent) {} SensorInRangeCondition(Sensor *parent) : parent_(parent) {}

View File

@@ -41,7 +41,7 @@ enum SerialProxyLineStateFlag : uint32_t {
/// Maximum bytes to read from UART in a single loop iteration /// Maximum bytes to read from UART in a single loop iteration
inline constexpr size_t SERIAL_PROXY_MAX_READ_SIZE = 256; inline constexpr size_t SERIAL_PROXY_MAX_READ_SIZE = 256;
class SerialProxy : public uart::UARTDevice, public Component { class SerialProxy final : public uart::UARTDevice, public Component {
public: public:
void setup() override; void setup() override;
void loop() override; void loop() override;

View File

@@ -10,7 +10,7 @@ namespace esphome::servo {
extern uint32_t global_servo_id; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) extern uint32_t global_servo_id; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
class Servo : public Component { class Servo final : public Component {
public: public:
void set_output(output::FloatOutput *output) { output_ = output; } void set_output(output::FloatOutput *output) { output_ = output; }
void loop() override; void loop() override;
@@ -51,7 +51,7 @@ class Servo : public Component {
}; };
}; };
template<typename... Ts> class ServoWriteAction : public Action<Ts...> { template<typename... Ts> class ServoWriteAction final : public Action<Ts...> {
public: public:
ServoWriteAction(Servo *servo) : servo_(servo) {} ServoWriteAction(Servo *servo) : servo_(servo) {}
TEMPLATABLE_VALUE(float, value) TEMPLATABLE_VALUE(float, value)
@@ -62,7 +62,7 @@ template<typename... Ts> class ServoWriteAction : public Action<Ts...> {
Servo *servo_; Servo *servo_;
}; };
template<typename... Ts> class ServoDetachAction : public Action<Ts...> { template<typename... Ts> class ServoDetachAction final : public Action<Ts...> {
public: public:
ServoDetachAction(Servo *servo) : servo_(servo) {} ServoDetachAction(Servo *servo) : servo_(servo) {}

View File

@@ -6,7 +6,7 @@
namespace esphome::sfa30 { namespace esphome::sfa30 {
class SFA30Component : public PollingComponent, public sensirion_common::SensirionI2CDevice { class SFA30Component final : public PollingComponent, public sensirion_common::SensirionI2CDevice {
enum ErrorCode { DEVICE_MARKING_READ_FAILED, MEASUREMENT_INIT_FAILED, UNKNOWN }; enum ErrorCode { DEVICE_MARKING_READ_FAILED, MEASUREMENT_INIT_FAILED, UNKNOWN };
public: public:

View File

@@ -16,7 +16,7 @@ struct SGP30Baselines {
} PACKED; } PACKED;
/// This class implements support for the Sensirion SGP30 i2c GAS (VOC and CO2eq) sensors. /// This class implements support for the Sensirion SGP30 i2c GAS (VOC and CO2eq) sensors.
class SGP30Component : public PollingComponent, public sensirion_common::SensirionI2CDevice { class SGP30Component final : public PollingComponent, public sensirion_common::SensirionI2CDevice {
public: public:
void set_eco2_sensor(sensor::Sensor *eco2) { eco2_sensor_ = eco2; } void set_eco2_sensor(sensor::Sensor *eco2) { eco2_sensor_ = eco2; }
void set_tvoc_sensor(sensor::Sensor *tvoc) { tvoc_sensor_ = tvoc; } void set_tvoc_sensor(sensor::Sensor *tvoc) { tvoc_sensor_ = tvoc; }

View File

@@ -54,7 +54,9 @@ const float MAXIMUM_STORAGE_DIFF = 50.0f;
class SGP4xComponent; class SGP4xComponent;
/// This class implements support for the Sensirion sgp4x i2c GAS (VOC) sensors. /// This class implements support for the Sensirion sgp4x i2c GAS (VOC) sensors.
class SGP4xComponent : public PollingComponent, public sensor::Sensor, public sensirion_common::SensirionI2CDevice { class SGP4xComponent final : public PollingComponent,
public sensor::Sensor,
public sensirion_common::SensirionI2CDevice {
enum ErrorCode { enum ErrorCode {
COMMUNICATION_FAILED, COMMUNICATION_FAILED,
MEASUREMENT_INIT_FAILED, MEASUREMENT_INIT_FAILED,

View File

@@ -12,7 +12,7 @@
namespace esphome::shelly_dimmer { namespace esphome::shelly_dimmer {
class ShellyDimmer : public PollingComponent, public light::LightOutput, public uart::UARTDevice { class ShellyDimmer final : public PollingComponent, public light::LightOutput, public uart::UARTDevice {
private: private:
static constexpr uint16_t SHELLY_DIMMER_BUFFER_SIZE = 256; static constexpr uint16_t SHELLY_DIMMER_BUFFER_SIZE = 256;

View File

@@ -7,7 +7,7 @@
namespace esphome::sht3xd { namespace esphome::sht3xd {
/// This class implements support for the SHT3x-DIS family of temperature+humidity i2c sensors. /// This class implements support for the SHT3x-DIS family of temperature+humidity i2c sensors.
class SHT3XDComponent : public PollingComponent, public sensirion_common::SensirionI2CDevice { class SHT3XDComponent final : public PollingComponent, public sensirion_common::SensirionI2CDevice {
public: public:
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; } void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
void set_humidity_sensor(sensor::Sensor *humidity_sensor) { humidity_sensor_ = humidity_sensor; } void set_humidity_sensor(sensor::Sensor *humidity_sensor) { humidity_sensor_ = humidity_sensor; }

View File

@@ -14,7 +14,7 @@ enum SHT4XHEATERPOWER { SHT4X_HEATERPOWER_HIGH, SHT4X_HEATERPOWER_MED, SHT4X_HEA
enum SHT4XHEATERTIME : uint16_t { SHT4X_HEATERTIME_LONG = 1100, SHT4X_HEATERTIME_SHORT = 110 }; enum SHT4XHEATERTIME : uint16_t { SHT4X_HEATERTIME_LONG = 1100, SHT4X_HEATERTIME_SHORT = 110 };
class SHT4XComponent : public PollingComponent, public sensirion_common::SensirionI2CDevice { class SHT4XComponent final : public PollingComponent, public sensirion_common::SensirionI2CDevice {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -13,7 +13,7 @@ enum SHTCXType : uint8_t {
}; };
/// This class implements support for the SHT3x-DIS family of temperature+humidity i2c sensors. /// This class implements support for the SHT3x-DIS family of temperature+humidity i2c sensors.
class SHTCXComponent : public PollingComponent, public sensirion_common::SensirionI2CDevice { class SHTCXComponent final : public PollingComponent, public sensirion_common::SensirionI2CDevice {
public: public:
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; } void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
void set_humidity_sensor(sensor::Sensor *humidity_sensor) { humidity_sensor_ = humidity_sensor; } void set_humidity_sensor(sensor::Sensor *humidity_sensor) { humidity_sensor_ = humidity_sensor; }

View File

@@ -5,7 +5,7 @@
namespace esphome::shutdown { namespace esphome::shutdown {
class ShutdownButton : public button::Button, public Component { class ShutdownButton final : public button::Button, public Component {
public: public:
void dump_config() override; void dump_config() override;

View File

@@ -5,7 +5,7 @@
namespace esphome::shutdown { namespace esphome::shutdown {
class ShutdownSwitch : public switch_::Switch, public Component { class ShutdownSwitch final : public switch_::Switch, public Component {
public: public:
void dump_config() override; void dump_config() override;

View File

@@ -6,7 +6,7 @@
namespace esphome::sigma_delta_output { namespace esphome::sigma_delta_output {
class SigmaDeltaOutput : public PollingComponent, public output::FloatOutput { class SigmaDeltaOutput final : public PollingComponent, public output::FloatOutput {
public: public:
Trigger<> *get_turn_on_trigger() { Trigger<> *get_turn_on_trigger() {
if (!this->turn_on_trigger_) if (!this->turn_on_trigger_)

View File

@@ -46,7 +46,7 @@ enum State {
STATE_RECEIVED_USSD STATE_RECEIVED_USSD
}; };
class Sim800LComponent : public uart::UARTDevice, public PollingComponent { class Sim800LComponent final : public uart::UARTDevice, public PollingComponent {
public: public:
/// Retrieve the latest sensor values. This operation takes approximately 16ms. /// Retrieve the latest sensor values. This operation takes approximately 16ms.
void update() override; void update() override;
@@ -120,7 +120,7 @@ class Sim800LComponent : public uart::UARTDevice, public PollingComponent {
CallbackManager<void(std::string)> ussd_received_callback_; CallbackManager<void(std::string)> ussd_received_callback_;
}; };
template<typename... Ts> class Sim800LSendSmsAction : public Action<Ts...> { template<typename... Ts> class Sim800LSendSmsAction final : public Action<Ts...> {
public: public:
Sim800LSendSmsAction(Sim800LComponent *parent) : parent_(parent) {} Sim800LSendSmsAction(Sim800LComponent *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(std::string, recipient) TEMPLATABLE_VALUE(std::string, recipient)
@@ -136,7 +136,7 @@ template<typename... Ts> class Sim800LSendSmsAction : public Action<Ts...> {
Sim800LComponent *parent_; Sim800LComponent *parent_;
}; };
template<typename... Ts> class Sim800LSendUssdAction : public Action<Ts...> { template<typename... Ts> class Sim800LSendUssdAction final : public Action<Ts...> {
public: public:
Sim800LSendUssdAction(Sim800LComponent *parent) : parent_(parent) {} Sim800LSendUssdAction(Sim800LComponent *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(std::string, ussd) TEMPLATABLE_VALUE(std::string, ussd)
@@ -150,7 +150,7 @@ template<typename... Ts> class Sim800LSendUssdAction : public Action<Ts...> {
Sim800LComponent *parent_; Sim800LComponent *parent_;
}; };
template<typename... Ts> class Sim800LDialAction : public Action<Ts...> { template<typename... Ts> class Sim800LDialAction final : public Action<Ts...> {
public: public:
Sim800LDialAction(Sim800LComponent *parent) : parent_(parent) {} Sim800LDialAction(Sim800LComponent *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(std::string, recipient) TEMPLATABLE_VALUE(std::string, recipient)
@@ -163,7 +163,7 @@ template<typename... Ts> class Sim800LDialAction : public Action<Ts...> {
protected: protected:
Sim800LComponent *parent_; Sim800LComponent *parent_;
}; };
template<typename... Ts> class Sim800LConnectAction : public Action<Ts...> { template<typename... Ts> class Sim800LConnectAction final : public Action<Ts...> {
public: public:
Sim800LConnectAction(Sim800LComponent *parent) : parent_(parent) {} Sim800LConnectAction(Sim800LComponent *parent) : parent_(parent) {}
@@ -173,7 +173,7 @@ template<typename... Ts> class Sim800LConnectAction : public Action<Ts...> {
Sim800LComponent *parent_; Sim800LComponent *parent_;
}; };
template<typename... Ts> class Sim800LDisconnectAction : public Action<Ts...> { template<typename... Ts> class Sim800LDisconnectAction final : public Action<Ts...> {
public: public:
Sim800LDisconnectAction(Sim800LComponent *parent) : parent_(parent) {} Sim800LDisconnectAction(Sim800LComponent *parent) : parent_(parent) {}

View File

@@ -6,7 +6,7 @@
namespace esphome::slow_pwm { namespace esphome::slow_pwm {
class SlowPWMOutput : public output::FloatOutput, public Component { class SlowPWMOutput final : public output::FloatOutput, public Component {
public: public:
void set_pin(GPIOPin *pin) { pin_ = pin; }; void set_pin(GPIOPin *pin) { pin_ = pin; };
void set_period(unsigned int period) { period_ = period; }; void set_period(unsigned int period) { period_ = period; };