mirror of
https://github.com/esphome/esphome-docs.git
synced 2024-12-27 17:37:45 +01:00
063b170d02
Still need to update some images
61 lines
1.3 KiB
ReStructuredText
61 lines
1.3 KiB
ReStructuredText
Binary Sensor
|
|
=============
|
|
|
|
.. cpp:namespace:: binary_sensor
|
|
|
|
In esphomelib, every component that exposes a binary state, is a :cpp:class:`BinarySensor`.
|
|
|
|
To create your own binary sensor, simply subclass :cpp:class:`BinarySensor` and call
|
|
:cpp:func:`BinarySensor::publish_state` to tell the frontend that you have a new state.
|
|
Inversion is automatically done for you when publishing state and can be changed by the
|
|
user with :cpp:func:`BinarySensor::set_inverted`.
|
|
|
|
Supported Binary Sensors
|
|
------------------------
|
|
|
|
.. toctree::
|
|
|
|
esp32_touch
|
|
gpio
|
|
pn532
|
|
rdm6300
|
|
remote_receiver
|
|
status
|
|
template
|
|
|
|
Example Usage
|
|
-------------
|
|
|
|
.. code-block:: cpp
|
|
|
|
// Basic
|
|
App.register_binary_sensor(custom_binary_sensor);
|
|
// GPIO Binary Sensor
|
|
App.make_gpio_binary_sensor("Window Open", 36);
|
|
|
|
|
|
.. cpp:namespace:: nullptr
|
|
|
|
See :cpp:func:`Application::register_binary_sensor` and :cpp:func:`Application::make_gpio_binary_sensor`.
|
|
|
|
API Reference
|
|
-------------
|
|
|
|
.. cpp:namespace:: nullptr
|
|
|
|
BinarySensor
|
|
************
|
|
|
|
.. doxygenclass:: binary_sensor::BinarySensor
|
|
:members:
|
|
:protected-members:
|
|
:undoc-members:
|
|
|
|
MQTTBinarySensorComponent
|
|
*************************
|
|
|
|
.. doxygenclass:: binary_sensor::MQTTBinarySensorComponent
|
|
:members:
|
|
:protected-members:
|
|
:undoc-members:
|