ESPHome  2024.10.2
demo_binary_sensor.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 namespace esphome {
7 namespace demo {
8 
10  public:
11  void setup() override { this->publish_initial_state(false); }
12  void update() override {
13  bool new_state = last_state_ = !last_state_;
14  this->publish_state(new_state);
15  }
16 
17  protected:
18  bool last_state_ = false;
19 };
20 
21 } // namespace demo
22 } // namespace esphome
void publish_initial_state(bool state)
Publish the initial state, this will not make the callback manager send callbacks and is meant only f...
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void publish_state(bool state)
Publish a new state to the front-end.
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
Base class for all binary_sensor-type classes.
Definition: binary_sensor.h:37