ESPHome  2024.10.2
template_datetime.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "esphome/core/defines.h"
4 
5 #ifdef USE_DATETIME_DATETIME
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::DateTimeCall &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_DATETIME
void set_restore_value(bool restore_value)
Trigger< ESPTime > * get_set_trigger() const
float get_setup_priority() const override
A more user-friendly version of struct tm from time.h.
Definition: time.h:17
void set_initial_value(ESPTime initial_value)
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void control(const datetime::DateTimeCall &call) override
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_
void set_template(std::function< optional< ESPTime >()> &&f)