ESPHome 2025.6.2
Loading...
Searching...
No Matches
demo_datetime.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef USE_DATETIME_DATETIME
6
9
10namespace esphome {
11namespace demo {
12
14 public:
15 void setup() override {
16 this->year_ = 2038;
17 this->month_ = 01;
18 this->day_ = 19;
19 this->hour_ = 3;
20 this->minute_ = 14;
21 this->second_ = 8;
22 this->publish_state();
23 }
24
25 protected:
26 void control(const datetime::DateTimeCall &call) override {
27 this->year_ = call.get_year().value_or(this->year_);
28 this->month_ = call.get_month().value_or(this->month_);
29 this->day_ = call.get_day().value_or(this->day_);
30 this->hour_ = call.get_hour().value_or(this->hour_);
31 this->minute_ = call.get_minute().value_or(this->minute_);
32 this->second_ = call.get_second().value_or(this->second_);
33 this->publish_state();
34 }
35};
36
37} // namespace demo
38} // namespace esphome
39
40#endif
optional< uint16_t > get_year() const
optional< uint8_t > get_hour() const
optional< uint8_t > get_month() const
optional< uint8_t > get_minute() const
optional< uint8_t > get_day() const
optional< uint8_t > get_second() const
void control(const datetime::DateTimeCall &call) override
value_type value_or(U const &v) const
Definition optional.h:93
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7