ESPHome 2026.5.1
Loading...
Searching...
No Matches
demo_date.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef USE_DATETIME_DATE
6
9
10namespace esphome::demo {
11
12class DemoDate : public datetime::DateEntity, public Component {
13 public:
14 void setup() override {
15 this->year_ = 2038;
16 this->month_ = 01;
17 this->day_ = 19;
18 this->publish_state();
19 }
20
21 protected:
22 void control(const datetime::DateCall &call) override {
23 this->year_ = call.get_year().value_or(this->year_);
24 this->month_ = call.get_month().value_or(this->month_);
25 this->day_ = call.get_day().value_or(this->day_);
26 this->publish_state();
27 }
28};
29
30} // namespace esphome::demo
31
32#endif
optional< uint8_t > get_month() const
Definition date_entity.h:86
optional< uint8_t > get_day() const
Definition date_entity.h:87
optional< uint16_t > get_year() const
Definition date_entity.h:85
void control(const datetime::DateCall &call) override
Definition demo_date.h:22
void setup() override
Definition demo_date.h:14