feature request 398 add 'hide timestamp' option for version text sensor (#1085)

Co-authored-by: Guillermo Ruffino <glm.net@gmail.com>
This commit is contained in:
Wauter
2020-07-12 00:55:30 +02:00
committed by GitHub
parent ed5f207eba
commit e41ea42074
5 changed files with 20 additions and 4 deletions
@@ -8,9 +8,15 @@ namespace version {
static const char *TAG = "version.text_sensor";
void VersionTextSensor::setup() { this->publish_state(ESPHOME_VERSION " " + App.get_compilation_time()); }
void VersionTextSensor::setup() {
if (this->hide_timestamp_) {
this->publish_state(ESPHOME_VERSION);
} else {
this->publish_state(ESPHOME_VERSION " " + App.get_compilation_time());
}
}
float VersionTextSensor::get_setup_priority() const { return setup_priority::DATA; }
void VersionTextSensor::set_hide_timestamp(bool hide_timestamp) { this->hide_timestamp_ = hide_timestamp; }
std::string VersionTextSensor::unique_id() { return get_mac_address() + "-version"; }
void VersionTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Version Text Sensor", this); }