ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
demo_text_sensor.h
Go to the documentation of this file.
1#pragma once
2
6
7namespace esphome::demo {
8
10 public:
11 void update() override {
12 float val = random_float();
13 if (val < 0.33) {
14 this->publish_state("foo");
15 } else if (val < 0.66) {
16 this->publish_state("bar");
17 } else {
18 this->publish_state("foobar");
19 }
20 }
21};
22
23} // namespace esphome::demo
This class simplifies creating components that periodically check a state.
Definition component.h:602
void publish_state(const std::string &state)
mopeka_std_values val[3]
float random_float()
Return a random float between 0 and 1.
Definition helpers.cpp:198