mirror of
https://github.com/esphome/esphome.git
synced 2025-03-15 15:18:16 +00:00
fix: improve lamp name comparison in remove_output_from_lamp and get_lamp_index_by_name_ functions of DynamicLampComponent
This commit is contained in:
parent
612ee82183
commit
24c2d33c7b
@ -209,6 +209,7 @@ void DynamicLampComponent::remove_output_from_lamp(std::string lamp_name, Linked
|
|||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
while (i < 16) {
|
while (i < 16) {
|
||||||
if (this->active_lamps_[i].name == lamp_name) {
|
if (this->active_lamps_[i].name == lamp_name) {
|
||||||
|
uint8_t k = output->output_index;
|
||||||
uint8_t j = 0;
|
uint8_t j = 0;
|
||||||
if (output->output_index > 7) {
|
if (output->output_index > 7) {
|
||||||
j = 1;
|
j = 1;
|
||||||
@ -243,7 +244,8 @@ std::array<bool, 16> DynamicLampComponent::get_lamp_outputs(uint8_t lamp_number)
|
|||||||
uint8_t DynamicLampComponent::get_lamp_index_by_name_(std::string lamp_name) {
|
uint8_t DynamicLampComponent::get_lamp_index_by_name_(std::string lamp_name) {
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
for (i = 0; i < this->lamp_count_; i++) {
|
for (i = 0; i < this->lamp_count_; i++) {
|
||||||
if (this->active_lamps_[i].name == lamp_name) {
|
std::string str(this->active_lamps_[i].name, this->active_lamps_[i].name + sizeof this->active_lamps_[i].name / sizeof this->active_lamps_[i].name[0]);
|
||||||
|
if (str == lamp_name) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user