ESPHome  2024.12.2
demo_text_sensor.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/helpers.h"
6 
7 namespace esphome {
8 namespace 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
mopeka_std_values val[4]
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void publish_state(const std::string &state)
Definition: text_sensor.cpp:9
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
float random_float()
Return a random float between 0 and 1.
Definition: helpers.cpp:215