Mark user-configurable classes as final (part 11/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 11 of 21, split alphabetically by
component (microphone .. ms8607).
This commit is contained in:
Jesse Hills
2026-06-15 13:20:47 +12:00
parent a25ac28ae5
commit 5bb8a6a996
62 changed files with 95 additions and 93 deletions

View File

@@ -7,22 +7,22 @@
namespace esphome::micro_wake_word { namespace esphome::micro_wake_word {
template<typename... Ts> class StartAction : public Action<Ts...>, public Parented<MicroWakeWord> { template<typename... Ts> class StartAction final : public Action<Ts...>, public Parented<MicroWakeWord> {
public: public:
void play(const Ts &...x) override { this->parent_->start(); } void play(const Ts &...x) override { this->parent_->start(); }
}; };
template<typename... Ts> class StopAction : public Action<Ts...>, public Parented<MicroWakeWord> { template<typename... Ts> class StopAction final : public Action<Ts...>, public Parented<MicroWakeWord> {
public: public:
void play(const Ts &...x) override { this->parent_->stop(); } void play(const Ts &...x) override { this->parent_->stop(); }
}; };
template<typename... Ts> class IsRunningCondition : public Condition<Ts...>, public Parented<MicroWakeWord> { template<typename... Ts> class IsRunningCondition final : public Condition<Ts...>, public Parented<MicroWakeWord> {
public: public:
bool check(const Ts &...x) override { return this->parent_->is_running(); } bool check(const Ts &...x) override { return this->parent_->is_running(); }
}; };
template<typename... Ts> class EnableModelAction : public Action<Ts...> { template<typename... Ts> class EnableModelAction final : public Action<Ts...> {
public: public:
explicit EnableModelAction(WakeWordModel *wake_word_model) : wake_word_model_(wake_word_model) {} explicit EnableModelAction(WakeWordModel *wake_word_model) : wake_word_model_(wake_word_model) {}
void play(const Ts &...x) override { this->wake_word_model_->enable(); } void play(const Ts &...x) override { this->wake_word_model_->enable(); }
@@ -31,7 +31,7 @@ template<typename... Ts> class EnableModelAction : public Action<Ts...> {
WakeWordModel *wake_word_model_; WakeWordModel *wake_word_model_;
}; };
template<typename... Ts> class DisableModelAction : public Action<Ts...> { template<typename... Ts> class DisableModelAction final : public Action<Ts...> {
public: public:
explicit DisableModelAction(WakeWordModel *wake_word_model) : wake_word_model_(wake_word_model) {} explicit DisableModelAction(WakeWordModel *wake_word_model) : wake_word_model_(wake_word_model) {}
void play(const Ts &...x) override { this->wake_word_model_->disable(); } void play(const Ts &...x) override { this->wake_word_model_->disable(); }
@@ -40,7 +40,7 @@ template<typename... Ts> class DisableModelAction : public Action<Ts...> {
WakeWordModel *wake_word_model_; WakeWordModel *wake_word_model_;
}; };
template<typename... Ts> class ModelIsEnabledCondition : public Condition<Ts...> { template<typename... Ts> class ModelIsEnabledCondition final : public Condition<Ts...> {
public: public:
explicit ModelIsEnabledCondition(WakeWordModel *wake_word_model) : wake_word_model_(wake_word_model) {} explicit ModelIsEnabledCondition(WakeWordModel *wake_word_model) : wake_word_model_(wake_word_model) {}
bool check(const Ts &...x) override { return this->wake_word_model_->is_enabled(); } bool check(const Ts &...x) override { return this->wake_word_model_->is_enabled(); }

View File

@@ -31,10 +31,10 @@ enum State {
STOPPED, STOPPED,
}; };
class MicroWakeWord : public Component class MicroWakeWord final : public Component
#ifdef USE_OTA_STATE_LISTENER #ifdef USE_OTA_STATE_LISTENER
, ,
public ota::OTAGlobalStateListener public ota::OTAGlobalStateListener
#endif #endif
{ {
public: public:

View File

@@ -7,34 +7,34 @@
namespace esphome::microphone { namespace esphome::microphone {
template<typename... Ts> class CaptureAction : public Action<Ts...>, public Parented<Microphone> { template<typename... Ts> class CaptureAction final : public Action<Ts...>, public Parented<Microphone> {
void play(const Ts &...x) override { this->parent_->start(); } void play(const Ts &...x) override { this->parent_->start(); }
}; };
template<typename... Ts> class StopCaptureAction : public Action<Ts...>, public Parented<Microphone> { template<typename... Ts> class StopCaptureAction final : public Action<Ts...>, public Parented<Microphone> {
void play(const Ts &...x) override { this->parent_->stop(); } void play(const Ts &...x) override { this->parent_->stop(); }
}; };
template<typename... Ts> class MuteAction : public Action<Ts...>, public Parented<Microphone> { template<typename... Ts> class MuteAction final : public Action<Ts...>, public Parented<Microphone> {
void play(const Ts &...x) override { this->parent_->set_mute_state(true); } void play(const Ts &...x) override { this->parent_->set_mute_state(true); }
}; };
template<typename... Ts> class UnmuteAction : public Action<Ts...>, public Parented<Microphone> { template<typename... Ts> class UnmuteAction final : public Action<Ts...>, public Parented<Microphone> {
void play(const Ts &...x) override { this->parent_->set_mute_state(false); } void play(const Ts &...x) override { this->parent_->set_mute_state(false); }
}; };
class DataTrigger : public Trigger<const std::vector<uint8_t> &> { class DataTrigger final : public Trigger<const std::vector<uint8_t> &> {
public: public:
explicit DataTrigger(Microphone *mic) { explicit DataTrigger(Microphone *mic) {
mic->add_data_callback([this](const std::vector<uint8_t> &data) { this->trigger(data); }); mic->add_data_callback([this](const std::vector<uint8_t> &data) { this->trigger(data); });
} }
}; };
template<typename... Ts> class IsCapturingCondition : public Condition<Ts...>, public Parented<Microphone> { template<typename... Ts> class IsCapturingCondition final : public Condition<Ts...>, public Parented<Microphone> {
public: public:
bool check(const Ts &...x) override { return this->parent_->is_running(); } bool check(const Ts &...x) override { return this->parent_->is_running(); }
}; };
template<typename... Ts> class IsMutedCondition : public Condition<Ts...>, public Parented<Microphone> { template<typename... Ts> class IsMutedCondition final : public Condition<Ts...>, public Parented<Microphone> {
public: public:
bool check(const Ts &...x) override { return this->parent_->get_mute_state(); } bool check(const Ts &...x) override { return this->parent_->get_mute_state(); }
}; };

View File

@@ -13,7 +13,7 @@ namespace esphome::microphone {
static const int32_t MAX_GAIN_FACTOR = 64; static const int32_t MAX_GAIN_FACTOR = 64;
class MicrophoneSource { class MicrophoneSource final {
/* /*
* @brief Helper class that handles converting raw microphone data to a requested format. * @brief Helper class that handles converting raw microphone data to a requested format.
* Components requesting microphone audio should register a callback through this class instead of registering a * Components requesting microphone audio should register a callback through this class instead of registering a

View File

@@ -7,7 +7,7 @@
namespace esphome::mics_4514 { namespace esphome::mics_4514 {
class MICS4514Component : public PollingComponent, public i2c::I2CDevice { class MICS4514Component final : public PollingComponent, public i2c::I2CDevice {
SUB_SENSOR(carbon_monoxide) SUB_SENSOR(carbon_monoxide)
SUB_SENSOR(nitrogen_dioxide) SUB_SENSOR(nitrogen_dioxide)
SUB_SENSOR(methane) SUB_SENSOR(methane)

View File

@@ -21,7 +21,7 @@ using climate::ClimateModeMask;
using climate::ClimateSwingModeMask; using climate::ClimateSwingModeMask;
using climate::ClimatePresetMask; using climate::ClimatePresetMask;
class AirConditioner : public ApplianceBase<dudanov::midea::ac::AirConditioner>, public climate::Climate { class AirConditioner final : public ApplianceBase<dudanov::midea::ac::AirConditioner>, public climate::Climate {
public: public:
void dump_config() override; void dump_config() override;
void set_outdoor_temperature_sensor(Sensor *sensor) { this->outdoor_sensor_ = sensor; } void set_outdoor_temperature_sensor(Sensor *sensor) { this->outdoor_sensor_ = sensor; }

View File

@@ -11,7 +11,7 @@ const uint8_t MIDEA_TEMPC_MAX = 30; // Celsius
const uint8_t MIDEA_TEMPF_MIN = 62; // Fahrenheit const uint8_t MIDEA_TEMPF_MIN = 62; // Fahrenheit
const uint8_t MIDEA_TEMPF_MAX = 86; // Fahrenheit const uint8_t MIDEA_TEMPF_MAX = 86; // Fahrenheit
class MideaIR : public climate_ir::ClimateIR { class MideaIR final : public climate_ir::ClimateIR {
public: public:
MideaIR() MideaIR()
: climate_ir::ClimateIR( : climate_ir::ClimateIR(

View File

@@ -35,7 +35,7 @@ const uint8_t MADCTL_MV = 0x20; // row/column swap
const uint8_t MADCTL_XFLIP = 0x02; // Mirror the display horizontally const uint8_t MADCTL_XFLIP = 0x02; // Mirror the display horizontally
const uint8_t MADCTL_YFLIP = 0x01; // Mirror the display vertically const uint8_t MADCTL_YFLIP = 0x01; // Mirror the display vertically
class MipiDsi : public display::Display { class MipiDsi final : public display::Display {
public: public:
MipiDsi(size_t width, size_t height, display::ColorBitness color_depth, uint8_t pixel_mode) MipiDsi(size_t width, size_t height, display::ColorBitness color_depth, uint8_t pixel_mode)
: width_(width), height_(height), color_depth_(color_depth), pixel_mode_(pixel_mode) {} : width_(width), height_(height), color_depth_(color_depth), pixel_mode_(pixel_mode) {}

View File

@@ -98,9 +98,9 @@ class MipiRgb : public display::Display {
}; };
#ifdef USE_SPI #ifdef USE_SPI
class MipiRgbSpi : public MipiRgb, class MipiRgbSpi final : public MipiRgb,
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::DATA_RATE_1MHZ> { spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_1MHZ> {
public: public:
MipiRgbSpi(int width, int height) : MipiRgb(width, height) {} MipiRgbSpi(int width, int height) : MipiRgb(width, height) {}

View File

@@ -38,7 +38,7 @@ enum VerticalDirection {
VERTICAL_DIRECTION_DOWN = 0x28, VERTICAL_DIRECTION_DOWN = 0x28,
}; };
class MitsubishiClimate : public climate_ir::ClimateIR { class MitsubishiClimate final : public climate_ir::ClimateIR {
public: public:
MitsubishiClimate() MitsubishiClimate()
: climate_ir::ClimateIR(MITSUBISHI_TEMP_MIN, MITSUBISHI_TEMP_MAX, 1.0f, true, true, : climate_ir::ClimateIR(MITSUBISHI_TEMP_MIN, MITSUBISHI_TEMP_MAX, 1.0f, true, true,

View File

@@ -8,7 +8,7 @@
namespace esphome::mitsubishi_cn105 { namespace esphome::mitsubishi_cn105 {
class MitsubishiCN105Climate : public climate::Climate, public Component, public uart::UARTDevice { class MitsubishiCN105Climate final : public climate::Climate, public Component, public uart::UARTDevice {
public: public:
explicit MitsubishiCN105Climate() : hp_(*this) {} explicit MitsubishiCN105Climate() : hp_(*this) {}
@@ -37,7 +37,7 @@ class MitsubishiCN105Climate : public climate::Climate, public Component, public
}; };
template<typename... Ts> template<typename... Ts>
class SetRemoteTemperatureAction : public Action<Ts...>, public Parented<MitsubishiCN105Climate> { class SetRemoteTemperatureAction final : public Action<Ts...>, public Parented<MitsubishiCN105Climate> {
public: public:
TEMPLATABLE_VALUE(float, temperature) TEMPLATABLE_VALUE(float, temperature)
@@ -45,7 +45,7 @@ class SetRemoteTemperatureAction : public Action<Ts...>, public Parented<Mitsubi
}; };
template<typename... Ts> template<typename... Ts>
class ClearRemoteTemperatureAction : public Action<Ts...>, public Parented<MitsubishiCN105Climate> { class ClearRemoteTemperatureAction final : public Action<Ts...>, public Parented<MitsubishiCN105Climate> {
public: public:
void play(const Ts &...x) override { this->parent_->clear_remote_temperature(); } void play(const Ts &...x) override { this->parent_->clear_remote_temperature(); }
}; };

View File

@@ -6,7 +6,7 @@
#ifdef USE_ESP32 #ifdef USE_ESP32
namespace esphome::mixer_speaker { namespace esphome::mixer_speaker {
template<typename... Ts> class DuckingApplyAction : public Action<Ts...>, public Parented<SourceSpeaker> { template<typename... Ts> class DuckingApplyAction final : public Action<Ts...>, public Parented<SourceSpeaker> {
TEMPLATABLE_VALUE(uint8_t, decibel_reduction); TEMPLATABLE_VALUE(uint8_t, decibel_reduction);
TEMPLATABLE_VALUE(uint32_t, duration); TEMPLATABLE_VALUE(uint32_t, duration);
void play(const Ts &...x) override { void play(const Ts &...x) override {

View File

@@ -44,7 +44,7 @@ namespace esphome::mixer_speaker {
class MixerSpeaker; class MixerSpeaker;
class SourceSpeaker : public speaker::Speaker, public Component { class SourceSpeaker final : public speaker::Speaker, public Component {
public: public:
void dump_config() override; void dump_config() override;
void setup() override; void setup() override;
@@ -118,7 +118,7 @@ class SourceSpeaker : public speaker::Speaker, public Component {
uint32_t stopping_start_ms_{0}; uint32_t stopping_start_ms_{0};
}; };
class MixerSpeaker : public Component { class MixerSpeaker final : public Component {
public: public:
void dump_config() override; void dump_config() override;
void setup() override; void setup() override;

View File

@@ -20,7 +20,7 @@ enum MLX90393Setting {
MLX90393_LAST, MLX90393_LAST,
}; };
class MLX90393Cls : public PollingComponent, public i2c::I2CDevice, public MLX90393Hal { class MLX90393Cls final : public PollingComponent, public i2c::I2CDevice, public MLX90393Hal {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -6,7 +6,7 @@
namespace esphome::mlx90614 { namespace esphome::mlx90614 {
class MLX90614Component : public PollingComponent, public i2c::I2CDevice { class MLX90614Component final : public PollingComponent, public i2c::I2CDevice {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -12,7 +12,7 @@ enum MMC5603Datarate {
MMC5603_DATARATE_255_0_HZ, MMC5603_DATARATE_255_0_HZ,
}; };
class MMC5603Component : public PollingComponent, public i2c::I2CDevice { class MMC5603Component final : public PollingComponent, public i2c::I2CDevice {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -6,7 +6,7 @@
namespace esphome::mmc5983 { namespace esphome::mmc5983 {
class MMC5983Component : public PollingComponent, public i2c::I2CDevice { class MMC5983Component final : public PollingComponent, public i2c::I2CDevice {
public: public:
void update() override; void update() override;
void setup() override; void setup() override;

View File

@@ -34,7 +34,7 @@ struct ModbusDeviceCommand {
} }
}; };
class Modbus : public uart::UARTDevice, public Component { class Modbus final : public uart::UARTDevice, public Component {
public: public:
Modbus() = default; Modbus() = default;

View File

@@ -8,7 +8,7 @@
namespace esphome::modbus_controller { namespace esphome::modbus_controller {
class ModbusBinarySensor : public Component, public binary_sensor::BinarySensor, public SensorItem { class ModbusBinarySensor final : public Component, public binary_sensor::BinarySensor, public SensorItem {
public: public:
ModbusBinarySensor(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask, ModbusBinarySensor(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask,
uint16_t skip_updates, bool force_new_range) { uint16_t skip_updates, bool force_new_range) {

View File

@@ -279,7 +279,7 @@ class ModbusCommandItem {
* Responses for the commands are dispatched to the modbus sensor items. * Responses for the commands are dispatched to the modbus sensor items.
*/ */
class ModbusController : public PollingComponent, public modbus::ModbusDevice { class ModbusController final : public PollingComponent, public modbus::ModbusDevice {
public: public:
void dump_config() override; void dump_config() override;
void loop() override; void loop() override;

View File

@@ -10,7 +10,7 @@ namespace esphome::modbus_controller {
using value_to_data_t = std::function<float>(float); using value_to_data_t = std::function<float>(float);
class ModbusNumber : public number::Number, public Component, public SensorItem { class ModbusNumber final : public number::Number, public Component, public SensorItem {
public: public:
ModbusNumber(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask, ModbusNumber(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask,
SensorValueType value_type, int register_count, uint16_t skip_updates, bool force_new_range) { SensorValueType value_type, int register_count, uint16_t skip_updates, bool force_new_range) {

View File

@@ -8,7 +8,7 @@
namespace esphome::modbus_controller { namespace esphome::modbus_controller {
class ModbusFloatOutput : public output::FloatOutput, public Component, public SensorItem { class ModbusFloatOutput final : public output::FloatOutput, public Component, public SensorItem {
public: public:
ModbusFloatOutput(uint16_t start_address, uint8_t offset, SensorValueType value_type, int register_count) { ModbusFloatOutput(uint16_t start_address, uint8_t offset, SensorValueType value_type, int register_count) {
this->register_type = ModbusRegisterType::HOLDING; this->register_type = ModbusRegisterType::HOLDING;
@@ -41,7 +41,7 @@ class ModbusFloatOutput : public output::FloatOutput, public Component, public S
bool use_write_multiple_{false}; bool use_write_multiple_{false};
}; };
class ModbusBinaryOutput : public output::BinaryOutput, public Component, public SensorItem { class ModbusBinaryOutput final : public output::BinaryOutput, public Component, public SensorItem {
public: public:
ModbusBinaryOutput(uint16_t start_address, uint8_t offset) { ModbusBinaryOutput(uint16_t start_address, uint8_t offset) {
this->register_type = ModbusRegisterType::COIL; this->register_type = ModbusRegisterType::COIL;

View File

@@ -9,7 +9,7 @@
namespace esphome::modbus_controller { namespace esphome::modbus_controller {
class ModbusSelect : public Component, public select::Select, public SensorItem { class ModbusSelect final : public Component, public select::Select, public SensorItem {
public: public:
ModbusSelect(SensorValueType sensor_value_type, uint16_t start_address, uint8_t register_count, uint16_t skip_updates, ModbusSelect(SensorValueType sensor_value_type, uint16_t start_address, uint8_t register_count, uint16_t skip_updates,
bool force_new_range, std::vector<int64_t> mapping) { bool force_new_range, std::vector<int64_t> mapping) {

View File

@@ -8,7 +8,7 @@
namespace esphome::modbus_controller { namespace esphome::modbus_controller {
class ModbusSensor : public Component, public sensor::Sensor, public SensorItem { class ModbusSensor final : public Component, public sensor::Sensor, public SensorItem {
public: public:
ModbusSensor(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask, ModbusSensor(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask,
SensorValueType value_type, int register_count, uint16_t skip_updates, bool force_new_range) { SensorValueType value_type, int register_count, uint16_t skip_updates, bool force_new_range) {

View File

@@ -8,7 +8,7 @@
namespace esphome::modbus_controller { namespace esphome::modbus_controller {
class ModbusSwitch : public Component, public switch_::Switch, public SensorItem { class ModbusSwitch final : public Component, public switch_::Switch, public SensorItem {
public: public:
ModbusSwitch(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask, ModbusSwitch(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint32_t bitmask,
uint16_t skip_updates, bool force_new_range) { uint16_t skip_updates, bool force_new_range) {

View File

@@ -10,7 +10,7 @@ namespace esphome::modbus_controller {
enum class RawEncoding { NONE = 0, HEXBYTES = 1, COMMA = 2, ANSI = 3 }; enum class RawEncoding { NONE = 0, HEXBYTES = 1, COMMA = 2, ANSI = 3 };
class ModbusTextSensor : public Component, public text_sensor::TextSensor, public SensorItem { class ModbusTextSensor final : public Component, public text_sensor::TextSensor, public SensorItem {
public: public:
ModbusTextSensor(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint8_t register_count, ModbusTextSensor(ModbusRegisterType register_type, uint16_t start_address, uint8_t offset, uint8_t register_count,
uint16_t response_bytes, RawEncoding encode, uint16_t skip_updates, bool force_new_range) { uint16_t response_bytes, RawEncoding encode, uint16_t skip_updates, bool force_new_range) {

View File

@@ -89,7 +89,7 @@ class ServerRegister {
WriteLambda write_lambda; WriteLambda write_lambda;
}; };
class ModbusServer : public Component, public modbus::ModbusDevice { class ModbusServer final : public Component, public modbus::ModbusDevice {
public: public:
void dump_config() override; void dump_config() override;

View File

@@ -6,7 +6,7 @@
namespace esphome::monochromatic { namespace esphome::monochromatic {
class MonochromaticLightOutput : public light::LightOutput { class MonochromaticLightOutput final : public light::LightOutput {
public: public:
void set_output(output::FloatOutput *output) { output_ = output; } void set_output(output::FloatOutput *output) { output_ = output; }
light::LightTraits get_traits() override { light::LightTraits get_traits() override {

View File

@@ -9,7 +9,7 @@
namespace esphome::mopeka_ble { namespace esphome::mopeka_ble {
class MopekaListener : public esp32_ble_tracker::ESPBTDeviceListener { class MopekaListener final : public esp32_ble_tracker::ESPBTDeviceListener {
public: public:
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override; bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override;
void set_show_sensors_without_sync(bool show_sensors_without_sync) { void set_show_sensors_without_sync(bool show_sensors_without_sync) {

View File

@@ -27,7 +27,7 @@ enum SensorType {
// measurement may be inaccurate. // measurement may be inaccurate.
enum SensorReadQuality { QUALITY_HIGH = 0x3, QUALITY_MED = 0x2, QUALITY_LOW = 0x1, QUALITY_ZERO = 0x0 }; enum SensorReadQuality { QUALITY_HIGH = 0x3, QUALITY_MED = 0x2, QUALITY_LOW = 0x1, QUALITY_ZERO = 0x0 };
class MopekaProCheck : public Component, public esp32_ble_tracker::ESPBTDeviceListener { class MopekaProCheck final : public Component, public esp32_ble_tracker::ESPBTDeviceListener {
public: public:
void set_address(uint64_t address) { address_ = address; }; void set_address(uint64_t address) { address_ = address; };

View File

@@ -42,7 +42,7 @@ struct mopeka_std_package { // NOLINT(readability-identifier-naming,altera-stru
mopeka_std_values val[3]; mopeka_std_values val[3];
} __attribute__((packed)); } __attribute__((packed));
class MopekaStdCheck : public Component, public esp32_ble_tracker::ESPBTDeviceListener { class MopekaStdCheck final : public Component, public esp32_ble_tracker::ESPBTDeviceListener {
public: public:
void set_address(uint64_t address) { address_ = address; }; void set_address(uint64_t address) { address_ = address; };

View File

@@ -85,7 +85,7 @@ class MotionComponent : public PollingComponent {
// --- Actions --- // --- Actions ---
template<typename... Ts> class CalibrateLevelAction : public Action<Ts...> { template<typename... Ts> class CalibrateLevelAction final : public Action<Ts...> {
public: public:
explicit CalibrateLevelAction(MotionComponent *parent) : parent_(parent) {} explicit CalibrateLevelAction(MotionComponent *parent) : parent_(parent) {}
void set_save(bool save) { this->save_ = save; } void set_save(bool save) { this->save_ = save; }
@@ -110,7 +110,7 @@ template<typename... Ts> class CalibrateLevelAction : public Action<Ts...> {
bool save_{false}; bool save_{false};
}; };
template<typename... Ts> class CalibrateHeadingAction : public Action<Ts...> { template<typename... Ts> class CalibrateHeadingAction final : public Action<Ts...> {
public: public:
explicit CalibrateHeadingAction(MotionComponent *parent) : parent_(parent) {} explicit CalibrateHeadingAction(MotionComponent *parent) : parent_(parent) {}
void set_save(bool save) { this->save_ = save; } void set_save(bool save) { this->save_ = save; }
@@ -135,7 +135,7 @@ template<typename... Ts> class CalibrateHeadingAction : public Action<Ts...> {
bool save_{false}; bool save_{false};
}; };
template<typename... Ts> class ClearCalibrationAction : public Action<Ts...> { template<typename... Ts> class ClearCalibrationAction final : public Action<Ts...> {
public: public:
explicit ClearCalibrationAction(MotionComponent *parent) : parent_(parent) {} explicit ClearCalibrationAction(MotionComponent *parent) : parent_(parent) {}
void set_save(bool save) { this->save_ = save; } void set_save(bool save) { this->save_ = save; }

View File

@@ -80,7 +80,7 @@ enum {
MPL3115A2_CTRL_REG1_OS128 = 0x38, MPL3115A2_CTRL_REG1_OS128 = 0x38,
}; };
class MPL3115A2Component : public PollingComponent, public i2c::I2CDevice { class MPL3115A2Component final : public PollingComponent, public i2c::I2CDevice {
public: public:
void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; } void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; }
void set_altitude(sensor::Sensor *altitude) { altitude_ = altitude; } void set_altitude(sensor::Sensor *altitude) { altitude_ = altitude; }

View File

@@ -6,7 +6,9 @@
namespace esphome::mpr121 { namespace esphome::mpr121 {
class MPR121BinarySensor : public binary_sensor::BinarySensor, public MPR121Channel, public Parented<MPR121Component> { class MPR121BinarySensor final : public binary_sensor::BinarySensor,
public MPR121Channel,
public Parented<MPR121Component> {
public: public:
void set_channel(uint8_t channel) { this->channel_ = channel; } void set_channel(uint8_t channel) { this->channel_ = channel; }
void set_touch_threshold(uint8_t touch_threshold) { this->touch_threshold_ = touch_threshold; }; void set_touch_threshold(uint8_t touch_threshold) { this->touch_threshold_ = touch_threshold; };

View File

@@ -57,7 +57,7 @@ class MPR121Channel {
virtual void process(uint16_t data) = 0; virtual void process(uint16_t data) = 0;
}; };
class MPR121Component : public Component, public i2c::I2CDevice { class MPR121Component final : public Component, public i2c::I2CDevice {
public: public:
void register_channel(MPR121Channel *channel) { this->channels_.push_back(channel); } void register_channel(MPR121Channel *channel) { this->channels_.push_back(channel); }
void set_touch_debounce(uint8_t debounce); void set_touch_debounce(uint8_t debounce);
@@ -102,7 +102,7 @@ class MPR121Component : public Component, public i2c::I2CDevice {
}; };
/// Helper class to expose a MPR121 pin as an internal input GPIO pin. /// Helper class to expose a MPR121 pin as an internal input GPIO pin.
class MPR121GPIOPin : public GPIOPin { class MPR121GPIOPin 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::mpu6050 { namespace esphome::mpu6050 {
class MPU6050Component : public PollingComponent, public i2c::I2CDevice { class MPU6050Component final : public PollingComponent, public i2c::I2CDevice {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -6,7 +6,7 @@
namespace esphome::mpu6886 { namespace esphome::mpu6886 {
class MPU6886Component : public PollingComponent, public i2c::I2CDevice { class MPU6886Component final : public PollingComponent, public i2c::I2CDevice {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTAlarmControlPanelComponent : public mqtt::MQTTComponent { class MQTTAlarmControlPanelComponent final : public mqtt::MQTTComponent {
public: public:
explicit MQTTAlarmControlPanelComponent(alarm_control_panel::AlarmControlPanel *alarm_control_panel); explicit MQTTAlarmControlPanelComponent(alarm_control_panel::AlarmControlPanel *alarm_control_panel);

View File

@@ -9,7 +9,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTBinarySensorComponent : public mqtt::MQTTComponent { class MQTTBinarySensorComponent final : public mqtt::MQTTComponent {
public: public:
/** Construct a MQTTBinarySensorComponent. /** Construct a MQTTBinarySensorComponent.
* *

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTButtonComponent : public mqtt::MQTTComponent { class MQTTButtonComponent final : public mqtt::MQTTComponent {
public: public:
explicit MQTTButtonComponent(button::Button *button); explicit MQTTButtonComponent(button::Button *button);

View File

@@ -99,7 +99,7 @@ enum MQTTClientState {
class MQTTComponent; class MQTTComponent;
class MQTTClientComponent : public Component { class MQTTClientComponent final : public Component {
public: public:
MQTTClientComponent(); MQTTClientComponent();
@@ -340,7 +340,7 @@ class MQTTClientComponent : public Component {
extern MQTTClientComponent *global_mqtt_client; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) extern MQTTClientComponent *global_mqtt_client; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
class MQTTMessageTrigger : public Trigger<std::string>, public Component { class MQTTMessageTrigger final : public Trigger<std::string>, public Component {
public: public:
explicit MQTTMessageTrigger(std::string topic); explicit MQTTMessageTrigger(std::string topic);
@@ -356,7 +356,7 @@ class MQTTMessageTrigger : public Trigger<std::string>, public Component {
optional<std::string> payload_; optional<std::string> payload_;
}; };
class MQTTJsonMessageTrigger : public Trigger<JsonObjectConst> { class MQTTJsonMessageTrigger final : public Trigger<JsonObjectConst> {
public: public:
explicit MQTTJsonMessageTrigger(const std::string &topic, uint8_t qos) { explicit MQTTJsonMessageTrigger(const std::string &topic, uint8_t qos) {
global_mqtt_client->subscribe_json( global_mqtt_client->subscribe_json(
@@ -364,21 +364,21 @@ class MQTTJsonMessageTrigger : public Trigger<JsonObjectConst> {
} }
}; };
class MQTTConnectTrigger : public Trigger<bool> { class MQTTConnectTrigger final : public Trigger<bool> {
public: public:
explicit MQTTConnectTrigger(MQTTClientComponent *client) { explicit MQTTConnectTrigger(MQTTClientComponent *client) {
client->set_on_connect([this](bool session_present) { this->trigger(session_present); }); client->set_on_connect([this](bool session_present) { this->trigger(session_present); });
} }
}; };
class MQTTDisconnectTrigger : public Trigger<MQTTClientDisconnectReason> { class MQTTDisconnectTrigger final : public Trigger<MQTTClientDisconnectReason> {
public: public:
explicit MQTTDisconnectTrigger(MQTTClientComponent *client) { explicit MQTTDisconnectTrigger(MQTTClientComponent *client) {
client->set_on_disconnect([this](MQTTClientDisconnectReason reason) { this->trigger(reason); }); client->set_on_disconnect([this](MQTTClientDisconnectReason reason) { this->trigger(reason); });
} }
}; };
template<typename... Ts> class MQTTPublishAction : public Action<Ts...> { template<typename... Ts> class MQTTPublishAction final : public Action<Ts...> {
public: public:
MQTTPublishAction(MQTTClientComponent *parent) : parent_(parent) {} MQTTPublishAction(MQTTClientComponent *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(std::string, topic) TEMPLATABLE_VALUE(std::string, topic)
@@ -395,7 +395,7 @@ template<typename... Ts> class MQTTPublishAction : public Action<Ts...> {
MQTTClientComponent *parent_; MQTTClientComponent *parent_;
}; };
template<typename... Ts> class MQTTPublishJsonAction : public Action<Ts...> { template<typename... Ts> class MQTTPublishJsonAction final : public Action<Ts...> {
public: public:
MQTTPublishJsonAction(MQTTClientComponent *parent) : parent_(parent) {} MQTTPublishJsonAction(MQTTClientComponent *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(std::string, topic) TEMPLATABLE_VALUE(std::string, topic)
@@ -417,7 +417,7 @@ template<typename... Ts> class MQTTPublishJsonAction : public Action<Ts...> {
MQTTClientComponent *parent_; MQTTClientComponent *parent_;
}; };
template<typename... Ts> class MQTTConnectedCondition : public Condition<Ts...> { template<typename... Ts> class MQTTConnectedCondition final : public Condition<Ts...> {
public: public:
MQTTConnectedCondition(MQTTClientComponent *parent) : parent_(parent) {} MQTTConnectedCondition(MQTTClientComponent *parent) : parent_(parent) {}
bool check(const Ts &...x) override { return this->parent_->is_connected(); } bool check(const Ts &...x) override { return this->parent_->is_connected(); }
@@ -426,7 +426,7 @@ template<typename... Ts> class MQTTConnectedCondition : public Condition<Ts...>
MQTTClientComponent *parent_; MQTTClientComponent *parent_;
}; };
template<typename... Ts> class MQTTEnableAction : public Action<Ts...> { template<typename... Ts> class MQTTEnableAction final : public Action<Ts...> {
public: public:
MQTTEnableAction(MQTTClientComponent *parent) : parent_(parent) {} MQTTEnableAction(MQTTClientComponent *parent) : parent_(parent) {}
@@ -436,7 +436,7 @@ template<typename... Ts> class MQTTEnableAction : public Action<Ts...> {
MQTTClientComponent *parent_; MQTTClientComponent *parent_;
}; };
template<typename... Ts> class MQTTDisableAction : public Action<Ts...> { template<typename... Ts> class MQTTDisableAction final : public Action<Ts...> {
public: public:
MQTTDisableAction(MQTTClientComponent *parent) : parent_(parent) {} MQTTDisableAction(MQTTClientComponent *parent) : parent_(parent) {}

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTClimateComponent : public mqtt::MQTTComponent { class MQTTClimateComponent final : public mqtt::MQTTComponent {
public: public:
MQTTClimateComponent(climate::Climate *device); MQTTClimateComponent(climate::Climate *device);
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override; void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override;

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTCoverComponent : public mqtt::MQTTComponent { class MQTTCoverComponent final : public mqtt::MQTTComponent {
public: public:
explicit MQTTCoverComponent(cover::Cover *cover); explicit MQTTCoverComponent(cover::Cover *cover);

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTDateComponent : public mqtt::MQTTComponent { class MQTTDateComponent final : public mqtt::MQTTComponent {
public: public:
/** Construct this MQTTDateComponent instance with the provided friendly_name and date /** Construct this MQTTDateComponent instance with the provided friendly_name and date
* *

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTDateTimeComponent : public mqtt::MQTTComponent { class MQTTDateTimeComponent final : public mqtt::MQTTComponent {
public: public:
/** Construct this MQTTDateTimeComponent instance with the provided friendly_name and time /** Construct this MQTTDateTimeComponent instance with the provided friendly_name and time
* *

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTEventComponent : public mqtt::MQTTComponent { class MQTTEventComponent final : public mqtt::MQTTComponent {
public: public:
explicit MQTTEventComponent(event::Event *event); explicit MQTTEventComponent(event::Event *event);

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTFanComponent : public mqtt::MQTTComponent { class MQTTFanComponent final : public mqtt::MQTTComponent {
public: public:
explicit MQTTFanComponent(fan::Fan *state); explicit MQTTFanComponent(fan::Fan *state);

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTJSONLightComponent : public mqtt::MQTTComponent, public light::LightRemoteValuesListener { class MQTTJSONLightComponent final : public mqtt::MQTTComponent, public light::LightRemoteValuesListener {
public: public:
explicit MQTTJSONLightComponent(light::LightState *state); explicit MQTTJSONLightComponent(light::LightState *state);

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTLockComponent : public mqtt::MQTTComponent { class MQTTLockComponent final : public mqtt::MQTTComponent {
public: public:
explicit MQTTLockComponent(lock::Lock *a_lock); explicit MQTTLockComponent(lock::Lock *a_lock);

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTNumberComponent : public mqtt::MQTTComponent { class MQTTNumberComponent final : public mqtt::MQTTComponent {
public: public:
/** Construct this MQTTNumberComponent instance with the provided friendly_name and number /** Construct this MQTTNumberComponent instance with the provided friendly_name and number
* *

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTSelectComponent : public mqtt::MQTTComponent { class MQTTSelectComponent final : public mqtt::MQTTComponent {
public: public:
/** Construct this MQTTSelectComponent instance with the provided friendly_name and select /** Construct this MQTTSelectComponent instance with the provided friendly_name and select
* *

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTSensorComponent : public mqtt::MQTTComponent { class MQTTSensorComponent final : public mqtt::MQTTComponent {
public: public:
/** Construct this MQTTSensorComponent instance with the provided friendly_name and sensor /** Construct this MQTTSensorComponent instance with the provided friendly_name and sensor
* *

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTSwitchComponent : public mqtt::MQTTComponent { class MQTTSwitchComponent final : public mqtt::MQTTComponent {
public: public:
explicit MQTTSwitchComponent(switch_::Switch *a_switch); explicit MQTTSwitchComponent(switch_::Switch *a_switch);

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTTextComponent : public mqtt::MQTTComponent { class MQTTTextComponent final : public mqtt::MQTTComponent {
public: public:
/** Construct this MQTTTextComponent instance with the provided friendly_name and text /** Construct this MQTTTextComponent instance with the provided friendly_name and text
* *

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTTextSensor : public mqtt::MQTTComponent { class MQTTTextSensor final : public mqtt::MQTTComponent {
public: public:
explicit MQTTTextSensor(text_sensor::TextSensor *sensor); explicit MQTTTextSensor(text_sensor::TextSensor *sensor);

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTTimeComponent : public mqtt::MQTTComponent { class MQTTTimeComponent final : public mqtt::MQTTComponent {
public: public:
/** Construct this MQTTTimeComponent instance with the provided friendly_name and time /** Construct this MQTTTimeComponent instance with the provided friendly_name and time
* *

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTUpdateComponent : public mqtt::MQTTComponent { class MQTTUpdateComponent final : public mqtt::MQTTComponent {
public: public:
explicit MQTTUpdateComponent(update::UpdateEntity *update); explicit MQTTUpdateComponent(update::UpdateEntity *update);

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt { namespace esphome::mqtt {
class MQTTValveComponent : public mqtt::MQTTComponent { class MQTTValveComponent final : public mqtt::MQTTComponent {
public: public:
explicit MQTTValveComponent(valve::Valve *valve); explicit MQTTValveComponent(valve::Valve *valve);

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt_subscribe { namespace esphome::mqtt_subscribe {
class MQTTSubscribeSensor : public sensor::Sensor, public Component { class MQTTSubscribeSensor final : public sensor::Sensor, public Component {
public: public:
void set_parent(mqtt::MQTTClientComponent *parent) { parent_ = parent; } void set_parent(mqtt::MQTTClientComponent *parent) { parent_ = parent; }
void set_topic(const std::string &topic) { topic_ = topic; } void set_topic(const std::string &topic) { topic_ = topic; }

View File

@@ -10,7 +10,7 @@
namespace esphome::mqtt_subscribe { namespace esphome::mqtt_subscribe {
class MQTTSubscribeTextSensor : public text_sensor::TextSensor, public Component { class MQTTSubscribeTextSensor final : public text_sensor::TextSensor, public Component {
public: public:
void set_parent(mqtt::MQTTClientComponent *parent) { parent_ = parent; } void set_parent(mqtt::MQTTClientComponent *parent) { parent_ = parent; }
void set_topic(const std::string &topic) { topic_ = topic; } void set_topic(const std::string &topic) { topic_ = topic; }

View File

@@ -6,7 +6,7 @@
namespace esphome::ms5611 { namespace esphome::ms5611 {
class MS5611Component : public PollingComponent, public i2c::I2CDevice { class MS5611Component final : public PollingComponent, public i2c::I2CDevice {
public: public:
void setup() override; void setup() override;
void dump_config() override; void dump_config() override;

View File

@@ -10,7 +10,7 @@ namespace esphome::ms8607 {
Class for I2CDevice used to communicate with the Humidity sensor Class for I2CDevice used to communicate with the Humidity sensor
on the chip. See MS8607Component instead on the chip. See MS8607Component instead
*/ */
class MS8607HumidityDevice : public i2c::I2CDevice { class MS8607HumidityDevice final : public i2c::I2CDevice {
public: public:
uint8_t get_address() { return address_; } uint8_t get_address() { return address_; }
}; };
@@ -30,7 +30,7 @@ class MS8607HumidityDevice : public i2c::I2CDevice {
- https://github.com/adafruit/Adafruit_MS8607 - https://github.com/adafruit/Adafruit_MS8607
- https://github.com/sparkfun/SparkFun_PHT_MS8607_Arduino_Library - https://github.com/sparkfun/SparkFun_PHT_MS8607_Arduino_Library
*/ */
class MS8607Component : public PollingComponent, public i2c::I2CDevice { class MS8607Component final : public PollingComponent, public i2c::I2CDevice {
public: public:
virtual ~MS8607Component() = default; virtual ~MS8607Component() = default;
void setup() override; void setup() override;