1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00:00

Refactor fan platform to resemble climate/cover platforms (#2848)

Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
Co-authored-by: rob-deutsch <robzyb+altgithub@gmail.com>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Oxan van Leeuwen
2022-01-23 10:21:54 +01:00
committed by GitHub
parent 8187a4bce9
commit 2a84db7f85
41 changed files with 593 additions and 506 deletions

View File

@@ -81,7 +81,7 @@ class Application {
#endif
#ifdef USE_FAN
void register_fan(fan::FanState *state) { this->fans_.push_back(state); }
void register_fan(fan::Fan *state) { this->fans_.push_back(state); }
#endif
#ifdef USE_COVER
@@ -204,8 +204,8 @@ class Application {
}
#endif
#ifdef USE_FAN
const std::vector<fan::FanState *> &get_fans() { return this->fans_; }
fan::FanState *get_fan_by_key(uint32_t key, bool include_internal = false) {
const std::vector<fan::Fan *> &get_fans() { return this->fans_; }
fan::Fan *get_fan_by_key(uint32_t key, bool include_internal = false) {
for (auto *obj : this->fans_)
if (obj->get_object_id_hash() == key && (include_internal || !obj->is_internal()))
return obj;
@@ -288,7 +288,7 @@ class Application {
std::vector<text_sensor::TextSensor *> text_sensors_{};
#endif
#ifdef USE_FAN
std::vector<fan::FanState *> fans_{};
std::vector<fan::Fan *> fans_{};
#endif
#ifdef USE_COVER
std::vector<cover::Cover *> covers_{};