ESPHome
2025.2.2
Main Page
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
y
+
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
d
e
f
i
j
l
m
n
p
q
r
s
t
u
v
+
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
+
Enumerator
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
+
Data Fields
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
c
d
o
p
s
t
v
w
+
Enumerations
b
c
e
f
i
m
n
p
r
s
t
v
+
Enumerator
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
w
Related Functions
+
Files
File List
+
Globals
+
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
+
Functions
_
a
l
m
o
s
t
u
+
Variables
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
Typedefs
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Modules
Pages
esphome
esphome
components
demo
demo_text_sensor.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/core/helpers.h
"
5
#include "
esphome/components/text_sensor/text_sensor.h
"
6
7
namespace
esphome
{
8
namespace
demo {
9
10
class
DemoTextSensor
:
public
text_sensor::TextSensor
,
public
PollingComponent
{
11
public
:
12
void
update
()
override
{
13
float
val
=
random_float
();
14
if
(val < 0.33) {
15
this->
publish_state
(
"foo"
);
16
}
else
if
(val < 0.66) {
17
this->
publish_state
(
"bar"
);
18
}
else
{
19
this->
publish_state
(
"foobar"
);
20
}
21
}
22
};
23
24
}
// namespace demo
25
}
// namespace esphome
esphome::demo::DemoTextSensor::update
void update() override
Definition:
demo_text_sensor.h:12
val
mopeka_std_values val[4]
Definition:
mopeka_std_check.h:224
esphome::PollingComponent
This class simplifies creating components that periodically check a state.
Definition:
component.h:283
esphome::text_sensor::TextSensor::publish_state
void publish_state(const std::string &state)
Definition:
text_sensor.cpp:9
esphome::text_sensor::TextSensor
Definition:
text_sensor.h:34
esphome::demo::DemoTextSensor
Definition:
demo_text_sensor.h:10
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
component.h
helpers.h
esphome::random_float
float random_float()
Return a random float between 0 and 1.
Definition:
helpers.cpp:219
text_sensor.h
Generated by
1.8.13