mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
parent
bdc6302ea1
commit
4c383906c4
2 changed files with 4 additions and 4 deletions
|
@ -790,7 +790,7 @@ uint8_t Pipsolar::check_incoming_crc_() {
|
|||
// send next command used
|
||||
uint8_t Pipsolar::send_next_command_() {
|
||||
uint16_t crc16;
|
||||
if (this->command_queue_[this->command_queue_position_].length() != 0) {
|
||||
if (!this->command_queue_[this->command_queue_position_].empty()) {
|
||||
const char *command = this->command_queue_[this->command_queue_position_].c_str();
|
||||
uint8_t byte_command[16];
|
||||
uint8_t length = this->command_queue_[this->command_queue_position_].length();
|
||||
|
@ -846,7 +846,7 @@ void Pipsolar::queue_command_(const char *command, uint8_t length) {
|
|||
uint8_t next_position = command_queue_position_;
|
||||
for (uint8_t i = 0; i < COMMAND_QUEUE_LENGTH; i++) {
|
||||
uint8_t testposition = (next_position + i) % COMMAND_QUEUE_LENGTH;
|
||||
if (command_queue_[testposition].length() == 0) {
|
||||
if (command_queue_[testposition].empty()) {
|
||||
command_queue_[testposition] = command;
|
||||
ESP_LOGD(TAG, "Command queued successfully: %s with length %u at position %d", command,
|
||||
command_queue_[testposition].length(), testposition);
|
||||
|
|
|
@ -10,11 +10,11 @@ static const char *const TAG = "pipsolar.switch";
|
|||
void PipsolarSwitch::dump_config() { LOG_SWITCH("", "Pipsolar Switch", this); }
|
||||
void PipsolarSwitch::write_state(bool state) {
|
||||
if (state) {
|
||||
if (this->on_command_.length() > 0) {
|
||||
if (!this->on_command_.empty()) {
|
||||
this->parent_->switch_command(this->on_command_);
|
||||
}
|
||||
} else {
|
||||
if (this->off_command_.length() > 0) {
|
||||
if (!this->off_command_.empty()) {
|
||||
this->parent_->switch_command(this->off_command_);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue