ESPHome  2024.11.1
version_text_sensor.cpp
Go to the documentation of this file.
1 #include "version_text_sensor.h"
2 #include "esphome/core/log.h"
4 #include "esphome/core/version.h"
5 
6 namespace esphome {
7 namespace version {
8 
9 static const char *const TAG = "version.text_sensor";
10 
12  if (this->hide_timestamp_) {
13  this->publish_state(ESPHOME_VERSION);
14  } else {
15  this->publish_state(ESPHOME_VERSION " " + App.get_compilation_time());
16  }
17 }
19 void VersionTextSensor::set_hide_timestamp(bool hide_timestamp) { this->hide_timestamp_ = hide_timestamp; }
20 std::string VersionTextSensor::unique_id() { return get_mac_address() + "-version"; }
21 void VersionTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Version Text Sensor", this); }
22 
23 } // namespace version
24 } // namespace esphome
const float DATA
For components that import data from directly connected sensors like DHT.
Definition: component.cpp:19
void publish_state(const std::string &state)
Definition: text_sensor.cpp:9
std::string get_mac_address()
Get the device MAC address as a string, in lowercase hex notation.
Definition: helpers.cpp:706
Application App
Global storage of Application pointer - only one Application can exist.
void set_hide_timestamp(bool hide_timestamp)
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
std::string get_compilation_time() const
Definition: application.h:215