mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 11:44:13 +01:00
22 lines
515 B
C++
22 lines
515 B
C++
#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
|