ESPHome
2025.2.2
Main Page
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
y
+
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
d
e
f
i
j
l
m
n
p
q
r
s
t
u
v
+
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
+
Enumerator
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
+
Data Fields
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
c
d
o
p
s
t
v
w
+
Enumerations
b
c
e
f
i
m
n
p
r
s
t
v
+
Enumerator
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
w
Related Functions
+
Files
File List
+
Globals
+
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
+
Functions
_
a
l
m
o
s
t
u
+
Variables
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
Typedefs
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Modules
Pages
esphome
esphome
components
mqtt_subscribe
text_sensor
mqtt_subscribe_text_sensor.cpp
Go to the documentation of this file.
1
#include "
mqtt_subscribe_text_sensor.h
"
2
3
#ifdef USE_MQTT
4
5
#include "
esphome/core/log.h
"
6
#include <utility>
7
8
namespace
esphome
{
9
namespace
mqtt_subscribe {
10
11
static
const
char
*
const
TAG =
"mqtt_subscribe.text_sensor"
;
12
13
void
MQTTSubscribeTextSensor::setup
() {
14
this->
parent_
->
subscribe
(
15
this->
topic_
, [
this
](
const
std::string &topic,
const
std::string &payload) { this->
publish_state
(payload); },
16
this->
qos_
);
17
}
18
float
MQTTSubscribeTextSensor::get_setup_priority
()
const
{
return
setup_priority::AFTER_CONNECTION
; }
19
void
MQTTSubscribeTextSensor::set_qos
(uint8_t qos) { this->
qos_
= qos; }
20
void
MQTTSubscribeTextSensor::dump_config
() {
21
LOG_TEXT_SENSOR(
""
,
"MQTT Subscribe Text Sensor"
,
this
);
22
ESP_LOGCONFIG(TAG,
" Topic: %s"
, this->
topic_
.c_str());
23
}
24
25
}
// namespace mqtt_subscribe
26
}
// namespace esphome
27
28
#endif // USE_MQTT
esphome::mqtt_subscribe::MQTTSubscribeTextSensor::dump_config
void dump_config() override
Definition:
mqtt_subscribe_text_sensor.cpp:20
esphome::setup_priority::AFTER_CONNECTION
const float AFTER_CONNECTION
For components that should be initialized after a data connection (API/MQTT) is connected.
Definition:
component.cpp:27
esphome::text_sensor::TextSensor::publish_state
void publish_state(const std::string &state)
Definition:
text_sensor.cpp:9
esphome::mqtt_subscribe::MQTTSubscribeTextSensor::qos_
uint8_t qos_
Definition:
mqtt_subscribe_text_sensor.h:26
esphome::mqtt_subscribe::MQTTSubscribeTextSensor::set_qos
void set_qos(uint8_t qos)
Definition:
mqtt_subscribe_text_sensor.cpp:19
esphome::mqtt_subscribe::MQTTSubscribeTextSensor::setup
void setup() override
Definition:
mqtt_subscribe_text_sensor.cpp:13
mqtt_subscribe_text_sensor.h
esphome::mqtt_subscribe::MQTTSubscribeTextSensor::topic_
std::string topic_
Definition:
mqtt_subscribe_text_sensor.h:25
esphome
Implementation of SPI Controller mode.
Definition:
a01nyub.cpp:7
esphome::mqtt_subscribe::MQTTSubscribeTextSensor::get_setup_priority
float get_setup_priority() const override
Definition:
mqtt_subscribe_text_sensor.cpp:18
log.h
esphome::mqtt::MQTTClientComponent::subscribe
void subscribe(const std::string &topic, mqtt_callback_t callback, uint8_t qos=0)
Subscribe to an MQTT topic and call callback when a message is received.
esphome::mqtt_subscribe::MQTTSubscribeTextSensor::parent_
mqtt::MQTTClientComponent * parent_
Definition:
mqtt_subscribe_text_sensor.h:24
Generated by
1.8.13