mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 19:54:14 +01:00
25 lines
556 B
C++
25 lines
556 B
C++
#pragma once
|
|
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/core/helpers.h"
|
|
#include "esphome/components/text_sensor/text_sensor.h"
|
|
|
|
namespace esphome {
|
|
namespace demo {
|
|
|
|
class DemoTextSensor : public text_sensor::TextSensor, public PollingComponent {
|
|
public:
|
|
void update() override {
|
|
float val = random_float();
|
|
if (val < 0.33) {
|
|
this->publish_state("foo");
|
|
} else if (val < 0.66) {
|
|
this->publish_state("bar");
|
|
} else {
|
|
this->publish_state("foobar");
|
|
}
|
|
}
|
|
};
|
|
|
|
} // namespace demo
|
|
} // namespace esphome
|