ESPHome
2026.5.0b1
Loading...
Searching...
No Matches
esphome
components
demo
demo_time.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/defines.h
"
4
5
#ifdef USE_DATETIME_TIME
6
7
#include "
esphome/components/datetime/time_entity.h
"
8
#include "
esphome/core/component.h
"
9
10
namespace
esphome::demo
{
11
12
class
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
esphome::Component
Definition
component.h:145
esphome::Component::call
void call()
Definition
component.cpp:230
esphome::datetime::TimeCall
Definition
time_entity.h:64
esphome::datetime::TimeCall::get_hour
optional< uint8_t > get_hour() const
Definition
time_entity.h:87
esphome::datetime::TimeCall::get_second
optional< uint8_t > get_second() const
Definition
time_entity.h:89
esphome::datetime::TimeCall::get_minute
optional< uint8_t > get_minute() const
Definition
time_entity.h:88
esphome::datetime::TimeEntity
Definition
time_entity.h:34
esphome::datetime::TimeEntity::minute_
uint8_t minute_
Definition
time_entity.h:37
esphome::datetime::TimeEntity::hour_
uint8_t hour_
Definition
time_entity.h:36
esphome::datetime::TimeEntity::publish_state
void publish_state()
Definition
time_entity.cpp:12
esphome::datetime::TimeEntity::second_
uint8_t second_
Definition
time_entity.h:38
esphome::demo::DemoTime
Definition
demo_time.h:12
esphome::demo::DemoTime::control
void control(const datetime::TimeCall &call) override
Definition
demo_time.h:22
esphome::demo::DemoTime::setup
void setup() override
Definition
demo_time.h:14
component.h
defines.h
esphome::demo
Definition
demo_alarm_control_panel.h:6
time_entity.h
Generated by
1.12.0