Mark user-configurable classes as final (part 17/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 17 of 21, split alphabetically by
component (ssd1351_spi .. tem3200).
This commit is contained in:
Jesse Hills
2026-06-15 13:22:16 +12:00
parent a25ac28ae5
commit 49d6718345
46 changed files with 99 additions and 97 deletions

View File

@@ -6,9 +6,9 @@
namespace esphome::ssd1351_spi { namespace esphome::ssd1351_spi {
class SPISSD1351 : public ssd1351_base::SSD1351, class SPISSD1351 final : public ssd1351_base::SSD1351,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH, spi::CLOCK_PHASE_TRAILING, public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH,
spi::DATA_RATE_8MHZ> { spi::CLOCK_PHASE_TRAILING, spi::DATA_RATE_8MHZ> {
public: public:
void set_dc_pin(GPIOPin *dc_pin) { dc_pin_ = dc_pin; } void set_dc_pin(GPIOPin *dc_pin) { dc_pin_ = dc_pin; }

View File

@@ -6,7 +6,7 @@
namespace esphome::st7567_i2c { namespace esphome::st7567_i2c {
class I2CST7567 : public st7567_base::ST7567, public i2c::I2CDevice { class I2CST7567 final : public st7567_base::ST7567, public i2c::I2CDevice {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -6,9 +6,9 @@
namespace esphome::st7567_spi { namespace esphome::st7567_spi {
class SPIST7567 : public st7567_base::ST7567, class SPIST7567 final : public st7567_base::ST7567,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH, spi::CLOCK_PHASE_TRAILING, public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH,
spi::DATA_RATE_8MHZ> { spi::CLOCK_PHASE_TRAILING, spi::DATA_RATE_8MHZ> {
public: public:
void set_dc_pin(GPIOPin *dc_pin) { dc_pin_ = dc_pin; } void set_dc_pin(GPIOPin *dc_pin) { dc_pin_ = dc_pin; }

View File

@@ -26,7 +26,7 @@ const uint8_t CMD2_BKSEL = 0xFF;
const uint8_t CMD2_BK0[5] = {0x77, 0x01, 0x00, 0x00, 0x10}; const uint8_t CMD2_BK0[5] = {0x77, 0x01, 0x00, 0x00, 0x10};
const uint8_t ST7701S_DELAY_FLAG = 0xFF; const uint8_t ST7701S_DELAY_FLAG = 0xFF;
class ST7701S : public display::Display, class ST7701S final : public display::Display,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING, public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING,
spi::DATA_RATE_1MHZ> { spi::DATA_RATE_1MHZ> {
public: public:

View File

@@ -31,7 +31,7 @@ enum ST7735Model {
ST7735_INITR_18REDTAB = INITR_18REDTAB ST7735_INITR_18REDTAB = INITR_18REDTAB
}; };
class ST7735 : public display::DisplayBuffer, class ST7735 final : public display::DisplayBuffer,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING, public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING,
spi::DATA_RATE_8MHZ> { spi::DATA_RATE_8MHZ> {
public: public:

View File

@@ -106,7 +106,7 @@ static const uint8_t ST7789_MADCTL_GS = 0x01;
static const uint8_t ST7789_MADCTL_COLOR_ORDER = ST7789_MADCTL_BGR; static const uint8_t ST7789_MADCTL_COLOR_ORDER = ST7789_MADCTL_BGR;
class ST7789V : public display::DisplayBuffer, class ST7789V final : public display::DisplayBuffer,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING, public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING,
spi::DATA_RATE_20MHZ> { spi::DATA_RATE_20MHZ> {
public: public:

View File

@@ -10,9 +10,9 @@ class ST7920;
using st7920_writer_t = display::DisplayWriter<ST7920>; using st7920_writer_t = display::DisplayWriter<ST7920>;
class ST7920 : public display::DisplayBuffer, class ST7920 final : public display::DisplayBuffer,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH, spi::CLOCK_PHASE_TRAILING, public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH,
spi::DATA_RATE_200KHZ> { spi::CLOCK_PHASE_TRAILING, spi::DATA_RATE_200KHZ> {
public: public:
void set_writer(st7920_writer_t &&writer) { this->writer_local_ = writer; } void set_writer(st7920_writer_t &&writer) { this->writer_local_ = writer; }
void set_height(uint16_t height) { this->height_ = height; } void set_height(uint16_t height) { this->height_ = height; }

View File

@@ -27,7 +27,7 @@
namespace esphome::statsd { namespace esphome::statsd {
class StatsdComponent : public PollingComponent { class StatsdComponent final : public PollingComponent {
public: public:
~StatsdComponent(); ~StatsdComponent();

View File

@@ -5,7 +5,7 @@
namespace esphome::status { namespace esphome::status {
class StatusBinarySensor : public binary_sensor::BinarySensor, public PollingComponent { class StatusBinarySensor final : public binary_sensor::BinarySensor, public PollingComponent {
public: public:
void update() override; void update() override;

View File

@@ -7,7 +7,7 @@
namespace esphome::status_led { namespace esphome::status_led {
class StatusLEDLightOutput : public light::LightOutput, public Component { class StatusLEDLightOutput final : public light::LightOutput, public Component {
public: public:
void set_pin(GPIOPin *pin) { pin_ = pin; } void set_pin(GPIOPin *pin) { pin_ = pin; }
void set_output(output::BinaryOutput *output) { output_ = output; } void set_output(output::BinaryOutput *output) { output_ = output; }

View File

@@ -5,7 +5,7 @@
namespace esphome::status_led { namespace esphome::status_led {
class StatusLED : public Component { class StatusLED final : public Component {
public: public:
explicit StatusLED(GPIOPin *pin); explicit StatusLED(GPIOPin *pin);

View File

@@ -37,7 +37,7 @@ class Stepper {
uint32_t last_step_{0}; uint32_t last_step_{0};
}; };
template<typename... Ts> class SetTargetAction : public Action<Ts...> { template<typename... Ts> class SetTargetAction final : public Action<Ts...> {
public: public:
explicit SetTargetAction(Stepper *parent) : parent_(parent) {} explicit SetTargetAction(Stepper *parent) : parent_(parent) {}
@@ -49,7 +49,7 @@ template<typename... Ts> class SetTargetAction : public Action<Ts...> {
Stepper *parent_; Stepper *parent_;
}; };
template<typename... Ts> class ReportPositionAction : public Action<Ts...> { template<typename... Ts> class ReportPositionAction final : public Action<Ts...> {
public: public:
explicit ReportPositionAction(Stepper *parent) : parent_(parent) {} explicit ReportPositionAction(Stepper *parent) : parent_(parent) {}
@@ -61,7 +61,7 @@ template<typename... Ts> class ReportPositionAction : public Action<Ts...> {
Stepper *parent_; Stepper *parent_;
}; };
template<typename... Ts> class SetSpeedAction : public Action<Ts...> { template<typename... Ts> class SetSpeedAction final : public Action<Ts...> {
public: public:
explicit SetSpeedAction(Stepper *parent) : parent_(parent) {} explicit SetSpeedAction(Stepper *parent) : parent_(parent) {}
@@ -77,7 +77,7 @@ template<typename... Ts> class SetSpeedAction : public Action<Ts...> {
Stepper *parent_; Stepper *parent_;
}; };
template<typename... Ts> class SetAccelerationAction : public Action<Ts...> { template<typename... Ts> class SetAccelerationAction final : public Action<Ts...> {
public: public:
explicit SetAccelerationAction(Stepper *parent) : parent_(parent) {} explicit SetAccelerationAction(Stepper *parent) : parent_(parent) {}
@@ -92,7 +92,7 @@ template<typename... Ts> class SetAccelerationAction : public Action<Ts...> {
Stepper *parent_; Stepper *parent_;
}; };
template<typename... Ts> class SetDecelerationAction : public Action<Ts...> { template<typename... Ts> class SetDecelerationAction final : public Action<Ts...> {
public: public:
explicit SetDecelerationAction(Stepper *parent) : parent_(parent) {} explicit SetDecelerationAction(Stepper *parent) : parent_(parent) {}

View File

@@ -9,7 +9,9 @@
namespace esphome::sts3x { namespace esphome::sts3x {
/// This class implements support for the ST3x-DIS family of temperature i2c sensors. /// This class implements support for the ST3x-DIS family of temperature i2c sensors.
class STS3XComponent : public sensor::Sensor, public PollingComponent, public sensirion_common::SensirionI2CDevice { class STS3XComponent final : public sensor::Sensor,
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::stts22h { namespace esphome::stts22h {
class STTS22HComponent : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice { class STTS22HComponent final : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
public: public:
void setup() override; void setup() override;
void update() override; void update() override;

View File

@@ -11,7 +11,7 @@ enum SensorType {
SUN_SENSOR_AZIMUTH, SUN_SENSOR_AZIMUTH,
}; };
class SunSensor : public sensor::Sensor, public PollingComponent { class SunSensor final : public sensor::Sensor, public PollingComponent {
public: public:
void set_parent(Sun *parent) { parent_ = parent; } void set_parent(Sun *parent) { parent_ = parent; }
void set_type(SensorType type) { type_ = type; } void set_type(SensorType type) { type_ = type; }

View File

@@ -51,7 +51,7 @@ struct HorizontalCoordinate {
} // namespace internal } // namespace internal
class Sun { class Sun final {
public: public:
void set_time(time::RealTimeClock *time) { time_ = time; } void set_time(time::RealTimeClock *time) { time_ = time; }
time::RealTimeClock *get_time() const { return time_; } time::RealTimeClock *get_time() const { return time_; }
@@ -78,7 +78,7 @@ class Sun {
internal::GeoLocation location_; internal::GeoLocation location_;
}; };
class SunTrigger : public Trigger<>, public PollingComponent, public Parented<Sun> { class SunTrigger final : public Trigger<>, public PollingComponent, public Parented<Sun> {
public: public:
SunTrigger() : PollingComponent(60000) {} SunTrigger() : PollingComponent(60000) {}
@@ -109,7 +109,7 @@ class SunTrigger : public Trigger<>, public PollingComponent, public Parented<Su
double elevation_; double elevation_;
}; };
template<typename... Ts> class SunCondition : public Condition<Ts...>, public Parented<Sun> { template<typename... Ts> class SunCondition final : public Condition<Ts...>, public Parented<Sun> {
public: public:
TEMPLATABLE_VALUE(double, elevation); TEMPLATABLE_VALUE(double, elevation);
void set_above(bool above) { above_ = above; } void set_above(bool above) { above_ = above; }

View File

@@ -8,7 +8,7 @@
namespace esphome::sun { namespace esphome::sun {
class SunTextSensor : public text_sensor::TextSensor, public PollingComponent { class SunTextSensor final : public text_sensor::TextSensor, public PollingComponent {
public: public:
void set_parent(Sun *parent) { parent_ = parent; } void set_parent(Sun *parent) { parent_ = parent; }
void set_elevation(double elevation) { elevation_ = elevation; } void set_elevation(double elevation) { elevation_ = elevation; }

View File

@@ -15,7 +15,7 @@
namespace esphome::sun_gtil2 { namespace esphome::sun_gtil2 {
class SunGTIL2 : public Component, public uart::UARTDevice { class SunGTIL2 final : public Component, public uart::UARTDevice {
public: public:
float get_setup_priority() const override { return setup_priority::LATE; } float get_setup_priority() const override { return setup_priority::LATE; }
void setup() override; void setup() override;

View File

@@ -6,7 +6,7 @@
namespace esphome::switch_ { namespace esphome::switch_ {
template<typename... Ts> class TurnOnAction : public Action<Ts...> { template<typename... Ts> class TurnOnAction final : public Action<Ts...> {
public: public:
explicit TurnOnAction(Switch *a_switch) : switch_(a_switch) {} explicit TurnOnAction(Switch *a_switch) : switch_(a_switch) {}
@@ -16,7 +16,7 @@ template<typename... Ts> class TurnOnAction : public Action<Ts...> {
Switch *switch_; Switch *switch_;
}; };
template<typename... Ts> class TurnOffAction : public Action<Ts...> { template<typename... Ts> class TurnOffAction final : public Action<Ts...> {
public: public:
explicit TurnOffAction(Switch *a_switch) : switch_(a_switch) {} explicit TurnOffAction(Switch *a_switch) : switch_(a_switch) {}
@@ -26,7 +26,7 @@ template<typename... Ts> class TurnOffAction : public Action<Ts...> {
Switch *switch_; Switch *switch_;
}; };
template<typename... Ts> class ToggleAction : public Action<Ts...> { template<typename... Ts> class ToggleAction final : public Action<Ts...> {
public: public:
explicit ToggleAction(Switch *a_switch) : switch_(a_switch) {} explicit ToggleAction(Switch *a_switch) : switch_(a_switch) {}
@@ -36,7 +36,7 @@ template<typename... Ts> class ToggleAction : public Action<Ts...> {
Switch *switch_; Switch *switch_;
}; };
template<typename... Ts> class ControlAction : public Action<Ts...> { template<typename... Ts> class ControlAction final : public Action<Ts...> {
public: public:
explicit ControlAction(Switch *a_switch) : switch_(a_switch) {} explicit ControlAction(Switch *a_switch) : switch_(a_switch) {}
@@ -53,7 +53,7 @@ template<typename... Ts> class ControlAction : public Action<Ts...> {
Switch *switch_; Switch *switch_;
}; };
template<typename... Ts> class SwitchCondition : public Condition<Ts...> { template<typename... Ts> class SwitchCondition final : public Condition<Ts...> {
public: public:
SwitchCondition(Switch *parent, bool state) : parent_(parent), state_(state) {} SwitchCondition(Switch *parent, bool state) : parent_(parent), state_(state) {}
bool check(const Ts &...x) override { return this->parent_->state == this->state_; } bool check(const Ts &...x) override { return this->parent_->state == this->state_; }
@@ -63,14 +63,14 @@ template<typename... Ts> class SwitchCondition : public Condition<Ts...> {
bool state_; bool state_;
}; };
class SwitchStateTrigger : public Trigger<bool> { class SwitchStateTrigger final : public Trigger<bool> {
public: public:
SwitchStateTrigger(Switch *a_switch) { SwitchStateTrigger(Switch *a_switch) {
a_switch->add_on_state_callback([this](bool state) { this->trigger(state); }); a_switch->add_on_state_callback([this](bool state) { this->trigger(state); });
} }
}; };
class SwitchTurnOnTrigger : public Trigger<> { class SwitchTurnOnTrigger final : public Trigger<> {
public: public:
SwitchTurnOnTrigger(Switch *a_switch) { SwitchTurnOnTrigger(Switch *a_switch) {
a_switch->add_on_state_callback([this](bool state) { a_switch->add_on_state_callback([this](bool state) {
@@ -81,7 +81,7 @@ class SwitchTurnOnTrigger : public Trigger<> {
} }
}; };
class SwitchTurnOffTrigger : public Trigger<> { class SwitchTurnOffTrigger final : public Trigger<> {
public: public:
SwitchTurnOffTrigger(Switch *a_switch) { SwitchTurnOffTrigger(Switch *a_switch) {
a_switch->add_on_state_callback([this](bool state) { a_switch->add_on_state_callback([this](bool state) {
@@ -92,7 +92,7 @@ class SwitchTurnOffTrigger : public Trigger<> {
} }
}; };
template<typename... Ts> class SwitchPublishAction : public Action<Ts...> { template<typename... Ts> class SwitchPublishAction final : public Action<Ts...> {
public: public:
SwitchPublishAction(Switch *a_switch) : switch_(a_switch) {} SwitchPublishAction(Switch *a_switch) : switch_(a_switch) {}
TEMPLATABLE_VALUE(bool, state) TEMPLATABLE_VALUE(bool, state)

View File

@@ -6,7 +6,7 @@
namespace esphome::switch_ { namespace esphome::switch_ {
class SwitchBinarySensor : public binary_sensor::BinarySensor, public Component { class SwitchBinarySensor final : public binary_sensor::BinarySensor, public Component {
public: public:
void set_source(Switch *source) { source_ = source; } void set_source(Switch *source) { source_ = source; }
void setup() override; void setup() override;

View File

@@ -6,12 +6,12 @@
namespace esphome::sx126x { namespace esphome::sx126x {
template<typename... Ts> class RunImageCalAction : public Action<Ts...>, public Parented<SX126x> { template<typename... Ts> class RunImageCalAction final : public Action<Ts...>, public Parented<SX126x> {
public: public:
void play(const Ts &...x) override { this->parent_->run_image_cal(); } void play(const Ts &...x) override { this->parent_->run_image_cal(); }
}; };
template<typename... Ts> class SendPacketAction : public Action<Ts...>, public Parented<SX126x> { template<typename... Ts> class SendPacketAction final : public Action<Ts...>, public Parented<SX126x> {
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;
@@ -43,23 +43,23 @@ template<typename... Ts> class SendPacketAction : public Action<Ts...>, public P
} data_; } data_;
}; };
template<typename... Ts> class SetModeTxAction : public Action<Ts...>, public Parented<SX126x> { template<typename... Ts> class SetModeTxAction final : public Action<Ts...>, public Parented<SX126x> {
public: public:
void play(const Ts &...x) override { this->parent_->set_mode_tx(); } void play(const Ts &...x) override { this->parent_->set_mode_tx(); }
}; };
template<typename... Ts> class SetModeRxAction : public Action<Ts...>, public Parented<SX126x> { template<typename... Ts> class SetModeRxAction final : public Action<Ts...>, public Parented<SX126x> {
public: public:
void play(const Ts &...x) override { this->parent_->set_mode_rx(); } void play(const Ts &...x) override { this->parent_->set_mode_rx(); }
}; };
template<typename... Ts> class SetModeSleepAction : public Action<Ts...>, public Parented<SX126x> { template<typename... Ts> class SetModeSleepAction final : public Action<Ts...>, public Parented<SX126x> {
public: public:
TEMPLATABLE_VALUE(bool, cold) TEMPLATABLE_VALUE(bool, cold)
void play(const Ts &...x) override { this->parent_->set_mode_sleep(this->cold_.value(x...)); } void play(const Ts &...x) override { this->parent_->set_mode_sleep(this->cold_.value(x...)); }
}; };
template<typename... Ts> class SetModeStandbyAction : public Action<Ts...>, public Parented<SX126x> { template<typename... Ts> class SetModeStandbyAction final : public Action<Ts...>, public Parented<SX126x> {
public: public:
void play(const Ts &...x) override { this->parent_->set_mode_standby(STDBY_XOSC); } void play(const Ts &...x) override { this->parent_->set_mode_standby(STDBY_XOSC); }
}; };

View File

@@ -7,7 +7,7 @@
namespace esphome::sx126x { namespace esphome::sx126x {
class SX126xTransport : public packet_transport::PacketTransport, public Parented<SX126x>, public SX126xListener { class SX126xTransport final : public packet_transport::PacketTransport, public Parented<SX126x>, public SX126xListener {
public: public:
void setup() override; void setup() override;
void on_packet(const std::vector<uint8_t> &packet, float rssi, float snr) override; void on_packet(const std::vector<uint8_t> &packet, float rssi, float snr) override;

View File

@@ -53,7 +53,7 @@ class SX126xListener {
virtual void on_packet(const std::vector<uint8_t> &packet, float rssi, float snr) = 0; virtual void on_packet(const std::vector<uint8_t> &packet, float rssi, float snr) = 0;
}; };
class SX126x : public Component, class SX126x final : public Component,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING, public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING,
spi::DATA_RATE_8MHZ> { spi::DATA_RATE_8MHZ> {
public: public:

View File

@@ -6,12 +6,12 @@
namespace esphome::sx127x { namespace esphome::sx127x {
template<typename... Ts> class RunImageCalAction : public Action<Ts...>, public Parented<SX127x> { template<typename... Ts> class RunImageCalAction final : public Action<Ts...>, public Parented<SX127x> {
public: public:
void play(const Ts &...x) override { this->parent_->run_image_cal(); } void play(const Ts &...x) override { this->parent_->run_image_cal(); }
}; };
template<typename... Ts> class SendPacketAction : public Action<Ts...>, public Parented<SX127x> { template<typename... Ts> class SendPacketAction final : public Action<Ts...>, public Parented<SX127x> {
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;
@@ -43,22 +43,22 @@ template<typename... Ts> class SendPacketAction : public Action<Ts...>, public P
} data_; } data_;
}; };
template<typename... Ts> class SetModeTxAction : public Action<Ts...>, public Parented<SX127x> { template<typename... Ts> class SetModeTxAction final : public Action<Ts...>, public Parented<SX127x> {
public: public:
void play(const Ts &...x) override { this->parent_->set_mode_tx(); } void play(const Ts &...x) override { this->parent_->set_mode_tx(); }
}; };
template<typename... Ts> class SetModeRxAction : public Action<Ts...>, public Parented<SX127x> { template<typename... Ts> class SetModeRxAction final : public Action<Ts...>, public Parented<SX127x> {
public: public:
void play(const Ts &...x) override { this->parent_->set_mode_rx(); } void play(const Ts &...x) override { this->parent_->set_mode_rx(); }
}; };
template<typename... Ts> class SetModeSleepAction : public Action<Ts...>, public Parented<SX127x> { template<typename... Ts> class SetModeSleepAction final : public Action<Ts...>, public Parented<SX127x> {
public: public:
void play(const Ts &...x) override { this->parent_->set_mode_sleep(); } void play(const Ts &...x) override { this->parent_->set_mode_sleep(); }
}; };
template<typename... Ts> class SetModeStandbyAction : public Action<Ts...>, public Parented<SX127x> { template<typename... Ts> class SetModeStandbyAction final : public Action<Ts...>, public Parented<SX127x> {
public: public:
void play(const Ts &...x) override { this->parent_->set_mode_standby(); } void play(const Ts &...x) override { this->parent_->set_mode_standby(); }
}; };

View File

@@ -7,7 +7,7 @@
namespace esphome::sx127x { namespace esphome::sx127x {
class SX127xTransport : public packet_transport::PacketTransport, public Parented<SX127x>, public SX127xListener { class SX127xTransport final : public packet_transport::PacketTransport, public Parented<SX127x>, public SX127xListener {
public: public:
void setup() override; void setup() override;
void on_packet(const std::vector<uint8_t> &packet, float rssi, float snr) override; void on_packet(const std::vector<uint8_t> &packet, float rssi, float snr) override;

View File

@@ -41,7 +41,7 @@ class SX127xListener {
virtual void on_packet(const std::vector<uint8_t> &packet, float rssi, float snr) = 0; virtual void on_packet(const std::vector<uint8_t> &packet, float rssi, float snr) = 0;
}; };
class SX127x : public Component, class SX127x final : public Component,
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING, public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW, spi::CLOCK_PHASE_LEADING,
spi::DATA_RATE_8MHZ> { spi::DATA_RATE_8MHZ> {
public: public:

View File

@@ -5,7 +5,7 @@
namespace esphome::sx1509 { namespace esphome::sx1509 {
class SX1509BinarySensor : public sx1509::SX1509Processor, public binary_sensor::BinarySensor { class SX1509BinarySensor final : public sx1509::SX1509Processor, public binary_sensor::BinarySensor {
public: public:
void set_row_col(uint8_t row, uint8_t col) { this->key_ = (1 << (col + 8)) | (1 << row); } void set_row_col(uint8_t row, uint8_t col) { this->key_ = (1 << (col + 8)) | (1 << row); }
void process(uint16_t data) override { this->publish_state(static_cast<bool>(data == key_)); } void process(uint16_t data) override { this->publish_state(static_cast<bool>(data == key_)); }

View File

@@ -7,7 +7,7 @@ namespace esphome::sx1509 {
class SX1509Component; class SX1509Component;
class SX1509FloatOutputChannel : public output::FloatOutput, public Component { class SX1509FloatOutputChannel final : public output::FloatOutput, public Component {
public: public:
void set_parent(SX1509Component *parent) { this->parent_ = parent; } void set_parent(SX1509Component *parent) { this->parent_ = parent; }
void set_pin(uint8_t pin) { pin_ = pin; } void set_pin(uint8_t pin) { pin_ = pin; }

View File

@@ -28,9 +28,9 @@ class SX1509Processor {
virtual void process(uint16_t data){}; virtual void process(uint16_t data){};
}; };
class SX1509KeyTrigger : public Trigger<uint8_t> {}; class SX1509KeyTrigger final : public Trigger<uint8_t> {};
class SX1509Component : public Component, class SX1509Component final : public Component,
public i2c::I2CDevice, public i2c::I2CDevice,
public gpio_expander::CachedGpioExpander<uint16_t, 16>, public gpio_expander::CachedGpioExpander<uint16_t, 16>,
public key_provider::KeyProvider { public key_provider::KeyProvider {

View File

@@ -6,7 +6,7 @@ namespace esphome::sx1509 {
class SX1509Component; class SX1509Component;
class SX1509GPIOPin : public GPIOPin { class SX1509GPIOPin final : public GPIOPin {
public: public:
void setup() override; void setup() override;
void pin_mode(gpio::Flags flags) override; void pin_mode(gpio::Flags flags) override;

View File

@@ -6,7 +6,7 @@
namespace esphome::sy6970 { namespace esphome::sy6970 {
template<uint8_t REG, uint8_t SHIFT, uint8_t MASK, uint8_t TRUE_VALUE> template<uint8_t REG, uint8_t SHIFT, uint8_t MASK, uint8_t TRUE_VALUE>
class StatusBinarySensor : public SY6970Listener, public binary_sensor::BinarySensor { class StatusBinarySensor final : public SY6970Listener, public binary_sensor::BinarySensor {
public: public:
void on_data(const SY6970Data &data) override { void on_data(const SY6970Data &data) override {
uint8_t value = (data.registers[REG] >> SHIFT) & MASK; uint8_t value = (data.registers[REG] >> SHIFT) & MASK;
@@ -24,7 +24,7 @@ class InverseStatusBinarySensor : public SY6970Listener, public binary_sensor::B
}; };
// Custom binary sensor for charging (true when pre-charge or fast charge) // Custom binary sensor for charging (true when pre-charge or fast charge)
class SY6970ChargingBinarySensor : public SY6970Listener, public binary_sensor::BinarySensor { class SY6970ChargingBinarySensor final : public SY6970Listener, public binary_sensor::BinarySensor {
public: public:
void on_data(const SY6970Data &data) override { void on_data(const SY6970Data &data) override {
uint8_t chrg_stat = (data.registers[SY6970_REG_STATUS] >> 3) & 0x03; uint8_t chrg_stat = (data.registers[SY6970_REG_STATUS] >> 3) & 0x03;

View File

@@ -34,7 +34,7 @@ using SY6970SystemVoltageSensor = VoltageSensor<SY6970_REG_VINDPM_STATUS, 0x7F,
using SY6970ChargeCurrentSensor = CurrentSensor<SY6970_REG_CHARGE_CURRENT_MONITOR, 0x7F, 0, CHG_CURRENT_STEP_MA>; using SY6970ChargeCurrentSensor = CurrentSensor<SY6970_REG_CHARGE_CURRENT_MONITOR, 0x7F, 0, CHG_CURRENT_STEP_MA>;
// Precharge current sensor needs special handling (bit shift) // Precharge current sensor needs special handling (bit shift)
class SY6970PrechargeCurrentSensor : public SY6970Listener, public sensor::Sensor { class SY6970PrechargeCurrentSensor final : public SY6970Listener, public sensor::Sensor {
public: public:
void on_data(const SY6970Data &data) override { void on_data(const SY6970Data &data) override {
uint8_t iprechg = (data.registers[SY6970_REG_PRECHARGE_CURRENT] >> 4) & 0x0F; uint8_t iprechg = (data.registers[SY6970_REG_PRECHARGE_CURRENT] >> 4) & 0x0F;

View File

@@ -73,7 +73,7 @@ class SY6970Listener {
virtual void on_data(const SY6970Data &data) = 0; virtual void on_data(const SY6970Data &data) = 0;
}; };
class SY6970Component : public PollingComponent, public i2c::I2CDevice { class SY6970Component final : public PollingComponent, public i2c::I2CDevice {
public: public:
SY6970Component(bool led_enabled, uint16_t input_current_limit, uint16_t charge_voltage, uint16_t charge_current, SY6970Component(bool led_enabled, uint16_t input_current_limit, uint16_t charge_voltage, uint16_t charge_current,
uint16_t precharge_current, bool charge_enabled, bool enable_adc) uint16_t precharge_current, bool charge_enabled, bool enable_adc)

View File

@@ -6,7 +6,7 @@
namespace esphome::sy6970 { namespace esphome::sy6970 {
// Bus status text sensor // Bus status text sensor
class SY6970BusStatusTextSensor : public SY6970Listener, public text_sensor::TextSensor { class SY6970BusStatusTextSensor final : public SY6970Listener, public text_sensor::TextSensor {
public: public:
void on_data(const SY6970Data &data) override { void on_data(const SY6970Data &data) override {
uint8_t status = (data.registers[SY6970_REG_STATUS] >> 5) & 0x07; uint8_t status = (data.registers[SY6970_REG_STATUS] >> 5) & 0x07;
@@ -40,7 +40,7 @@ class SY6970BusStatusTextSensor : public SY6970Listener, public text_sensor::Tex
}; };
// Charge status text sensor // Charge status text sensor
class SY6970ChargeStatusTextSensor : public SY6970Listener, public text_sensor::TextSensor { class SY6970ChargeStatusTextSensor final : public SY6970Listener, public text_sensor::TextSensor {
public: public:
void on_data(const SY6970Data &data) override { void on_data(const SY6970Data &data) override {
uint8_t status = (data.registers[SY6970_REG_STATUS] >> 3) & 0x03; uint8_t status = (data.registers[SY6970_REG_STATUS] >> 3) & 0x03;
@@ -66,7 +66,7 @@ class SY6970ChargeStatusTextSensor : public SY6970Listener, public text_sensor::
}; };
// NTC status text sensor // NTC status text sensor
class SY6970NtcStatusTextSensor : public SY6970Listener, public text_sensor::TextSensor { class SY6970NtcStatusTextSensor final : public SY6970Listener, public text_sensor::TextSensor {
public: public:
void on_data(const SY6970Data &data) override { void on_data(const SY6970Data &data) override {
uint8_t status = data.registers[SY6970_REG_FAULT] & 0x07; uint8_t status = data.registers[SY6970_REG_FAULT] & 0x07;

View File

@@ -7,7 +7,7 @@
#ifdef USE_NETWORK #ifdef USE_NETWORK
namespace esphome::syslog { namespace esphome::syslog {
class Syslog : public Component, public Parented<udp::UDPComponent> { class Syslog final : public Component, public Parented<udp::UDPComponent> {
public: public:
Syslog(int level, time::RealTimeClock *time) : log_level_(level), time_(time) {} Syslog(int level, time::RealTimeClock *time) : log_level_(level), time_(time) {}
void setup() override; void setup() override;

View File

@@ -19,7 +19,7 @@ enum class T6615Command : uint8_t {
SET_ELEVATION, SET_ELEVATION,
}; };
class T6615Component : public PollingComponent, public uart::UARTDevice { class T6615Component final : public PollingComponent, public uart::UARTDevice {
public: public:
void loop() override; void loop() override;
void update() override; void update() override;

View File

@@ -6,7 +6,7 @@
namespace esphome::tc74 { namespace esphome::tc74 {
class TC74Component : public PollingComponent, public i2c::I2CDevice, public sensor::Sensor { class TC74Component final : public PollingComponent, public i2c::I2CDevice, public sensor::Sensor {
public: public:
/// Setup the sensor and check connection. /// Setup the sensor and check connection.
void setup() override; void setup() override;

View File

@@ -8,7 +8,7 @@ namespace esphome::tca9548a {
static const uint8_t TCA9548A_DISABLE_CHANNELS_COMMAND = 0x00; static const uint8_t TCA9548A_DISABLE_CHANNELS_COMMAND = 0x00;
class TCA9548AComponent; class TCA9548AComponent;
class TCA9548AChannel : public i2c::I2CBus { class TCA9548AChannel final : public i2c::I2CBus {
public: public:
void set_channel(uint8_t channel) { channel_ = channel; } void set_channel(uint8_t channel) { channel_ = channel; }
void set_parent(TCA9548AComponent *parent) { parent_ = parent; } void set_parent(TCA9548AComponent *parent) { parent_ = parent; }
@@ -21,7 +21,7 @@ class TCA9548AChannel : public i2c::I2CBus {
TCA9548AComponent *parent_; TCA9548AComponent *parent_;
}; };
class TCA9548AComponent : public Component, public i2c::I2CDevice { class TCA9548AComponent final : public Component, public i2c::I2CDevice {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -7,7 +7,7 @@
namespace esphome::tca9555 { namespace esphome::tca9555 {
class TCA9555Component : public Component, class TCA9555Component final : public Component,
public i2c::I2CDevice, public i2c::I2CDevice,
public gpio_expander::CachedGpioExpander<uint8_t, 16> { public gpio_expander::CachedGpioExpander<uint8_t, 16> {
public: public:
@@ -47,7 +47,7 @@ class TCA9555Component : public Component,
}; };
/// Helper class to expose a TCA9555 pin as an internal input GPIO pin. /// Helper class to expose a TCA9555 pin as an internal input GPIO pin.
class TCA9555GPIOPin : public GPIOPin, public Parented<TCA9555Component> { class TCA9555GPIOPin final : public GPIOPin, public Parented<TCA9555Component> {
public: public:
void setup() override; void setup() override;
void pin_mode(gpio::Flags flags) override; void pin_mode(gpio::Flags flags) override;

View File

@@ -8,7 +8,7 @@ namespace esphome::tcl112 {
const float TCL112_TEMP_MAX = 31.0; const float TCL112_TEMP_MAX = 31.0;
const float TCL112_TEMP_MIN = 16.0; const float TCL112_TEMP_MIN = 16.0;
class Tcl112Climate : public climate_ir::ClimateIR { class Tcl112Climate final : public climate_ir::ClimateIR {
public: public:
Tcl112Climate() Tcl112Climate()
: climate_ir::ClimateIR(TCL112_TEMP_MIN, TCL112_TEMP_MAX, .5f, true, true, : climate_ir::ClimateIR(TCL112_TEMP_MIN, TCL112_TEMP_MAX, .5f, true, true,

View File

@@ -35,7 +35,7 @@ enum TCS34725Gain {
TCS34725_GAIN_60X = 0x03, TCS34725_GAIN_60X = 0x03,
}; };
class TCS34725Component : public PollingComponent, public i2c::I2CDevice { class TCS34725Component final : public PollingComponent, public i2c::I2CDevice {
public: public:
void set_integration_time(TCS34725IntegrationTime integration_time); void set_integration_time(TCS34725IntegrationTime integration_time);
void set_gain(TCS34725Gain gain); void set_gain(TCS34725Gain gain);

View File

@@ -7,7 +7,7 @@
namespace esphome::tee501 { namespace esphome::tee501 {
/// This class implements support for the tee501 of temperature i2c sensors. /// This class implements support for the tee501 of temperature i2c sensors.
class TEE501Component : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice { class TEE501Component 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

@@ -4,7 +4,7 @@
namespace esphome::teleinfo { namespace esphome::teleinfo {
class TeleInfoSensor : public TeleInfoListener, public sensor::Sensor, public Component { class TeleInfoSensor final : public TeleInfoListener, public sensor::Sensor, public Component {
public: public:
TeleInfoSensor(const char *tag); TeleInfoSensor(const char *tag);
void publish_val(const std::string &val) override; void publish_val(const std::string &val) override;

View File

@@ -20,7 +20,7 @@ class TeleInfoListener {
std::string tag; std::string tag;
virtual void publish_val(const std::string &val){}; virtual void publish_val(const std::string &val){};
}; };
class TeleInfo : public PollingComponent, public uart::UARTDevice { class TeleInfo final : public PollingComponent, public uart::UARTDevice {
public: public:
TeleInfo(bool historical_mode); TeleInfo(bool historical_mode);
void register_teleinfo_listener(TeleInfoListener *listener); void register_teleinfo_listener(TeleInfoListener *listener);

View File

@@ -3,7 +3,7 @@
#include "esphome/components/text_sensor/text_sensor.h" #include "esphome/components/text_sensor/text_sensor.h"
namespace esphome::teleinfo { namespace esphome::teleinfo {
class TeleInfoTextSensor : public TeleInfoListener, public text_sensor::TextSensor, public Component { class TeleInfoTextSensor final : public TeleInfoListener, public text_sensor::TextSensor, public Component {
public: public:
TeleInfoTextSensor(const char *tag); TeleInfoTextSensor(const char *tag);
void publish_val(const std::string &val) override; void publish_val(const std::string &val) override;

View File

@@ -7,7 +7,7 @@
namespace esphome::tem3200 { namespace esphome::tem3200 {
/// This class implements support for the tem3200 pressure and temperature i2c sensors. /// This class implements support for the tem3200 pressure and temperature i2c sensors.
class TEM3200Component : public PollingComponent, public i2c::I2CDevice { class TEM3200Component final : public PollingComponent, public i2c::I2CDevice {
public: public:
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { this->temperature_sensor_ = temperature_sensor; } void set_temperature_sensor(sensor::Sensor *temperature_sensor) { this->temperature_sensor_ = temperature_sensor; }
void set_raw_pressure_sensor(sensor::Sensor *raw_pressure_sensor) { void set_raw_pressure_sensor(sensor::Sensor *raw_pressure_sensor) {