diff --git a/custom_components/empty_custom_fan/fan/empty_custom_fan.cpp b/custom_components/empty_custom_fan/fan/empty_custom_fan.cpp index 62a9c1b..99841ee 100644 --- a/custom_components/empty_custom_fan/fan/empty_custom_fan.cpp +++ b/custom_components/empty_custom_fan/fan/empty_custom_fan.cpp @@ -18,7 +18,12 @@ void EmptyCustomFan::setup() { } void EmptyCustomFan::loop() { - + if (!this->next_update_) { + return; //no state change, nothing to do + } + this->next_update_ = false; + + //there was a state change, do something here. } void EmptyCustomFan::dump_config() { diff --git a/custom_components/empty_custom_fan/fan/empty_custom_fan.h b/custom_components/empty_custom_fan/fan/empty_custom_fan.h index f460c2c..43d35dc 100644 --- a/custom_components/empty_custom_fan/fan/empty_custom_fan.h +++ b/custom_components/empty_custom_fan/fan/empty_custom_fan.h @@ -14,14 +14,10 @@ class EmptyCustomFan : public Component { void setup() override; void loop() override; void dump_config() override; - void set_oscillating(output::BinaryOutput *oscillating) { this->oscillating_ = oscillating; } - void set_direction(output::BinaryOutput *direction) { this->direction_ = direction; } - + protected: fan::FanState *fan_; output::BinaryOutput *output_; - output::BinaryOutput *oscillating_{nullptr}; - output::BinaryOutput *direction_{nullptr}; bool next_update_{true}; };