28 LOG_MQTT_COMPONENT(
true,
false);
30 ESP_LOGCONFIG(TAG,
" Expire After: %" PRIu32
"s", this->
get_expire_after() / 1000);
50 if (!unit_of_measurement.empty()) {
51 root[MQTT_UNIT_OF_MEASUREMENT] = unit_of_measurement;
59 root[MQTT_FORCE_UPDATE] =
true;
75 char topic_buf[MQTT_DEFAULT_TOPIC_MAX_LEN];
StringRef get_unit_of_measurement_ref() const
bool publish_float_(StringRef topic, float value, int8_t accuracy)
Publish a float formatted to accuracy, or "None" for NaN when publish_nan_as_none is set.
StringRef get_state_topic_to_(std::span< char, MQTT_DEFAULT_TOPIC_MAX_LEN > buf) const
Get the MQTT state topic into a buffer (no heap allocation for non-lambda custom topics).
uint32_t get_expire_after() const
Get the expire_after in milliseconds used for Home Assistant discovery, first checks override.
optional< uint32_t > expire_after_
bool publish_state(float value)
bool send_initial_state() override
void dump_config() override
MQTTSensorComponent(sensor::Sensor *sensor)
Construct this MQTTSensorComponent instance with the provided friendly_name and sensor.
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
void setup() override
Override setup.
Base-class for all sensors.
void add_on_state_callback(F &&callback)
Add a callback that will be called every time a filtered value arrives.
bool has_accuracy_decimals() const
Check if the accuracy in decimals has been manually set.
float state
This member variable stores the last state that has passed through all filters.
StateClass get_state_class()
Get the state class, using the manual override if set.
int8_t get_accuracy_decimals()
Get the accuracy in decimals, using the manual override if set.
bool get_force_update() const
Get whether force update mode is enabled.
ESPHOME_LOG_TAG(TAG, "alarm_control_panel")
MQTT_COMPONENT_TYPE(MQTTAlarmControlPanelComponent, "alarm_control_panel") const EntityBase *MQTTAlarmControlPanelComponent
const LogString * state_class_to_string(StateClass state_class)
const __FlashStringHelper * ProgmemStr
Simple Helper struct used for Home Assistant MQTT send_discovery().
bool command_topic
If the command topic should be included. Default to true.