mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 08:15:49 +00:00
Add demo integration (#2085)
This commit is contained in:
22
esphome/components/demo/demo_binary_sensor.h
Normal file
22
esphome/components/demo/demo_binary_sensor.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace demo {
|
||||
|
||||
class DemoBinarySensor : public binary_sensor::BinarySensor, public PollingComponent {
|
||||
public:
|
||||
void setup() override { this->publish_initial_state(false); }
|
||||
void update() override {
|
||||
bool new_state = last_state_ = !last_state_;
|
||||
this->publish_state(new_state);
|
||||
}
|
||||
|
||||
protected:
|
||||
bool last_state_ = false;
|
||||
};
|
||||
|
||||
} // namespace demo
|
||||
} // namespace esphome
|
||||
Reference in New Issue
Block a user