ESPHome  2022.8.0
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:18
void publish_state(const std::string &state)
Definition: text_sensor.cpp:12
std::string get_mac_address()
Get the device MAC address as a string, in lowercase hex notation.
Definition: helpers.cpp:399
Application App
Global storage of Application pointer - only one Application can exist.
const std::string & get_compilation_time() const
Definition: application.h:139
void set_hide_timestamp(bool hide_timestamp)
Definition: a4988.cpp:4