ESPHome
2024.11.0
esphome
esphome
components
demo
demo_binary_sensor.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
esphome/core/component.h
"
4
#include "
esphome/components/binary_sensor/binary_sensor.h
"
5
6
namespace
esphome
{
7
namespace
demo {
8
9
class
DemoBinarySensor
:
public
binary_sensor::BinarySensor
,
public
PollingComponent
{
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
esphome::binary_sensor::BinarySensor::publish_initial_state
void publish_initial_state(bool state)
Publish the initial state, this will not make the callback manager send callbacks and is meant only f...
Definition:
binary_sensor.cpp:23
esphome::demo::DemoBinarySensor::update
void update() override
Definition:
demo_binary_sensor.h:12
esphome::demo::DemoBinarySensor::last_state_
bool last_state_
Definition:
demo_binary_sensor.h:18
esphome::demo::DemoBinarySensor
Definition:
demo_binary_sensor.h:9
esphome::PollingComponent
This class simplifies creating components that periodically check a state.
Definition:
component.h:283
binary_sensor.h
esphome::binary_sensor::BinarySensor::publish_state
void publish_state(bool state)
Publish a new state to the front-end.
Definition:
binary_sensor.cpp:14
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
esphome::demo::DemoBinarySensor::setup
void setup() override
Definition:
demo_binary_sensor.h:11
component.h
esphome::binary_sensor::BinarySensor
Base class for all binary_sensor-type classes.
Definition:
binary_sensor.h:37
Generated by
1.8.13