ESPHome 2025.12.1
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"
13
14namespace esphome::template_ {
15
17 public:
18 template<typename F> void set_template(F &&f) { this->f_.set(std::forward<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 esphome::template_
44
45#endif // USE_DATETIME_DATETIME
This class simplifies creating components that periodically check a state.
Definition component.h:474
Lightweight wrapper for template platform lambdas (stateless function pointers only).
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)
const float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.cpp:80
A more user-friendly version of struct tm from time.h.
Definition time.h:15