mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 11:44:13 +01:00
22 lines
479 B
C++
22 lines
479 B
C++
#pragma once
|
|
|
|
#include "esphome/core/component.h"
|
|
#include "esphome/core/helpers.h"
|
|
#include "esphome/components/switch/switch.h"
|
|
|
|
namespace esphome {
|
|
namespace demo {
|
|
|
|
class DemoSwitch : public switch_::Switch, public Component {
|
|
public:
|
|
void setup() override {
|
|
bool initial = random_float() < 0.5;
|
|
this->publish_state(initial);
|
|
}
|
|
|
|
protected:
|
|
void write_state(bool state) override { this->publish_state(state); }
|
|
};
|
|
|
|
} // namespace demo
|
|
} // namespace esphome
|