ESPHome 2025.6.2
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 {
11namespace demo {
12
13class DemoDate : public datetime::DateEntity, public Component {
14 public:
15 void setup() override {
16 this->year_ = 2038;
17 this->month_ = 01;
18 this->day_ = 19;
19 this->publish_state();
20 }
21
22 protected:
23 void control(const datetime::DateCall &call) override {
24 this->year_ = call.get_year().value_or(this->year_);
25 this->month_ = call.get_month().value_or(this->month_);
26 this->day_ = call.get_day().value_or(this->day_);
27 this->publish_state();
28 }
29};
30
31} // namespace demo
32} // namespace esphome
33
34#endif
optional< uint8_t > get_month() const
Definition date_entity.h:87
optional< uint8_t > get_day() const
Definition date_entity.h:88
optional< uint16_t > get_year() const
Definition date_entity.h:86
void control(const datetime::DateCall &call) override
Definition demo_date.h:23
void setup() override
Definition demo_date.h:15
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