diff --git a/esphome/components/bl0910/bl0910.cpp b/esphome/components/bl0910/bl0910.cpp index 1fcfa21728..67c9da4bff 100644 --- a/esphome/components/bl0910/bl0910.cpp +++ b/esphome/components/bl0910/bl0910.cpp @@ -35,7 +35,6 @@ void BL0910::write_register(uint8_t addr, uint8_t data_h, uint8_t data_m, uint8_ } int32_t BL0910::read_register(uint8_t addr) { - int32_t data = 0; uint8_t packet[6] = {0}; packet[0] = BL0910_READ_COMMAND; @@ -94,17 +93,22 @@ void BL0910::update() { this->current_channel_ = 0; } void BL0910::loop() { if (this->current_channel_ < NUM_CHANNELS) { - if (voltage_sensor_[this->current_channel_]) + if (voltage_sensor_[this->current_channel_]) { voltage_sensor_[this->current_channel_]->publish_state(this->get_voltage(this->current_channel_)); - if (current_sensor_[this->current_channel_]) + } + if (current_sensor_[this->current_channel_]) { current_sensor_[this->current_channel_]->publish_state(this->get_current(this->current_channel_)); - if (power_sensor_[this->current_channel_]) + } + if (power_sensor_[this->current_channel_]) { power_sensor_[this->current_channel_]->publish_state(this->get_power(this->current_channel_)); - if (energy_sensor_[this->current_channel_]) + } + if (energy_sensor_[this->current_channel_]) { energy_sensor_[this->current_channel_]->publish_state(this->get_energy(this->current_channel_)); - if (power_factor_sensor_[this->current_channel_]) + } + if (power_factor_sensor_[this->current_channel_]) { power_factor_sensor_[this->current_channel_]->publish_state( this->get_powerfactor(this->current_channel_, this->freq_)); + } this->current_channel_++; } else if (this->current_channel_ == NUM_CHANNELS) { this->freq_ = this->get_frequency(); diff --git a/esphome/components/bl0910/bl0910.h b/esphome/components/bl0910/bl0910.h index a08babf382..26e5c3cd18 100644 --- a/esphome/components/bl0910/bl0910.h +++ b/esphome/components/bl0910/bl0910.h @@ -66,7 +66,6 @@ class BL0910 : public PollingComponent, uint8_t current_channel_ = 0; float freq_ = 50.0; - protected: void write_register(uint8_t addr, uint32_t data) { return this->write_register(addr, (data >> 16) & 0xFF, (data >> 8) & 0xFF, data & 0xFF); }