add-mcp23008-support

This commit is contained in:
Tom Fahey 2019-06-19 16:49:51 +01:00
parent 108209c31d
commit b4bc7785b1
122 changed files with 245 additions and 346 deletions

0
docker/rootfs/etc/cont-init.d/10-requirements.sh Executable file → Normal file
View file

0
docker/rootfs/etc/cont-init.d/20-nginx.sh Executable file → Normal file
View file

0
docker/rootfs/etc/nginx/nginx.conf Executable file → Normal file
View file

0
docker/rootfs/etc/services.d/esphome/finish Executable file → Normal file
View file

0
docker/rootfs/etc/services.d/esphome/run Executable file → Normal file
View file

0
docker/rootfs/etc/services.d/nginx/finish Executable file → Normal file
View file

0
docker/rootfs/etc/services.d/nginx/run Executable file → Normal file
View file

View file

@ -69,7 +69,7 @@ void AM2320Component::dump_config() {
}
float AM2320Component::get_setup_priority() const { return setup_priority::DATA; }
bool AM2320Component::read_bytes_(uint8_t a_register, uint8_t *data, uint8_t len, uint32_t conversion) {
bool AM2320Component::read_bytes(uint8_t a_register, uint8_t *data, uint8_t len, uint32_t conversion) {
if (!this->write_bytes(a_register, data, 2)) {
ESP_LOGW(TAG, "Writing bytes for AM2320 failed!");
return false;
@ -80,7 +80,7 @@ bool AM2320Component::read_bytes_(uint8_t a_register, uint8_t *data, uint8_t len
return this->parent_->raw_receive(this->address_, data, len);
}
bool AM2320Component::read_data_(uint8_t *data) {
bool AM2320Component::read_data(uint8_t *data) {
// Wake up
this->write_bytes(0, data, 0);
@ -95,12 +95,7 @@ bool AM2320Component::read_data_(uint8_t *data) {
checksum = data[7] << 8;
checksum += data[6];
if (crc_16(data, 6) != checksum) {
ESP_LOGW(TAG, "AM2320 Checksum invalid!");
return false;
}
return true;
return !;
}
} // namespace am2320

View file

@ -158,7 +158,7 @@ void APDS9960::update() {
void APDS9960::loop() { this->read_gesture_data_(); }
void APDS9960::read_color_data_(uint8_t status) {
void APDS9960::read_color_data(uint8_t status) {
if (!this->is_color_enabled_())
return;
@ -190,7 +190,7 @@ void APDS9960::read_color_data_(uint8_t status) {
if (this->blue_channel_ != nullptr)
this->blue_channel_->publish_state(blue_perc);
}
void APDS9960::read_proximity_data_(uint8_t status) {
void APDS9960::read_proximity_data(uint8_t status) {
if (this->proximity_ == nullptr)
return;

View file

@ -80,7 +80,7 @@ template<typename... Ts> class UserService : public UserServiceDescriptor, publi
template<typename... Ts>
template<int... S>
void UserService<Ts...>::execute_(std::vector<ExecuteServiceArgument> args, seq<S...>) {
void UserService<Ts...>::execute(std::vector<ExecuteServiceArgument> args, seq<S...>) {
this->trigger((args[S].get_value<Ts>())...);
}
template<typename... Ts> void UserService<Ts...>::encode_list_service_response(APIBuffer &buffer) {

View file

@ -90,7 +90,7 @@ void BangBangClimate::compute_state_() {
this->switch_to_mode_(target_mode);
}
void BangBangClimate::switch_to_mode_(climate::ClimateMode mode) {
void BangBangClimate::switch_to_mode(climate::ClimateMode mode) {
if (mode == this->internal_mode_)
// already in target mode
return;

View file

@ -33,11 +33,11 @@ class BangBangClimate : public climate::Climate, public Component {
protected:
/// Override control to change settings of the climate device.
void control(const climate::ClimateCall &call) override;
void control_(const climate::ClimateCall &call) override;
/// Change the away setting, will reset target temperatures to defaults.
void change_away_(bool away);
/// Return the traits of this controller.
climate::ClimateTraits traits() override;
climate::ClimateTraits traits_() override;
/// Re-compute the state of this climate controller.
void compute_state_();

View file

@ -79,14 +79,14 @@ void binary_sensor::MultiClickTrigger::schedule_cooldown_() {
this->cancel_timeout("is_valid");
this->cancel_timeout("is_not_valid");
}
void binary_sensor::MultiClickTrigger::schedule_is_valid_(uint32_t min_length) {
void binary_sensor::MultiClickTrigger::schedule_is_valid(uint32_t min_length) {
this->is_valid_ = false;
this->set_timeout("is_valid", min_length, [this]() {
ESP_LOGV(TAG, "Multi Click: You can now %s the button.", this->parent_->state ? "RELEASE" : "PRESS");
this->is_valid_ = true;
});
}
void binary_sensor::MultiClickTrigger::schedule_is_not_valid_(uint32_t max_length) {
void binary_sensor::MultiClickTrigger::schedule_is_not_valid(uint32_t max_length) {
this->set_timeout("is_not_valid", max_length, [this]() {
ESP_LOGV(TAG, "Multi Click: You waited too long to %s.", this->parent_->state ? "RELEASE" : "PRESS");
this->is_valid_ = false;

View file

@ -136,7 +136,7 @@ template<typename... Ts> class BinarySensorCondition : public Condition<Ts...> {
template<typename... Ts> class BinarySensorPublishAction : public Action<Ts...> {
public:
explicit BinarySensorPublishAction(BinarySensor *sensor) : sensor_(sensor) {}
TEMPLATABLE_VALUE(bool, state)
templatable_value(bool, state)
void play(Ts... x) override {
auto val = this->state_.value(x...);
this->sensor_->publish_state(val);

View file

@ -77,7 +77,7 @@ class BinarySensor : public Nameable {
virtual std::string device_class();
protected:
uint32_t hash_base() override;
uint32_t hash_base_() override;
CallbackManager<void(bool)> state_callback_{};
optional<std::string> device_class_{}; ///< Stores the override of the device class

View file

@ -204,7 +204,7 @@ void BME280Component::update() {
this->status_clear_warning();
});
}
float BME280Component::read_temperature_(int32_t *t_fine) {
float BME280Component::read_temperature(int32_t *t_fine) {
uint8_t data[3];
if (!this->read_bytes(BME280_REGISTER_TEMPDATA, data, 3))
return NAN;
@ -226,7 +226,7 @@ float BME280Component::read_temperature_(int32_t *t_fine) {
return temperature / 100.0f;
}
float BME280Component::read_pressure_(int32_t t_fine) {
float BME280Component::read_pressure(int32_t t_fine) {
uint8_t data[3];
if (!this->read_bytes(BME280_REGISTER_PRESSUREDATA, data, 3))
return NAN;
@ -265,7 +265,7 @@ float BME280Component::read_pressure_(int32_t t_fine) {
return (p / 256.0f) / 100.0f;
}
float BME280Component::read_humidity_(int32_t t_fine) {
float BME280Component::read_humidity(int32_t t_fine) {
uint16_t raw_adc;
if (!this->read_byte_16(BME280_REGISTER_HUMIDDATA, &raw_adc) || raw_adc == 0x8000)
return NAN;
@ -302,17 +302,17 @@ void BME280Component::set_humidity_oversampling(BME280Oversampling humidity_over
this->humidity_oversampling_ = humidity_over_sampling;
}
void BME280Component::set_iir_filter(BME280IIRFilter iir_filter) { this->iir_filter_ = iir_filter; }
uint8_t BME280Component::read_u8_(uint8_t a_register) {
uint8_t BME280Component::read_u8(uint8_t a_register) {
uint8_t data = 0;
this->read_byte(a_register, &data);
return data;
}
uint16_t BME280Component::read_u16_le_(uint8_t a_register) {
uint16_t BME280Component::read_u16_le(uint8_t a_register) {
uint16_t data = 0;
this->read_byte_16(a_register, &data);
return (data >> 8) | (data << 8);
}
int16_t BME280Component::read_s16_le_(uint8_t a_register) { return this->read_u16_le_(a_register); }
int16_t BME280Component::read_s16_le(uint8_t a_register) { return this->read_u16_le_(a_register); }
} // namespace bme280
} // namespace esphome

View file

@ -242,7 +242,7 @@ void BME680Component::update() {
this->set_timeout("data", this->calc_meas_duration_(), [this]() { this->read_data_(); });
}
uint8_t BME680Component::calc_heater_resistance_(uint16_t temperature) {
uint8_t BME680Component::calc_heater_resistance(uint16_t temperature) {
if (temperature < 200)
temperature = 200;
if (temperature > 400)
@ -273,7 +273,7 @@ uint8_t BME680Component::calc_heater_resistance_(uint16_t temperature) {
return heatr_res;
}
uint8_t BME680Component::calc_heater_duration_(uint16_t duration) {
uint8_t BME680Component::calc_heater_duration(uint16_t duration) {
uint8_t factor = 0;
uint8_t duration_value;
@ -323,7 +323,7 @@ void BME680Component::read_data_() {
this->status_clear_warning();
}
float BME680Component::calc_temperature_(uint32_t raw_temperature) {
float BME680Component::calc_temperature(uint32_t raw_temperature) {
float var1 = 0;
float var2 = 0;
float var3 = 0;
@ -349,7 +349,7 @@ float BME680Component::calc_temperature_(uint32_t raw_temperature) {
return calc_temp;
}
float BME680Component::calc_pressure_(uint32_t raw_pressure) {
float BME680Component::calc_pressure(uint32_t raw_pressure) {
const float tfine = this->calibration_.tfine;
const float p1 = this->calibration_.p1;
const float p2 = this->calibration_.p2;
@ -391,7 +391,7 @@ float BME680Component::calc_pressure_(uint32_t raw_pressure) {
return calc_pres / 100.0f;
}
float BME680Component::calc_humidity_(uint16_t raw_humidity) {
float BME680Component::calc_humidity(uint16_t raw_humidity) {
const float tfine = this->calibration_.tfine;
const float h1 = this->calibration_.h1;
const float h2 = this->calibration_.h2;
@ -426,7 +426,7 @@ float BME680Component::calc_humidity_(uint16_t raw_humidity) {
return calc_hum;
}
uint32_t BME680Component::calc_gas_resistance_(uint16_t raw_gas, uint8_t range) {
uint32_t BME680Component::calc_gas_resistance(uint16_t raw_gas, uint8_t range) {
float calc_gas_res;
float var1 = 0;
float var2 = 0;
@ -441,7 +441,7 @@ uint32_t BME680Component::calc_gas_resistance_(uint16_t raw_gas, uint8_t range)
return static_cast<uint32_t>(calc_gas_res);
}
uint32_t BME680Component::calc_meas_duration_() {
uint32_t BME680Component::calc_meas_duration() {
uint32_t tph_dur; // Calculate in us
uint32_t meas_cycles;
const uint8_t os_to_meas_cycles[6] = {0, 1, 2, 4, 8, 16};

View file

@ -128,7 +128,7 @@ void BMP085Component::read_pressure_() {
this->pressure_->publish_state(pressure);
this->status_clear_warning();
}
bool BMP085Component::set_mode_(uint8_t mode) {
bool BMP085Component::set_mode(uint8_t mode) {
ESP_LOGV(TAG, "Setting mode to 0x%02X...", mode);
return this->write_byte(BMP085_REGISTER_CONTROL, mode);
}

View file

@ -155,7 +155,7 @@ void BMP280Component::update() {
});
}
float BMP280Component::read_temperature_(int32_t *t_fine) {
float BMP280Component::read_temperature(int32_t *t_fine) {
uint8_t data[3];
if (!this->read_bytes(BMP280_REGISTER_TEMPDATA, data, 3))
return NAN;
@ -177,7 +177,7 @@ float BMP280Component::read_temperature_(int32_t *t_fine) {
return temperature / 100.0f;
}
float BMP280Component::read_pressure_(int32_t t_fine) {
float BMP280Component::read_pressure(int32_t t_fine) {
uint8_t data[3];
if (!this->read_bytes(BMP280_REGISTER_PRESSUREDATA, data, 3))
return NAN;
@ -222,17 +222,17 @@ void BMP280Component::set_pressure_oversampling(BMP280Oversampling pressure_over
this->pressure_oversampling_ = pressure_over_sampling;
}
void BMP280Component::set_iir_filter(BMP280IIRFilter iir_filter) { this->iir_filter_ = iir_filter; }
uint8_t BMP280Component::read_u8_(uint8_t a_register) {
uint8_t BMP280Component::read_u8(uint8_t a_register) {
uint8_t data = 0;
this->read_byte(a_register, &data);
return data;
}
uint16_t BMP280Component::read_u16_le_(uint8_t a_register) {
uint16_t BMP280Component::read_u16_le(uint8_t a_register) {
uint16_t data = 0;
this->read_byte_16(a_register, &data);
return (data >> 8) | (data << 8);
}
int16_t BMP280Component::read_s16_le_(uint8_t a_register) { return this->read_u16_le_(a_register); }
int16_t BMP280Component::read_s16_le(uint8_t a_register) { return this->read_u16_le_(a_register); }
} // namespace bmp280
} // namespace esphome

View file

@ -182,7 +182,7 @@ class Climate : public Nameable {
* modes, temperature range etc. Each integration must implement this method and the return value must
* be constant during all of execution time.
*/
virtual ClimateTraits traits() = 0;
virtual ClimateTraits traits_() = 0;
/** Control the climate device, this is a virtual method that each climate integration must implement.
*
@ -200,7 +200,7 @@ class Climate : public Nameable {
*/
void save_state_();
uint32_t hash_base() override;
uint32_t hash_base_() override;
CallbackManager<void()> state_callback_{};
ESPPreferenceObject rtc_;

View file

@ -22,9 +22,9 @@ class CoolixClimate : public climate::Climate, public Component {
protected:
/// Override control to change settings of the climate device.
void control(const climate::ClimateCall &call) override;
void control_(const climate::ClimateCall &call) override;
/// Return the traits of this controller.
climate::ClimateTraits traits() override;
climate::ClimateTraits traits_() override;
/// Transmit via IR the state of this climate controller.
void transmit_state_();

View file

@ -117,7 +117,7 @@ class Cover : public Nameable {
* COVER_CLOSED constants).
*/
float position;
ESPDEPRECATED("<cover>.state is deprecated, please use .position instead") float state;
espdeprecated("<cover>.state is deprecated, please use .position instead") float state;
};
/// The current tilt value of the cover from 0.0 to 1.0.
float tilt{COVER_OPEN};
@ -164,10 +164,10 @@ class Cover : public Nameable {
friend CoverCall;
virtual void control(const CoverCall &call) = 0;
virtual std::string device_class();
virtual std::string device_class_();
optional<CoverRestoreState> restore_state_();
uint32_t hash_base() override;
uint32_t hash_base_() override;
CallbackManager<void()> state_callback_{};
optional<std::string> device_class_override_{};

View file

@ -42,11 +42,7 @@ bool CSE7766Component::check_byte_() {
}
if (index == 1) {
if (byte != 0x5A) {
ESP_LOGV(TAG, "Invalid Header 2 Start: 0x%02X!", byte);
return false;
}
return true;
return !;
}
if (index == 23) {
@ -54,11 +50,7 @@ bool CSE7766Component::check_byte_() {
for (uint8_t i = 2; i < 23; i++)
checksum += this->raw_data_[i];
if (checksum != this->raw_data_[23]) {
ESP_LOGW(TAG, "Invalid checksum from CSE7766: 0x%02X != 0x%02X", checksum, this->raw_data_[23]);
return false;
}
return true;
return !;
}
return true;
@ -161,7 +153,7 @@ void CSE7766Component::update() {
this->current_counts_ = 0;
}
uint32_t CSE7766Component::get_24_bit_uint_(uint8_t start_index) {
uint32_t CSE7766Component::get_24_bit_uint(uint8_t start_index) {
return (uint32_t(this->raw_data_[start_index]) << 16) | (uint32_t(this->raw_data_[start_index + 1]) << 8) |
uint32_t(this->raw_data_[start_index + 2]);
}

View file

@ -110,13 +110,7 @@ void DallasComponent::update() {
disable_interrupts();
bool result;
if (!this->one_wire_->reset()) {
result = false;
} else {
result = true;
this->one_wire_->skip();
this->one_wire_->write8(DALLAS_COMMAND_START_CONVERSION);
}
result = !;
enable_interrupts();
if (!result) {
@ -168,17 +162,7 @@ const std::string &DallasTemperatureSensor::get_address_name() {
}
bool DallasTemperatureSensor::read_scratch_pad() {
ESPOneWire *wire = this->parent_->one_wire_;
if (!wire->reset()) {
return false;
}
wire->select(this->address_);
wire->write8(DALLAS_COMMAND_READ_SCRATCH_PAD);
for (unsigned char &i : this->scratch_pad_) {
i = wire->read8();
}
return true;
return !;
}
bool DallasTemperatureSensor::setup_sensor() {
disable_interrupts();
@ -244,11 +228,7 @@ bool DallasTemperatureSensor::check_scratch_pad() {
this->scratch_pad_[5], this->scratch_pad_[6], this->scratch_pad_[7], this->scratch_pad_[8],
crc8(this->scratch_pad_, 8));
#endif
if (crc8(this->scratch_pad_, 8) != this->scratch_pad_[8]) {
ESP_LOGE(TAG, "Reading scratchpad from Dallas Sensor failed");
return false;
}
return true;
return !;
}
float DallasTemperatureSensor::get_temp_c() {
int16_t temp = (int16_t(this->scratch_pad_[1]) << 11) | (int16_t(this->scratch_pad_[0]) << 3);

View file

@ -51,19 +51,14 @@ void DHT12Component::dump_config() {
LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
}
float DHT12Component::get_setup_priority() const { return setup_priority::DATA; }
bool DHT12Component::read_data_(uint8_t *data) {
bool DHT12Component::read_data(uint8_t *data) {
if (!this->read_bytes(0, data, 5)) {
ESP_LOGW(TAG, "Updating DHT12 failed!");
return false;
}
uint8_t checksum = data[0] + data[1] + data[2] + data[3];
if (data[4] != checksum) {
ESP_LOGW(TAG, "DHT12 Checksum invalid!");
return false;
}
return true;
return !;
}
} // namespace dht12

View file

@ -10,7 +10,7 @@ static const char *TAG = "display";
const uint8_t COLOR_OFF = 0;
const uint8_t COLOR_ON = 1;
void DisplayBuffer::init_internal_(uint32_t buffer_length) {
void DisplayBuffer::init_internal(uint32_t buffer_length) {
this->buffer_ = new uint8_t[buffer_length];
if (this->buffer_ == nullptr) {
ESP_LOGE(TAG, "Could not allocate buffer for display!");

View file

@ -390,7 +390,7 @@ class Image {
template<typename... Ts> class DisplayPageShowAction : public Action<Ts...> {
public:
TEMPLATABLE_VALUE(DisplayPage *, page)
templatable_value(DisplayPage *, page)
void play(Ts... x) override {
auto *page = this->page_.value(x...);
if (page != nullptr) {

View file

@ -113,7 +113,7 @@ bool EndstopCover::is_at_target_() const {
return true;
}
}
void EndstopCover::start_direction_(CoverOperation dir) {
void EndstopCover::start_direction(CoverOperation dir) {
if (dir == this->current_operation)
return;

View file

@ -27,7 +27,7 @@ class EndstopCover : public cover::Cover, public Component {
cover::CoverTraits get_traits() override;
protected:
void control(const cover::CoverCall &call) override;
void control_(const cover::CoverCall &call) override;
void stop_prev_trigger_();
bool is_open_() const { return this->open_endstop_->state; }
bool is_closed_() const { return this->close_endstop_->state; }

View file

@ -25,7 +25,7 @@ class ESP8266PWM : public output::FloatOutput, public Component {
float get_setup_priority() const override { return setup_priority::HARDWARE; }
protected:
void write_state(float state) override;
void write_state_(float state) override;
GPIOPin *pin_;
float frequency_{1000.0};
@ -36,7 +36,7 @@ class ESP8266PWM : public output::FloatOutput, public Component {
template<typename... Ts> class SetFrequencyAction : public Action<Ts...> {
public:
SetFrequencyAction(ESP8266PWM *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(float, frequency);
templatable_value(float, frequency);
void play(Ts... x) {
float freq = this->frequency_.value(x...);

View file

@ -11,7 +11,7 @@ template<typename... Ts> class TurnOnAction : public Action<Ts...> {
public:
explicit TurnOnAction(FanState *state) : state_(state) {}
TEMPLATABLE_VALUE(bool, oscillating)
templatable_value(bool, oscillating)
TEMPLATABLE_VALUE(FanSpeed, speed)
void play(Ts... x) override {

View file

@ -88,7 +88,7 @@ class FanState : public Nameable, public Component {
protected:
friend FanStateCall;
uint32_t hash_base() override;
uint32_t hash_base_() override;
FanTraits traits_{};
CallbackManager<void()> state_callback_{};

View file

@ -223,7 +223,7 @@ class FastLEDLightOutput : public light::AddressableLight {
}
protected:
light::ESPColorView get_view_internal(int32_t index) const override {
light::ESPColorView get_view_internal_(int32_t index) const override {
return {&this->leds_[index].r, &this->leds_[index].g, &this->leds_[index].b, nullptr,
&this->effect_data_[index], &this->correction_};
}

View file

@ -20,7 +20,7 @@ class GPIOBinaryOutput : public output::BinaryOutput, public Component {
float get_setup_priority() const override { return setup_priority::HARDWARE; }
protected:
void write_state(bool state) override { this->pin_->digital_write(state); }
void write_state_(bool state) override { this->pin_->digital_write(state); }
GPIOPin *pin_;
};

View file

@ -66,7 +66,7 @@ void GPIOSwitch::dump_config() {
}
}
}
void GPIOSwitch::write_state(bool state) {
void GPIOSwitch::write_state_(bool state) {
if (state != this->inverted_) {
// Turning ON, check interlocking
for (auto *lock : this->interlock_) {

View file

@ -28,7 +28,7 @@ class GPIOSwitch : public switch_::Switch, public Component {
void set_interlock(const std::vector<Switch *> &interlock);
protected:
void write_state(bool state) override;
void write_state_(bool state) override;
GPIOPin *pin_;
GPIOSwitchRestoreMode restore_mode_{GPIO_SWITCH_RESTORE_DEFAULT_OFF};

View file

@ -32,7 +32,7 @@ void HX711Sensor::update() {
this->publish_state(value);
}
}
bool HX711Sensor::read_sensor_(uint32_t *result) {
bool HX711Sensor::read_sensor(uint32_t *result) {
if (this->dout_pin_->digital_read()) {
ESP_LOGW(TAG, "HX711 is not ready for new measurements yet!");
this->status_set_warning();

View file

@ -82,11 +82,7 @@ bool I2CComponent::raw_end_transmission(uint8_t address) {
bool I2CComponent::raw_request_from(uint8_t address, uint8_t len) {
ESP_LOGVV(TAG, "Requesting %u bytes from 0x%02X:", len, address);
uint8_t ret = this->wire_->requestFrom(address, len);
if (ret != len) {
ESP_LOGW(TAG, "Requesting %u bytes from 0x%02X failed!", len, address);
return false;
}
return true;
return !;
}
void HOT I2CComponent::raw_write(uint8_t address, const uint8_t *data, uint8_t len) {
for (size_t i = 0; i < len; i++) {

View file

@ -56,9 +56,9 @@ class IntegrationSensor : public sensor::Sensor, public Component {
this->publish_state(result);
this->rtc_.save(&result);
}
std::string unit_of_measurement() override;
std::string icon() override { return this->sensor_->get_icon(); }
int8_t accuracy_decimals() override { return this->sensor_->get_accuracy_decimals() + 2; }
std::string unit_of_measurement_() override;
std::string icon_() override { return this->sensor_->get_icon(); }
int8_t accuracy_decimals_() override { return this->sensor_->get_accuracy_decimals() + 2; }
sensor::Sensor *sensor_;
IntegrationSensorTime time_;

View file

@ -33,11 +33,11 @@ class GPIOLCDDisplay : public lcd_base::LCDDisplay {
void dump_config() override;
protected:
bool is_four_bit_mode() override { return this->data_pins_[4] == nullptr; }
void write_n_bits(uint8_t value, uint8_t n) override;
void send(uint8_t value, bool rs) override;
bool is_four_bit_mode_() override { return this->data_pins_[4] == nullptr; }
void write_n_bits_(uint8_t value, uint8_t n) override;
void send_(uint8_t value, bool rs) override;
void call_writer() override { this->writer_(*this); }
void call_writer_() override { this->writer_(*this); }
GPIOPin *rs_pin_{nullptr};
GPIOPin *rw_pin_{nullptr};

View file

@ -16,11 +16,11 @@ class PCF8574LCDDisplay : public lcd_base::LCDDisplay, public i2c::I2CDevice {
void no_backlight();
protected:
bool is_four_bit_mode() override { return true; }
void write_n_bits(uint8_t value, uint8_t n) override;
void send(uint8_t value, bool rs) override;
bool is_four_bit_mode_() override { return true; }
void write_n_bits_(uint8_t value, uint8_t n) override;
void send_(uint8_t value, bool rs) override;
void call_writer() override { this->writer_(*this); }
void call_writer_() override { this->writer_(*this); }
// Stores the current state of the backlight.
uint8_t backlight_value_;

View file

@ -7,12 +7,12 @@ namespace light {
static const char *TAG = "light";
void LightState::start_transition_(const LightColorValues &target, uint32_t length) {
void LightState::start_transition(const LightColorValues &target, uint32_t length) {
this->transformer_ = make_unique<LightTransitionTransformer>(millis(), length, this->current_values, target);
this->remote_values = this->transformer_->get_remote_values();
}
void LightState::start_flash_(const LightColorValues &target, uint32_t length) {
void LightState::start_flash(const LightColorValues &target, uint32_t length) {
LightColorValues end_colors = this->current_values;
// If starting a flash if one is already happening, set end values to end values of current flash
// Hacky but works
@ -24,7 +24,7 @@ void LightState::start_flash_(const LightColorValues &target, uint32_t length) {
LightState::LightState(const std::string &name, LightOutput *output) : Nameable(name), output_(output) {}
void LightState::set_immediately_(const LightColorValues &target) {
void LightState::set_immediately(const LightColorValues &target) {
this->transformer_ = nullptr;
this->current_values = this->remote_values = target;
this->next_write_ = true;
@ -46,7 +46,7 @@ std::string LightState::get_effect_name() {
return "None";
}
void LightState::start_effect_(uint32_t effect_index) {
void LightState::start_effect(uint32_t effect_index) {
this->stop_effect_();
if (effect_index == 0)
return;
@ -57,7 +57,7 @@ void LightState::start_effect_(uint32_t effect_index) {
}
bool LightState::supports_effects() { return !this->effects_.empty(); }
void LightState::set_transformer_(std::unique_ptr<LightTransformer> transformer) {
void LightState::set_transformer(std::unique_ptr<LightTransformer> transformer) {
this->transformer_ = std::move(transformer);
}
void LightState::stop_effect_() {
@ -351,7 +351,7 @@ void LightCall::perform() {
}
}
LightColorValues LightCall::validate_() {
LightColorValues LightCall::validate() {
// use remote values for fallback
auto *name = this->parent_->get_name().c_str();
auto traits = this->parent_->get_traits();

View file

@ -203,11 +203,11 @@ class LightState : public Nameable, public Component {
LightColorValues current_values;
/// Deprecated method to access current_values.
ESPDEPRECATED("get_current_values() is deprecated, please use .current_values instead.")
espdeprecated("get_current_values() is deprecated, please use .current_values instead.")
LightColorValues get_current_values();
/// Deprecated method to access remote_values.
ESPDEPRECATED("get_remote_values() is deprecated, please use .remote_values instead.")
espdeprecated("get_remote_values() is deprecated, please use .remote_values instead.")
LightColorValues get_remote_values();
/** The remote color values reported to the frontend.
@ -278,7 +278,7 @@ class LightState : public Nameable, public Component {
friend LightOutput;
friend LightCall;
uint32_t hash_base() override;
uint32_t hash_base_() override;
/// Internal method to start an effect with the given index
void start_effect_(uint32_t effect_index);

View file

@ -145,11 +145,11 @@ void MAX7219Component::display() {
this->disable();
}
}
void MAX7219Component::send_byte_(uint8_t a_register, uint8_t data) {
void MAX7219Component::send_byte(uint8_t a_register, uint8_t data) {
this->write_byte(a_register);
this->write_byte(data);
}
void MAX7219Component::send_to_all_(uint8_t a_register, uint8_t data) {
void MAX7219Component::send_to_all(uint8_t a_register, uint8_t data) {
this->enable();
for (uint8_t i = 0; i < this->num_chips_; i++)
this->send_byte_(a_register, data);

View file

@ -47,19 +47,19 @@ void MCP23008::pin_mode(uint8_t pin, uint8_t mode) {
}
}
float MCP23008::get_setup_priority() const { return setup_priority::HARDWARE; }
bool MCP23008::read_reg_(uint8_t reg, uint8_t *value) {
bool MCP23008::read_reg(uint8_t reg, uint8_t *value) {
if (this->is_failed())
return false;
return this->read_byte(reg, value);
}
bool MCP23008::write_reg_(uint8_t reg, uint8_t value) {
bool MCP23008::write_reg(uint8_t reg, uint8_t value) {
if (this->is_failed())
return false;
return this->write_byte(reg, value);
}
void MCP23008::update_reg_(uint8_t pin, bool pin_value, uint8_t reg_addr) {
void MCP23008::update_reg(uint8_t pin, bool pin_value, uint8_t reg_addr) {
uint8_t bit = pin % 8;
uint8_t reg_value = 0;
if (reg_addr == MCP23008_OLAT) {

View file

@ -48,19 +48,19 @@ void MCP23017::pin_mode(uint8_t pin, uint8_t mode) {
}
}
float MCP23017::get_setup_priority() const { return setup_priority::HARDWARE; }
bool MCP23017::read_reg_(uint8_t reg, uint8_t *value) {
bool MCP23017::read_reg(uint8_t reg, uint8_t *value) {
if (this->is_failed())
return false;
return this->read_byte(reg, value);
}
bool MCP23017::write_reg_(uint8_t reg, uint8_t value) {
bool MCP23017::write_reg(uint8_t reg, uint8_t value) {
if (this->is_failed())
return false;
return this->write_byte(reg, value);
}
void MCP23017::update_reg_(uint8_t pin, bool pin_value, uint8_t reg_addr) {
void MCP23017::update_reg(uint8_t pin, bool pin_value, uint8_t reg_addr) {
uint8_t bit = pin % 8;
uint8_t reg_value = 0;
if (reg_addr == MCP23017_OLATA) {

View file

@ -50,7 +50,7 @@ void MHZ19Component::update() {
this->temperature_sensor_->publish_state(temp);
}
bool MHZ19Component::mhz19_write_command_(const uint8_t *command, uint8_t *response) {
bool MHZ19Component::mhz19_write_command(const uint8_t *command, uint8_t *response) {
this->flush();
this->write_array(command, MHZ19_REQUEST_LENGTH);
this->write_byte(mhz19_checksum(command));

View file

@ -286,7 +286,7 @@ void MQTTClientComponent::loop() {
float MQTTClientComponent::get_setup_priority() const { return setup_priority::AFTER_WIFI; }
// Subscribe
bool MQTTClientComponent::subscribe_(const char *topic, uint8_t qos) {
bool MQTTClientComponent::subscribe(const char *topic, uint8_t qos) {
if (!this->is_connected())
return false;

View file

@ -294,7 +294,7 @@ class MQTTJsonMessageTrigger : public Trigger<const JsonObject &> {
template<typename... Ts> class MQTTPublishAction : public Action<Ts...> {
public:
MQTTPublishAction(MQTTClientComponent *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(std::string, topic)
templatable_value(std::string, topic)
TEMPLATABLE_VALUE(std::string, payload)
TEMPLATABLE_VALUE(uint8_t, qos)
TEMPLATABLE_VALUE(bool, retain)
@ -311,7 +311,7 @@ template<typename... Ts> class MQTTPublishAction : public Action<Ts...> {
template<typename... Ts> class MQTTPublishJsonAction : public Action<Ts...> {
public:
MQTTPublishJsonAction(MQTTClientComponent *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(std::string, topic)
templatable_value(std::string, topic)
TEMPLATABLE_VALUE(uint8_t, qos)
TEMPLATABLE_VALUE(bool, retain)

View file

@ -11,24 +11,24 @@ static const char *TAG = "mqtt.component";
void MQTTComponent::set_retain(bool retain) { this->retain_ = retain; }
std::string MQTTComponent::get_discovery_topic_(const MQTTDiscoveryInfo &discovery_info) const {
std::string MQTTComponent::get_discovery_topic(const MQTTDiscoveryInfo &discovery_info) const {
std::string sanitized_name = sanitize_string_whitelist(App.get_name(), HOSTNAME_CHARACTER_WHITELIST);
return discovery_info.prefix + "/" + this->component_type() + "/" + sanitized_name + "/" +
this->get_default_object_id_() + "/config";
}
std::string MQTTComponent::get_default_topic_for_(const std::string &suffix) const {
std::string MQTTComponent::get_default_topic_for(const std::string &suffix) const {
return global_mqtt_client->get_topic_prefix() + "/" + this->component_type() + "/" + this->get_default_object_id_() +
"/" + suffix;
}
const std::string MQTTComponent::get_state_topic_() const {
const std::string MQTTComponent::get_state_topic() const {
if (this->custom_state_topic_.empty())
return this->get_default_topic_for_("state");
return this->custom_state_topic_;
}
const std::string MQTTComponent::get_command_topic_() const {
const std::string MQTTComponent::get_command_topic() const {
if (this->custom_command_topic_.empty())
return this->get_default_topic_for_("command");
return this->custom_command_topic_;
@ -116,7 +116,7 @@ bool MQTTComponent::is_discovery_enabled() const {
return this->discovery_enabled_ && global_mqtt_client->is_discovery_enabled();
}
std::string MQTTComponent::get_default_object_id_() const {
std::string MQTTComponent::get_default_object_id() const {
return sanitize_string_whitelist(to_lowercase_underscore(this->friendly_name()), HOSTNAME_CHARACTER_WHITELIST);
}

View file

@ -141,14 +141,14 @@ class MQTTComponent : public Component {
std::string get_default_topic_for_(const std::string &suffix) const;
/// Get the friendly name of this MQTT component.
virtual std::string friendly_name() const = 0;
virtual std::string friendly_name_() const = 0;
/** A unique ID for this MQTT component, empty for no unique id. See unique ID requirements:
* https://developers.home-assistant.io/docs/en/entity_registry_index.html#unique-id-requirements
*
* @return The unique id as a string.
*/
virtual std::string unique_id();
virtual std::string unique_id_();
/// Get the MQTT topic that new states will be shared to.
const std::string get_state_topic_() const;

View file

@ -65,7 +65,7 @@ void MS5611Component::read_temperature_() {
auto f = std::bind(&MS5611Component::read_pressure_, this, raw_temperature);
this->set_timeout("pressure", 10, f);
}
void MS5611Component::read_pressure_(uint32_t raw_temperature) {
void MS5611Component::read_pressure(uint32_t raw_temperature) {
uint8_t bytes[3];
if (!this->read_bytes(MS5611_CMD_ADC_READ, bytes, 3)) {
this->status_set_warning();
@ -74,7 +74,7 @@ void MS5611Component::read_pressure_(uint32_t raw_temperature) {
const uint32_t raw_pressure = (uint32_t(bytes[0]) << 16) | (uint32_t(bytes[1]) << 8) | (uint32_t(bytes[2]));
this->calculate_values_(raw_temperature, raw_pressure);
}
void MS5611Component::calculate_values_(uint32_t raw_temperature, uint32_t raw_pressure) {
void MS5611Component::calculate_values(uint32_t raw_temperature, uint32_t raw_pressure) {
const int32_t d_t = int32_t(raw_temperature) - (uint32_t(this->prom_[4]) << 8);
float temperature = (2000 + (int64_t(d_t) * this->prom_[5]) / 8388608.0f) / 100.0f;

View file

@ -73,7 +73,7 @@ void MY9231OutputComponent::loop() {
this->send_di_pulses_(8);
this->update_ = false;
}
void MY9231OutputComponent::set_channel_value_(uint8_t channel, uint16_t value) {
void MY9231OutputComponent::set_channel_value(uint8_t channel, uint16_t value) {
ESP_LOGV(TAG, "set channels %u to %u", channel, value);
uint8_t index = this->num_channels_ - channel - 1;
if (this->pwm_amounts_[index] != value) {
@ -81,7 +81,7 @@ void MY9231OutputComponent::set_channel_value_(uint8_t channel, uint16_t value)
}
this->pwm_amounts_[index] = value;
}
void MY9231OutputComponent::init_chips_(uint8_t command) {
void MY9231OutputComponent::init_chips(uint8_t command) {
// Send 12 DI pulse. After 6 falling edges, the duty data are stored
// and after 12 rising edges the command mode is activated.
this->send_di_pulses_(12);
@ -93,13 +93,13 @@ void MY9231OutputComponent::init_chips_(uint8_t command) {
// stored and after 16 falling edges the duty mode is activated.
this->send_di_pulses_(16);
}
void MY9231OutputComponent::write_word_(uint16_t value, uint8_t bits) {
void MY9231OutputComponent::write_word(uint16_t value, uint8_t bits) {
for (uint8_t i = bits; i > 0; i--) {
this->pin_di_->digital_write(value & (1 << (i - 1)));
this->pin_dcki_->digital_write(!this->pin_dcki_->digital_read());
}
}
void MY9231OutputComponent::send_di_pulses_(uint8_t count) {
void MY9231OutputComponent::send_di_pulses(uint8_t count) {
delayMicroseconds(12);
for (uint8_t i = 0; i < count; i++) {
this->pin_di_->digital_write(true);

View file

@ -32,7 +32,7 @@ class MY9231OutputComponent : public Component {
void set_channel(uint8_t channel) { channel_ = channel; }
protected:
void write_state(float state) override {
void write_state_(float state) override {
auto amount = uint16_t(state * this->parent_->get_max_amount_());
this->parent_->set_channel_value_(this->channel_, amount);
}

View file

@ -79,12 +79,7 @@ bool Nextion::send_command_printf(const char *format, ...) {
return false;
}
this->send_command_no_ack(buffer);
if (!this->ack_()) {
ESP_LOGW(TAG, "Sending command '%s' failed because no ACK was received", buffer);
return false;
}
return true;
return this->ack_();
}
void Nextion::hide_component(const char *component) { this->send_command_printf("vis %s,0", component); }
void Nextion::show_component(const char *component) { this->send_command_printf("vis %s,1", component); }

View file

@ -300,7 +300,7 @@ error:
#endif
}
size_t OTAComponent::wait_receive_(uint8_t *buf, size_t bytes, bool check_disconnected) {
size_t OTAComponent::wait_receive(uint8_t *buf, size_t bytes, bool check_disconnected) {
size_t available = 0;
uint32_t start = millis();
do {
@ -387,8 +387,8 @@ void OTAComponent::start_safe_mode(uint8_t num_attempts, uint32_t enable_time) {
this->write_rtc_(this->safe_mode_rtc_value_ + 1);
}
}
void OTAComponent::write_rtc_(uint32_t val) { this->rtc_.save(&val); }
uint32_t OTAComponent::read_rtc_() {
void OTAComponent::write_rtc(uint32_t val) { this->rtc_.save(&val); }
uint32_t OTAComponent::read_rtc() {
uint32_t val;
if (!this->rtc_.load(&val))
return 0;

View file

@ -32,7 +32,7 @@ template<typename... Ts> class SetLevelAction : public Action<Ts...> {
public:
SetLevelAction(FloatOutput *output) : output_(output) {}
TEMPLATABLE_VALUE(float, level)
templatable_value(float, level)
void play(Ts... x) override { this->output_->set_level(this->level_.value(x...)); }
protected:

View file

@ -18,7 +18,7 @@ void OutputSwitch::setup() {
this->turn_off();
}
}
void OutputSwitch::write_state(bool state) {
void OutputSwitch::write_state_(bool state) {
if (state) {
this->output_->turn_on();
} else {

View file

@ -16,7 +16,7 @@ class OutputSwitch : public switch_::Switch, public Component {
void dump_config() override;
protected:
void write_state(bool state) override;
void write_state_(bool state) override;
output::BinaryOutput *output_;
};

View file

@ -53,7 +53,7 @@ class PartitionLightOutput : public light::AddressableLight {
}
protected:
light::ESPColorView get_view_internal(int32_t index) const override {
light::ESPColorView get_view_internal_(int32_t index) const override {
uint32_t lo = 0;
uint32_t hi = this->segments_.size() - 1;
while (lo < hi) {

View file

@ -130,7 +130,7 @@ PCA9685Channel *PCA9685Output::create_channel(uint8_t channel) {
return c;
}
void PCA9685Channel::write_state(float state) {
void PCA9685Channel::write_state_(float state) {
const uint16_t max_duty = 4096;
const float duty_rounded = roundf(state * max_duty);
auto duty = static_cast<uint16_t>(duty_rounded);

View file

@ -25,7 +25,7 @@ class PCA9685Channel : public output::FloatOutput {
PCA9685Channel(PCA9685Output *parent, uint8_t channel) : parent_(parent), channel_(channel) {}
protected:
void write_state(float state) override;
void write_state_(float state) override;
PCA9685Output *parent_;
uint8_t channel_;

View file

@ -93,12 +93,7 @@ bool PCF8574Component::write_gpio_() {
data = (value >> 8) & 0xFF;
this->parent_->raw_write(this->address_, &data, 1);
}
if (!this->parent_->raw_end_transmission(this->address_)) {
this->status_set_warning();
return false;
}
this->status_clear_warning();
return true;
return !;
}
float PCF8574Component::get_setup_priority() const { return setup_priority::IO; }

View file

@ -45,7 +45,7 @@ void PMSX003Component::loop() {
}
}
float PMSX003Component::get_setup_priority() const { return setup_priority::DATA; }
optional<bool> PMSX003Component::check_byte_() {
optional<bool> PMSX003Component::check_byte() {
uint8_t index = this->data_index_;
uint8_t byte = this->data_[index];
@ -158,7 +158,7 @@ void PMSX003Component::parse_data_() {
this->status_clear_warning();
}
uint16_t PMSX003Component::get_16_bit_uint_(uint8_t start_index) {
uint16_t PMSX003Component::get_16_bit_uint(uint8_t start_index) {
return (uint16_t(this->data_[start_index]) << 8) | uint16_t(this->data_[start_index + 1]);
}
void PMSX003Component::dump_config() {

View file

@ -154,7 +154,7 @@ void PN532::loop() {
float PN532::get_setup_priority() const { return setup_priority::DATA; }
void PN532::pn532_write_command_(const std::vector<uint8_t> &data) {
void PN532::pn532_write_command(const std::vector<uint8_t> &data) {
this->enable();
delay(2);
// First byte, communication mode: Write data
@ -193,7 +193,7 @@ void PN532::pn532_write_command_(const std::vector<uint8_t> &data) {
this->disable();
}
bool PN532::pn532_write_command_check_ack_(const std::vector<uint8_t> &data) {
bool PN532::pn532_write_command_check_ack(const std::vector<uint8_t> &data) {
// 1. write command
this->pn532_write_command_(data);
@ -210,7 +210,7 @@ bool PN532::pn532_write_command_check_ack_(const std::vector<uint8_t> &data) {
return true;
}
std::vector<uint8_t> PN532::pn532_read_data_() {
std::vector<uint8_t> PN532::pn532_read_data() {
this->enable();
delay(2);
// Read data (transmission from the PN532 to the host)

View file

@ -33,13 +33,7 @@ class RDM6300BinarySensor : public binary_sensor::BinarySensor {
void set_id(uint32_t id) { id_ = id; }
bool process(uint32_t id) {
if (this->id_ == id) {
this->publish_state(true);
yield();
this->publish_state(false);
return true;
}
return false;
return ;
}
protected:

View file

@ -22,7 +22,7 @@ DECLARE_REMOTE_PROTOCOL(JVC)
template<typename... Ts> class JVCAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(uint32_t, data)
templatable_value(uint32_t, data)
void encode(RemoteTransmitData *dst, Ts... x) override {
JVCData data{};
data.data = this->data_.value(x...);

View file

@ -24,7 +24,7 @@ DECLARE_REMOTE_PROTOCOL(LG)
template<typename... Ts> class LGAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(uint32_t, data)
templatable_value(uint32_t, data)
TEMPLATABLE_VALUE(uint8_t, nbits)
void encode(RemoteTransmitData *dst, Ts... x) override {
LGData data{};

View file

@ -23,7 +23,7 @@ DECLARE_REMOTE_PROTOCOL(NEC)
template<typename... Ts> class NECAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(uint16_t, address)
templatable_value(uint16_t, address)
TEMPLATABLE_VALUE(uint16_t, command)
void encode(RemoteTransmitData *dst, Ts... x) override {
NECData data{};

View file

@ -24,7 +24,7 @@ DECLARE_REMOTE_PROTOCOL(Panasonic)
template<typename... Ts> class PanasonicAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(uint16_t, address)
templatable_value(uint16_t, address)
TEMPLATABLE_VALUE(uint32_t, command)
void encode(RemoteTransmitData *dst, Ts... x) override {
PanasonicData data{};

View file

@ -44,7 +44,7 @@ template<typename... Ts> class RawAction : public RemoteTransmitterActionBase<Ts
this->code_static_ = code;
this->code_static_len_ = len;
}
TEMPLATABLE_VALUE(uint32_t, carrier_frequency);
templatable_value(uint32_t, carrier_frequency);
void encode(RemoteTransmitData *dst, Ts... x) override {
if (this->code_static_ != nullptr) {
@ -62,7 +62,7 @@ template<typename... Ts> class RawAction : public RemoteTransmitterActionBase<Ts
}
protected:
std::function<std::vector<int32_t>(Ts...)> code_func_{};
std::function<std::vector<int32_t>(ts_...)> code_func_{};
const int32_t *code_static_{nullptr};
int32_t code_static_len_{0};
};

View file

@ -24,7 +24,7 @@ DECLARE_REMOTE_PROTOCOL(RC5)
template<typename... Ts> class RC5Action : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(uint8_t, address)
templatable_value(uint8_t, address)
TEMPLATABLE_VALUE(uint8_t, command)
void encode(RemoteTransmitData *dst, Ts... x) override {
RC5Data data{};

View file

@ -57,8 +57,8 @@ uint32_t decode_binary_string(const std::string &data);
template<typename... Ts> class RCSwitchRawAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(RCSwitchBase, protocol);
TEMPLATABLE_VALUE(std::string, code);
templatable_value(RCSwitchBase, protocol);
templatable_value(std::string, code);
void encode(RemoteTransmitData *dst, Ts... x) override {
auto code = this->code_.value(x...);
@ -72,10 +72,10 @@ template<typename... Ts> class RCSwitchRawAction : public RemoteTransmitterActio
template<typename... Ts> class RCSwitchTypeAAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(RCSwitchBase, protocol);
TEMPLATABLE_VALUE(std::string, group);
TEMPLATABLE_VALUE(std::string, device);
TEMPLATABLE_VALUE(bool, state);
templatable_value(RCSwitchBase, protocol);
templatable_value(std::string, group);
templatable_value(std::string, device);
templatable_value(bool, state);
void encode(RemoteTransmitData *dst, Ts... x) override {
auto group = this->group_.value(x...);
@ -95,10 +95,10 @@ template<typename... Ts> class RCSwitchTypeAAction : public RemoteTransmitterAct
template<typename... Ts> class RCSwitchTypeBAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(RCSwitchBase, protocol);
TEMPLATABLE_VALUE(uint8_t, address);
TEMPLATABLE_VALUE(uint8_t, channel);
TEMPLATABLE_VALUE(bool, state);
templatable_value(RCSwitchBase, protocol);
templatable_value(uint8_t, address);
templatable_value(uint8_t, channel);
templatable_value(bool, state);
void encode(RemoteTransmitData *dst, Ts... x) override {
auto address = this->address_.value(x...);
@ -116,11 +116,11 @@ template<typename... Ts> class RCSwitchTypeBAction : public RemoteTransmitterAct
template<typename... Ts> class RCSwitchTypeCAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(RCSwitchBase, protocol);
TEMPLATABLE_VALUE(std::string, family);
TEMPLATABLE_VALUE(uint8_t, group);
TEMPLATABLE_VALUE(uint8_t, device);
TEMPLATABLE_VALUE(bool, state);
templatable_value(RCSwitchBase, protocol);
templatable_value(std::string, family);
templatable_value(uint8_t, group);
templatable_value(uint8_t, device);
templatable_value(bool, state);
void encode(RemoteTransmitData *dst, Ts... x) override {
auto family = this->family_.value(x...);
@ -140,10 +140,10 @@ template<typename... Ts> class RCSwitchTypeCAction : public RemoteTransmitterAct
};
template<typename... Ts> class RCSwitchTypeDAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(RCSwitchBase, protocol);
TEMPLATABLE_VALUE(std::string, group);
TEMPLATABLE_VALUE(uint8_t, device);
TEMPLATABLE_VALUE(bool, state);
templatable_value(RCSwitchBase, protocol);
templatable_value(std::string, group);
templatable_value(uint8_t, device);
templatable_value(bool, state);
void encode(RemoteTransmitData *dst, Ts... x) override {
auto group = this->group_.value(x...);

View file

@ -16,7 +16,7 @@ RemoteComponentBase::RemoteComponentBase(GPIOPin *pin) : pin_(pin) {
void RemoteReceiverBinarySensorBase::dump_config() { LOG_BINARY_SENSOR("", "Remote Receiver Binary Sensor", this); }
void RemoteTransmitterBase::send_(uint32_t send_times, uint32_t send_wait) {
void RemoteTransmitterBase::send(uint32_t send_times, uint32_t send_wait) {
#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
const std::vector<int32_t> &vec = this->temp_.get_data();
char buffer[256];

View file

@ -93,27 +93,15 @@ class RemoteReceiveData {
void advance(uint32_t amount = 1) { this->index_ += amount; }
bool expect_mark(uint32_t length) {
if (this->peek_mark(length)) {
this->advance();
return true;
}
return false;
return ;
}
bool expect_space(uint32_t length) {
if (this->peek_space(length)) {
this->advance();
return true;
}
return false;
return ;
}
bool expect_item(uint32_t mark, uint32_t space) {
if (this->peek_item(mark, space)) {
this->advance(2);
return true;
}
return false;
return ;
}
void reset() { this->index_ = 0; }
@ -275,13 +263,7 @@ class RemoteReceiverBinarySensorBase : public binary_sensor::BinarySensor,
void dump_config() override;
virtual bool matches(RemoteReceiveData src) = 0;
bool on_receive(RemoteReceiveData src) override {
if (this->matches(src)) {
this->publish_state(true);
yield();
this->publish_state(false);
return true;
}
return false;
return this->matches(src);
}
};
@ -330,8 +312,8 @@ template<typename... Ts> class RemoteTransmitterActionBase : public Action<Ts...
virtual void encode(RemoteTransmitData *dst, Ts... x) = 0;
TEMPLATABLE_VALUE(uint32_t, send_times);
TEMPLATABLE_VALUE(uint32_t, send_wait);
templatable_value(uint32_t, send_times);
templatable_value(uint32_t, send_wait);
protected:
RemoteTransmitterBase *parent_{};

View file

@ -23,7 +23,7 @@ DECLARE_REMOTE_PROTOCOL(Samsung)
template<typename... Ts> class SamsungAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(uint32_t, data)
templatable_value(uint32_t, data)
void encode(RemoteTransmitData *dst, Ts... x) override {
SamsungData data{};
data.data = this->data_.value(x...);

View file

@ -24,7 +24,7 @@ DECLARE_REMOTE_PROTOCOL(Sony)
template<typename... Ts> class SonyAction : public RemoteTransmitterActionBase<Ts...> {
public:
TEMPLATABLE_VALUE(uint32_t, data)
templatable_value(uint32_t, data)
TEMPLATABLE_VALUE(uint8_t, nbits)
void encode(RemoteTransmitData *dst, Ts... x) override {
SonyData data{};

View file

@ -19,7 +19,7 @@ class RemoteTransmitterComponent : public remote_base::RemoteTransmitterBase, pu
void set_carrier_duty_percent(uint8_t carrier_duty_percent) { this->carrier_duty_percent_ = carrier_duty_percent; }
protected:
void send_internal(uint32_t send_times, uint32_t send_wait) override;
void send_internal_(uint32_t send_times, uint32_t send_wait) override;
#ifdef ARDUINO_ARCH_ESP8266
void calculate_on_off_time_(uint32_t carrier_frequency, uint32_t *on_time_period, uint32_t *off_time_period);

View file

@ -20,7 +20,7 @@ void RemoteTransmitterComponent::dump_config() {
LOG_PIN(" Pin: ", this->pin_);
}
void RemoteTransmitterComponent::calculate_on_off_time_(uint32_t carrier_frequency, uint32_t *on_time_period,
void RemoteTransmitterComponent::calculate_on_off_time(uint32_t carrier_frequency, uint32_t *on_time_period,
uint32_t *off_time_period) {
if (carrier_frequency == 0) {
*on_time_period = 0;
@ -33,7 +33,7 @@ void RemoteTransmitterComponent::calculate_on_off_time_(uint32_t carrier_frequen
*off_time_period = period - *on_time_period;
}
void RemoteTransmitterComponent::mark_(uint32_t on_time, uint32_t off_time, uint32_t usec) {
void RemoteTransmitterComponent::mark(uint32_t on_time, uint32_t off_time, uint32_t usec) {
if (this->carrier_duty_percent_ == 100 || (on_time == 0 && off_time == 0)) {
this->pin_->digital_write(true);
delay_microseconds_accurate(usec);
@ -58,7 +58,7 @@ void RemoteTransmitterComponent::mark_(uint32_t on_time, uint32_t off_time, uint
current_time = micros();
}
}
void RemoteTransmitterComponent::space_(uint32_t usec) {
void RemoteTransmitterComponent::space(uint32_t usec) {
this->pin_->digital_write(false);
delay_microseconds_accurate(usec);
}

View file

@ -7,7 +7,7 @@ namespace restart {
static const char *TAG = "restart";
void RestartSwitch::write_state(bool state) {
void RestartSwitch::write_state_(bool state) {
// Acknowledge
this->publish_state(false);

View file

@ -11,7 +11,7 @@ class RestartSwitch : public switch_::Switch, public Component {
void dump_config() override;
protected:
void write_state(bool state) override;
void write_state_(bool state) override;
};
} // namespace restart

View file

@ -93,7 +93,7 @@ float SDS011Component::get_setup_priority() const { return setup_priority::DATA;
void SDS011Component::set_rx_mode_only(bool rx_mode_only) { this->rx_mode_only_ = rx_mode_only; }
void SDS011Component::sds011_write_command_(const uint8_t *command_data) {
void SDS011Component::sds011_write_command(const uint8_t *command_data) {
this->flush();
this->write_byte(SDS011_MSG_HEAD);
this->write_byte(SDS011_COMMAND_ID_REQUEST);
@ -102,7 +102,7 @@ void SDS011Component::sds011_write_command_(const uint8_t *command_data) {
this->write_byte(SDS011_MSG_TAIL);
}
uint8_t SDS011Component::sds011_checksum_(const uint8_t *command_data, uint8_t length) const {
uint8_t SDS011Component::sds011_checksum(const uint8_t *command_data, uint8_t length) const {
uint8_t sum = 0;
for (uint8_t i = 0; i < length; i++) {
sum += command_data[i];
@ -110,7 +110,7 @@ uint8_t SDS011Component::sds011_checksum_(const uint8_t *command_data, uint8_t l
return sum;
}
optional<bool> SDS011Component::check_byte_() const {
optional<bool> SDS011Component::check_byte() const {
uint8_t index = this->data_index_;
uint8_t byte = this->data_[index];
@ -164,7 +164,7 @@ void SDS011Component::parse_data_() {
}
}
uint16_t SDS011Component::get_16_bit_uint_(uint8_t start_index) const {
uint16_t SDS011Component::get_16_bit_uint(uint8_t start_index) const {
return (uint16_t(this->data_[start_index + 1]) << 8) | uint16_t(this->data_[start_index]);
}
void SDS011Component::set_update_interval_min(uint8_t update_interval_min) {

View file

@ -24,7 +24,7 @@ class SensorRawStateTrigger : public Trigger<float> {
template<typename... Ts> class SensorPublishAction : public Action<Ts...> {
public:
SensorPublishAction(Sensor *sensor) : sensor_(sensor) {}
TEMPLATABLE_VALUE(float, state)
templatable_value(float, state)
void play(Ts... x) override { this->sensor_->publish_state(this->state_.value(x...)); }
protected:

View file

@ -162,7 +162,7 @@ class Sensor : public Nameable {
/// Return the accuracy in decimals for this sensor.
virtual int8_t accuracy_decimals(); // NOLINT
uint32_t hash_base() override;
uint32_t hash_base_() override;
CallbackManager<void(float)> raw_callback_; ///< Storage for raw state callbacks.
CallbackManager<void(float)> callback_; ///< Storage for filtered state callbacks.

View file

@ -62,7 +62,7 @@ class Servo : public Component {
template<typename... Ts> class ServoWriteAction : public Action<Ts...> {
public:
ServoWriteAction(Servo *servo) : servo_(servo) {}
TEMPLATABLE_VALUE(float, value)
templatable_value(float, value)
void play(Ts... x) override { this->servo_->write(this->value_.value(x...)); }
protected:

View file

@ -65,7 +65,7 @@ void SHT3XDComponent::update() {
});
}
bool SHT3XDComponent::write_command_(uint16_t command) {
bool SHT3XDComponent::write_command(uint16_t command) {
// Warning ugly, trick the I2Ccomponent base by setting register to the first 8 bit.
return this->write_byte(command >> 8, command & 0xFF);
}
@ -93,28 +93,11 @@ uint8_t sht_crc(uint8_t data1, uint8_t data2) {
return crc;
}
bool SHT3XDComponent::read_data_(uint16_t *data, uint8_t len) {
bool SHT3XDComponent::read_data(uint16_t *data, uint8_t len) {
const uint8_t num_bytes = len * 3;
auto *buf = new uint8_t[num_bytes];
if (!this->parent_->raw_receive(this->address_, buf, num_bytes)) {
delete[](buf);
return false;
}
for (uint8_t i = 0; i < len; i++) {
const uint8_t j = 3 * i;
uint8_t crc = sht_crc(buf[j], buf[j + 1]);
if (crc != buf[j + 2]) {
ESP_LOGE(TAG, "CRC8 Checksum invalid! 0x%02X != 0x%02X", buf[j + 2], crc);
delete[](buf);
return false;
}
data[i] = (buf[j] << 8) | buf[j + 1];
}
delete[](buf);
return true;
return !;
}
} // namespace sht3xd

View file

@ -8,7 +8,7 @@ namespace shutdown {
static const char *TAG = "shutdown.switch";
void ShutdownSwitch::dump_config() { LOG_SWITCH("", "Shutdown Switch", this); }
void ShutdownSwitch::write_state(bool state) {
void ShutdownSwitch::write_state_(bool state) {
// Acknowledge
this->publish_state(false);

View file

@ -11,7 +11,7 @@ class ShutdownSwitch : public switch_::Switch, public Component {
void dump_config() override;
protected:
void write_state(bool state) override;
void write_state_(bool state) override;
};
} // namespace shutdown

View file

@ -30,7 +30,7 @@ class SM16716 : public Component {
void set_channel(uint8_t channel) { channel_ = channel; }
protected:
void write_state(float state) override {
void write_state_(float state) override {
auto amount = uint8_t(state * 0xFF);
this->parent_->set_channel_value_(this->channel_, amount);
}

View file

@ -143,7 +143,7 @@ void SSD1306::update() {
this->do_update_();
this->display();
}
int SSD1306::get_height_internal() {
int SSD1306::get_height_internal_() {
switch (this->model_) {
case SSD1306_MODEL_128_32:
case SH1106_MODEL_128_32:
@ -161,7 +161,7 @@ int SSD1306::get_height_internal() {
return 0;
}
}
int SSD1306::get_width_internal() {
int SSD1306::get_width_internal_() {
switch (this->model_) {
case SSD1306_MODEL_128_32:
case SH1106_MODEL_128_32:
@ -178,7 +178,7 @@ int SSD1306::get_width_internal() {
return 0;
}
}
size_t SSD1306::get_buffer_length_() {
size_t SSD1306::get_buffer_length() {
return size_t(this->get_width_internal()) * size_t(this->get_height_internal()) / 8u;
}

View file

@ -40,10 +40,10 @@ class SSD1306 : public PollingComponent, public display::DisplayBuffer {
bool is_sh1106_() const;
void draw_absolute_pixel_internal(int x, int y, int color) override;
void draw_absolute_pixel_internal_(int x, int y, int color) override;
int get_height_internal() override;
int get_width_internal() override;
int get_height_internal_() override;
int get_width_internal_() override;
size_t get_buffer_length_();
const char *model_str_();

View file

@ -13,8 +13,8 @@ class I2CSSD1306 : public ssd1306_base::SSD1306, public i2c::I2CDevice {
void dump_config() override;
protected:
void command(uint8_t value) override;
void write_display_data() override;
void command_(uint8_t value) override;
void write_display_data_() override;
enum ErrorCode { NONE = 0, COMMUNICATION_FAILED } error_code_{NONE};
};

View file

@ -18,9 +18,9 @@ class SPISSD1306 : public ssd1306_base::SSD1306,
void dump_config() override;
protected:
void command(uint8_t value) override;
void command_(uint8_t value) override;
void write_display_data() override;
void write_display_data_() override;
GPIOPin *dc_pin_;
};

View file

@ -6,7 +6,7 @@ namespace stepper {
static const char *TAG = "stepper";
void Stepper::calculate_speed_(uint32_t now) {
void Stepper::calculate_speed(uint32_t now) {
// delta t since last calculation in seconds
float dt = (now - this->last_calculation_) * 1e-6f;
this->last_calculation_ = now;
@ -28,7 +28,7 @@ void Stepper::calculate_speed_(uint32_t now) {
}
this->current_speed_ = clamp(this->current_speed_, 0.0f, this->max_speed_);
}
int32_t Stepper::should_step_() {
int32_t Stepper::should_step() {
uint32_t now = micros();
this->calculate_speed_(now);
if (this->current_speed_ == 0.0f)

View file

@ -41,7 +41,7 @@ template<typename... Ts> class SetTargetAction : public Action<Ts...> {
public:
explicit SetTargetAction(Stepper *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(int32_t, target)
templatable_value(int32_t, target)
void play(Ts... x) override { this->parent_->set_target(this->target_.value(x...)); }
@ -53,7 +53,7 @@ template<typename... Ts> class ReportPositionAction : public Action<Ts...> {
public:
explicit ReportPositionAction(Stepper *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(int32_t, position)
templatable_value(int32_t, position)
void play(Ts... x) override { this->parent_->report_position(this->position_.value(x...)); }
@ -65,7 +65,7 @@ template<typename... Ts> class SetSpeedAction : public Action<Ts...> {
public:
explicit SetSpeedAction(Stepper *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(float, speed);
templatable_value(float, speed);
void play(Ts... x) override {
float speed = this->speed_.value(x...);

View file

@ -101,7 +101,7 @@ double Sun::azimuth_rad_(double sun_time) {
return az;
}
double Sun::azimuth_(double sun_time) { return this->azimuth_rad_(sun_time) * TO_DEGREES; }
double Sun::calc_sun_time_(const time::ESPTime &time) {
double Sun::calc_sun_time(const time::ESPTime &time) {
// Time as seen at 0° longitude
if (!time.is_valid())
return NAN;
@ -111,7 +111,7 @@ double Sun::calc_sun_time_(const time::ESPTime &time) {
double add = this->longitude_ / 360.0;
return base + add;
}
uint32_t Sun::calc_epoch_(time::ESPTime base, double sun_time) {
uint32_t Sun::calc_epoch(time::ESPTime base, double sun_time) {
sun_time -= this->longitude_ / 360.0;
base.day_of_year = uint32_t(floor(sun_time));
@ -127,7 +127,7 @@ uint32_t Sun::calc_epoch_(time::ESPTime base, double sun_time) {
base.recalc_timestamp_utc(true);
return base.timestamp;
}
double Sun::sun_time_for_elevation_(int32_t day_of_year, double elevation, bool rising) {
double Sun::sun_time_for_elevation(int32_t day_of_year, double elevation, bool rising) {
// Use binary search, newton's method would be better but binary search already
// converges quite well (19 cycles) and much simpler. Function is guaranteed to be
// monotonous.

View file

@ -117,7 +117,7 @@ class SunTrigger : public Trigger<>, public PollingComponent, public Parented<Su
template<typename... Ts> class SunCondition : public Condition<Ts...>, public Parented<Sun> {
public:
TEMPLATABLE_VALUE(double, elevation);
templatable_value(double, elevation);
void set_above(bool above) { above_ = above; }
bool check(Ts... x) override {

View file

@ -72,7 +72,7 @@ class SwitchTurnOffTrigger : public Trigger<> {
template<typename... Ts> class SwitchPublishAction : public Action<Ts...> {
public:
SwitchPublishAction(Switch *a_switch) : switch_(a_switch) {}
TEMPLATABLE_VALUE(bool, state)
templatable_value(bool, state)
void play(Ts... x) override { this->switch_->publish_state(this->state_.value(x...)); }
protected:

View file

@ -112,7 +112,7 @@ class Switch : public Nameable {
*/
virtual std::string icon(); // NOLINT
uint32_t hash_base() override;
uint32_t hash_base_() override;
optional<std::string> icon_{}; ///< The icon shown here. Not set means use default from switch. Empty means no icon.

View file

@ -22,9 +22,9 @@ class Tcl112Climate : public climate::Climate, public Component {
protected:
/// Override control to change settings of the climate device.
void control(const climate::ClimateCall &call) override;
void control_(const climate::ClimateCall &call) override;
/// Return the traits of this controller.
climate::ClimateTraits traits() override;
climate::ClimateTraits traits_() override;
/// Transmit via IR the state of this climate controller.
void transmit_state_();

Some files were not shown because too many files have changed in this diff Show more