ESPHome  2024.12.2
template_date.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "esphome/core/defines.h"
4 
5 #ifdef USE_DATETIME_DATE
6 
11 #include "esphome/core/time.h"
12 
13 namespace esphome {
14 namespace template_ {
15 
17  public:
18  void set_template(std::function<optional<ESPTime>()> &&f) { this->f_ = f; }
19 
20  void setup() override;
21  void update() override;
22  void dump_config() override;
23  float get_setup_priority() const override { return setup_priority::HARDWARE; }
24 
25  Trigger<ESPTime> *get_set_trigger() const { return this->set_trigger_; }
26  void set_optimistic(bool optimistic) { this->optimistic_ = optimistic; }
27 
28  void set_initial_value(ESPTime initial_value) { this->initial_value_ = initial_value; }
29  void set_restore_value(bool restore_value) { this->restore_value_ = restore_value; }
30 
31  protected:
32  void control(const datetime::DateCall &call) override;
33 
34  bool optimistic_{false};
36  bool restore_value_{false};
39 
41 };
42 
43 } // namespace template_
44 } // namespace esphome
45 
46 #endif // USE_DATETIME_DATE
void set_initial_value(ESPTime initial_value)
Definition: template_date.h:28
Trigger< ESPTime > * set_trigger_
Definition: template_date.h:37
A more user-friendly version of struct tm from time.h.
Definition: time.h:15
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void set_template(std::function< optional< ESPTime >()> &&f)
Definition: template_date.h:18
Trigger< ESPTime > * get_set_trigger() const
Definition: template_date.h:25
void control(const datetime::DateCall &call) override
void set_restore_value(bool restore_value)
Definition: template_date.h:29
float get_setup_priority() const override
Definition: template_date.h:23
void set_optimistic(bool optimistic)
Definition: template_date.h:26
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition: component.cpp:18
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
optional< std::function< optional< ESPTime >)> > f_
Definition: template_date.h:38