ESPHome
2025.6.2
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
{
11
namespace
demo {
12
13
class
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
esphome::Component
Definition
component.h:70
esphome::Component::call
void call()
Definition
component.cpp:93
esphome::datetime::TimeCall
Definition
time_entity.h:67
esphome::datetime::TimeCall::get_hour
optional< uint8_t > get_hour() const
Definition
time_entity.h:88
esphome::datetime::TimeCall::get_second
optional< uint8_t > get_second() const
Definition
time_entity.h:90
esphome::datetime::TimeCall::get_minute
optional< uint8_t > get_minute() const
Definition
time_entity.h:89
esphome::datetime::TimeEntity
Definition
time_entity.h:37
esphome::datetime::TimeEntity::minute_
uint8_t minute_
Definition
time_entity.h:40
esphome::datetime::TimeEntity::hour_
uint8_t hour_
Definition
time_entity.h:39
esphome::datetime::TimeEntity::publish_state
void publish_state()
Definition
time_entity.cpp:12
esphome::datetime::TimeEntity::second_
uint8_t second_
Definition
time_entity.h:41
esphome::demo::DemoTime
Definition
demo_time.h:13
esphome::demo::DemoTime::control
void control(const datetime::TimeCall &call) override
Definition
demo_time.h:23
esphome::demo::DemoTime::setup
void setup() override
Definition
demo_time.h:15
esphome::optional::value_or
value_type value_or(U const &v) const
Definition
optional.h:93
component.h
defines.h
esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition
a01nyub.cpp:7
time_entity.h
Generated by
1.12.0