ESPHome
2024.10.2
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:214
text_sensor.h
Generated by
1.8.13