mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	| @@ -790,7 +790,7 @@ uint8_t Pipsolar::check_incoming_crc_() { | |||||||
| // send next command used | // send next command used | ||||||
| uint8_t Pipsolar::send_next_command_() { | uint8_t Pipsolar::send_next_command_() { | ||||||
|   uint16_t crc16; |   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(); |     const char *command = this->command_queue_[this->command_queue_position_].c_str(); | ||||||
|     uint8_t byte_command[16]; |     uint8_t byte_command[16]; | ||||||
|     uint8_t length = this->command_queue_[this->command_queue_position_].length(); |     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_; |   uint8_t next_position = command_queue_position_; | ||||||
|   for (uint8_t i = 0; i < COMMAND_QUEUE_LENGTH; i++) { |   for (uint8_t i = 0; i < COMMAND_QUEUE_LENGTH; i++) { | ||||||
|     uint8_t testposition = (next_position + i) % COMMAND_QUEUE_LENGTH; |     uint8_t testposition = (next_position + i) % COMMAND_QUEUE_LENGTH; | ||||||
|     if (command_queue_[testposition].length() == 0) { |     if (command_queue_[testposition].empty()) { | ||||||
|       command_queue_[testposition] = command; |       command_queue_[testposition] = command; | ||||||
|       ESP_LOGD(TAG, "Command queued successfully: %s with length %u at position %d", command, |       ESP_LOGD(TAG, "Command queued successfully: %s with length %u at position %d", command, | ||||||
|                command_queue_[testposition].length(), testposition); |                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::dump_config() { LOG_SWITCH("", "Pipsolar Switch", this); } | ||||||
| void PipsolarSwitch::write_state(bool state) { | void PipsolarSwitch::write_state(bool state) { | ||||||
|   if (state) { |   if (state) { | ||||||
|     if (this->on_command_.length() > 0) { |     if (!this->on_command_.empty()) { | ||||||
|       this->parent_->switch_command(this->on_command_); |       this->parent_->switch_command(this->on_command_); | ||||||
|     } |     } | ||||||
|   } else { |   } else { | ||||||
|     if (this->off_command_.length() > 0) { |     if (!this->off_command_.empty()) { | ||||||
|       this->parent_->switch_command(this->off_command_); |       this->parent_->switch_command(this->off_command_); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user