7 #ifdef USE_BINARY_SENSOR 12 static const char *
const TAG =
"mqtt.binary_sensor";
23 LOG_MQTT_COMPONENT(
true,
false)
52 const char *state_s = state ?
"ON" :
"OFF";
bool send_initial_state() override
std::string get_device_class()
Get the device class, using the manual override if set.
virtual bool is_status_binary_sensor() const
void set_custom_state_topic(const char *custom_state_topic)
Set a custom state topic. Set to "" for default behavior.
bool command_topic
If the command topic should be included. Default to true.
void dump_config() override
bool publish(const std::string &topic, const std::string &payload)
Send a MQTT message.
constexpr const char *const MQTT_PAYLOAD_ON
MQTTClientComponent * global_mqtt_client
constexpr const char *const MQTT_PAYLOAD_OFF
const EntityBase * get_entity() const override
virtual bool has_state() const
Return whether this binary sensor has outputted a state.
Simple Helper struct used for Home Assistant MQTT send_discovery().
bool state
The current reported state of the binary sensor.
std::string component_type() const override
esphome::binary_sensor::BinarySensor * binary_sensor
constexpr const char * c_str() const
void add_on_state_callback(std::function< void(bool)> &&callback)
Add a callback to be notified of state changes.
Implementation of SPI Controller mode.
Base class for all binary_sensor-type classes.
binary_sensor::BinarySensor * binary_sensor_
constexpr const char *const MQTT_DEVICE_CLASS
std::string get_state_topic_() const
Get the MQTT topic that new states will be shared to.
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
MQTTBinarySensorComponent(binary_sensor::BinarySensor *binary_sensor)
Construct a MQTTBinarySensorComponent.
const StringRef & get_name() const
bool publish_state(bool state)