ESPHome 2025.6.2
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 {
11namespace demo {
12
13class DemoTime : public datetime::TimeEntity, public Component {
14 public:
15 void setup() override {
16 this->hour_ = 3;
17 this->minute_ = 14;
18 this->second_ = 8;
19 this->publish_state();
20 }
21
22 protected:
23 void control(const datetime::TimeCall &call) override {
24 this->hour_ = call.get_hour().value_or(this->hour_);
25 this->minute_ = call.get_minute().value_or(this->minute_);
26 this->second_ = call.get_second().value_or(this->second_);
27 this->publish_state();
28 }
29};
30
31} // namespace demo
32} // namespace esphome
33
34#endif
optional< uint8_t > get_hour() const
Definition time_entity.h:88
optional< uint8_t > get_second() const
Definition time_entity.h:90
optional< uint8_t > get_minute() const
Definition time_entity.h:89
void control(const datetime::TimeCall &call) override
Definition demo_time.h:23
void setup() override
Definition demo_time.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