1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-19 08:15:49 +00:00

Add light restore mode

I don't want users to rely on setup priority.

Ref https://github.com/esphome/esphome-docs/pull/248
This commit is contained in:
Otto Winter
2019-05-27 19:22:16 +02:00
parent 72218171b3
commit 4bc3067725
3 changed files with 41 additions and 6 deletions

View File

@@ -160,6 +160,13 @@ class LightCall {
bool save_{true};
};
enum LightRestoreMode {
LIGHT_RESTORE_DEFAULT_OFF,
LIGHT_RESTORE_DEFAULT_ON,
LIGHT_ALWAYS_OFF,
LIGHT_ALWAYS_ON,
};
/** This class represents the communication layer between the front-end MQTT layer and the
* hardware output layer.
*/
@@ -249,6 +256,7 @@ class LightState : public Nameable, public Component {
/// Set the gamma correction factor
void set_gamma_correct(float gamma_correct);
float get_gamma_correct() const { return this->gamma_correct_; }
void set_restore_mode(LightRestoreMode restore_mode) { restore_mode_ = restore_mode; }
const std::vector<LightEffect *> &get_effects() const;
@@ -292,6 +300,8 @@ class LightState : public Nameable, public Component {
/// Object used to store the persisted values of the light.
ESPPreferenceObject rtc_;
/// Restore mode of the light.
LightRestoreMode restore_mode_;
/// Default transition length for all transitions in ms.
uint32_t default_transition_length_{};
/// Value for storing the index of the currently active effect. 0 if no effect is active