ESPHome  2024.10.2
mqtt_binary_sensor.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "esphome/core/defines.h"
4 #ifdef USE_MQTT
5 #ifdef USE_BINARY_SENSOR
6 
7 #include "mqtt_component.h"
9 
10 namespace esphome {
11 namespace mqtt {
12 
14  public:
20 
21  void setup() override;
22 
23  void dump_config() override;
24 
25  void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override;
26 
27  void set_is_status(bool status);
28 
29  bool send_initial_state() override;
30  bool publish_state(bool state);
31 
32  protected:
33  std::string component_type() const override;
34  const EntityBase *get_entity() const override;
35 
37 };
38 
39 } // namespace mqtt
40 } // namespace esphome
41 
42 #endif
43 #endif // USE_MQTT
const EntityBase * get_entity() const override
Simple Helper struct used for Home Assistant MQTT send_discovery().
std::string component_type() const override
esphome::binary_sensor::BinarySensor * binary_sensor
Definition: statsd.h:40
uint8_t status
Definition: bl0942.h:74
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
Base class for all binary_sensor-type classes.
Definition: binary_sensor.h:37
binary_sensor::BinarySensor * binary_sensor_
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
MQTTBinarySensorComponent(binary_sensor::BinarySensor *binary_sensor)
Construct a MQTTBinarySensorComponent.
bool state
Definition: fan.h:34
MQTTComponent is the base class for all components that interact with MQTT to expose certain function...