mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-01 18:48:28 +02:00
Add demo integration (#2085)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user