1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 05:12:21 +01:00

fix: correct state variable references and update write_state method in DynamicLampComponent

This commit is contained in:
Oliver Kleinecke
2025-02-15 16:35:08 +01:00
parent 7d306cb5c3
commit 62a0c5775f
3 changed files with 4 additions and 3 deletions

View File

@@ -64,7 +64,7 @@ void DynamicLampComponent::loop() {
new_state = this->available_outputs_[j].mode_value;
break;
case MODE_PERCENTAGE:
new_state = this->active_lamps_[i].state * this->available_outputs_[j].mode_value;
new_state = this->active_lamps_[i].state_ * this->available_outputs_[j].mode_value;
if (this->available_outputs_[j].min_value && new_state < *this->available_outputs_[j].min_value) {
new_state = *this->available_outputs_[j].min_value;
}
@@ -217,7 +217,7 @@ void DynamicLampComponent::set_lamp_level(std::string lamp_name, float state) {
}
bool DynamicLampComponent::write_state(uint8_t lamp_number, float state) {
bool DynamicLampComponent::write_state_(uint8_t lamp_number, float state) {
if (this->active_lamps_[lamp_number].active) {
this->active_lamps_[lamp_number].state_ = state;
this->active_lamps_[lamp_number].update_ = true;

View File

@@ -82,6 +82,7 @@ class DynamicLampComponent : public Component {
void set_lamp_level(std::string lamp_name, float state);
void restore_lamp_values_(uint8_t lamp_number);
void set_lamp_values_(uint8_t lamp_number, bool active, uint16_t selected_outputs, uint8_t mode, uint8_t mode_value);
bool write_state_(uint8_t lamp_number, float state);
CombinedLamp active_lamps_[16];
LinkedOutput available_outputs_[16];

View File

@@ -8,7 +8,7 @@ namespace dynamic_lamp {
static const char *const TAG = "dynamic_lamp.output";
void DynamicLamp::write_state(float state) {
if (this->parent_->write_state(this->lamp_, state)) {
if (this->parent_->write_state_(this->lamp_, state)) {
this->state_ = state;
}