ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
demo_time.h
Go to the documentation of this file.
1#pragma once
2
4
5#ifdef USE_DATETIME_TIME
6
9
10namespace esphome::demo {
11
12class DemoTime : public datetime::TimeEntity, public Component {
13 public:
14 void setup() override {
15 this->hour_ = 3;
16 this->minute_ = 14;
17 this->second_ = 8;
18 this->publish_state();
19 }
20
21 protected:
22 void control(const datetime::TimeCall &call) override {
23 this->hour_ = call.get_hour().value_or(this->hour_);
24 this->minute_ = call.get_minute().value_or(this->minute_);
25 this->second_ = call.get_second().value_or(this->second_);
26 this->publish_state();
27 }
28};
29
30} // namespace esphome::demo
31
32#endif
optional< uint8_t > get_hour() const
Definition time_entity.h:87
optional< uint8_t > get_second() const
Definition time_entity.h:89
optional< uint8_t > get_minute() const
Definition time_entity.h:88
void control(const datetime::TimeCall &call) override
Definition demo_time.h:22
void setup() override
Definition demo_time.h:14