ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
datetime_base.h
Go to the documentation of this file.
1#pragma once
2
6#include "esphome/core/time.h"
7#ifdef USE_TIME
9#endif
10
11namespace esphome::datetime {
12
13class DateTimeBase : public EntityBase {
14 public:
15 virtual ESPTime state_as_esptime() const = 0;
16
17 template<typename F> void add_on_state_callback(F &&callback) {
18 this->state_callback_.add(std::forward<F>(callback));
19 }
20
21#ifdef USE_TIME
22 void set_rtc(time::RealTimeClock *rtc) { this->rtc_ = rtc; }
23 time::RealTimeClock *get_rtc() const { return this->rtc_; }
24#endif
25
26 protected:
28
29#ifdef USE_TIME
31#endif
32};
33
34} // namespace esphome::datetime
time::RealTimeClock * rtc_
void add_on_state_callback(F &&callback)
time::RealTimeClock * get_rtc() const
void set_rtc(time::RealTimeClock *rtc)
virtual ESPTime state_as_esptime() const =0
LazyCallbackManager< void()> state_callback_
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock.
A more user-friendly version of struct tm from time.h.
Definition time.h:23