mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-04 09:01:49 +00:00 
			
		
		
		
	fix: correct state variable references and update write_state method in DynamicLampComponent
This commit is contained in:
		@@ -64,7 +64,7 @@ void DynamicLampComponent::loop() {
 | 
				
			|||||||
              new_state = this->available_outputs_[j].mode_value;
 | 
					              new_state = this->available_outputs_[j].mode_value;
 | 
				
			||||||
              break;
 | 
					              break;
 | 
				
			||||||
            case MODE_PERCENTAGE:
 | 
					            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) {
 | 
					              if (this->available_outputs_[j].min_value && new_state < *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) {
 | 
					  if (this->active_lamps_[lamp_number].active) {
 | 
				
			||||||
    this->active_lamps_[lamp_number].state_ = state;
 | 
					    this->active_lamps_[lamp_number].state_ = state;
 | 
				
			||||||
    this->active_lamps_[lamp_number].update_ = true;
 | 
					    this->active_lamps_[lamp_number].update_ = true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -82,6 +82,7 @@ class DynamicLampComponent : public Component {
 | 
				
			|||||||
  void set_lamp_level(std::string lamp_name, float state);
 | 
					  void set_lamp_level(std::string lamp_name, float state);
 | 
				
			||||||
  void restore_lamp_values_(uint8_t lamp_number);
 | 
					  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);
 | 
					  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];
 | 
					  CombinedLamp active_lamps_[16];
 | 
				
			||||||
  LinkedOutput available_outputs_[16];
 | 
					  LinkedOutput available_outputs_[16];
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@ namespace dynamic_lamp {
 | 
				
			|||||||
static const char *const TAG = "dynamic_lamp.output";
 | 
					static const char *const TAG = "dynamic_lamp.output";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DynamicLamp::write_state(float state) {
 | 
					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;
 | 
					    this->state_ = state;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user