ESPHome 2025.5.0
Loading...
Searching...
No Matches
template_datetime.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef USE_DATETIME_DATETIME
6
11#include "esphome/core/time.h"
12
13namespace esphome {
14namespace 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
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
This class simplifies creating components that periodically check a state.
Definition component.h:301
float get_setup_priority() const override
void control(const datetime::DateTimeCall &call) override
void set_initial_value(ESPTime initial_value)
Trigger< ESPTime > * get_set_trigger() const
void set_restore_value(bool restore_value)
optional< std::function< optional< ESPTime >()> > f_
void set_template(std::function< optional< ESPTime >()> &&f)
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.cpp:18
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
A more user-friendly version of struct tm from time.h.
Definition time.h:15