mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Add support for fan preset modes (#5694)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
		| @@ -12,6 +12,7 @@ void CopyFan::setup() { | ||||
|     this->oscillating = source_->oscillating; | ||||
|     this->speed = source_->speed; | ||||
|     this->direction = source_->direction; | ||||
|     this->preset_mode = source_->preset_mode; | ||||
|     this->publish_state(); | ||||
|   }); | ||||
|  | ||||
| @@ -19,6 +20,7 @@ void CopyFan::setup() { | ||||
|   this->oscillating = source_->oscillating; | ||||
|   this->speed = source_->speed; | ||||
|   this->direction = source_->direction; | ||||
|   this->preset_mode = source_->preset_mode; | ||||
|   this->publish_state(); | ||||
| } | ||||
|  | ||||
| @@ -33,6 +35,7 @@ fan::FanTraits CopyFan::get_traits() { | ||||
|   traits.set_speed(base.supports_speed()); | ||||
|   traits.set_supported_speed_count(base.supported_speed_count()); | ||||
|   traits.set_direction(base.supports_direction()); | ||||
|   traits.set_supported_preset_modes(base.supported_preset_modes()); | ||||
|   return traits; | ||||
| } | ||||
|  | ||||
| @@ -46,6 +49,8 @@ void CopyFan::control(const fan::FanCall &call) { | ||||
|     call2.set_speed(*call.get_speed()); | ||||
|   if (call.get_direction().has_value()) | ||||
|     call2.set_direction(*call.get_direction()); | ||||
|   if (!call.get_preset_mode().empty()) | ||||
|     call2.set_preset_mode(call.get_preset_mode()); | ||||
|   call2.perform(); | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user