ESPHome 2025.5.0
Loading...
Searching...
No Matches
demo_text_sensor.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome {
8namespace demo {
9
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
This class simplifies creating components that periodically check a state.
Definition component.h:301
void publish_state(const std::string &state)
mopeka_std_values val[4]
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
float random_float()
Return a random float between 0 and 1.
Definition helpers.cpp:218