esphome/esphome/components/sntp/sntp_component.h
Otto Winter 8e75980ebd
Cleanup dashboard JS (#491)
* Cleanup dashboard JS

* Add vscode

* Save start_mark/end_mark

* Updates

* Updates

* Remove need for cv.nameable

It's a bit hacky but removes so much bloat from integrations

* Add enum helper

* Document APIs, and Improvements

* Fixes

* Fixes

* Update PULL_REQUEST_TEMPLATE.md

* Updates

* Updates

* Updates
2019-04-22 21:56:30 +02:00

37 lines
1.1 KiB
C++

#pragma once
#include "esphome/core/component.h"
#include "esphome/components/time/real_time_clock.h"
namespace esphome {
namespace sntp {
/// The SNTP component allows you to configure local timekeeping via Simple Network Time Protocol.
///
/// \note
/// The C library (newlib) available on ESPs only supports TZ strings that specify an offset and DST info;
/// you cannot specify zone names or paths to zoneinfo files.
/// \see https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
class SNTPComponent : public time::RealTimeClock {
public:
void setup() override;
void dump_config() override;
/// Change the servers used by SNTP for timekeeping
void set_servers(const std::string &server_1, const std::string &server_2, const std::string &server_3) {
this->server_1_ = server_1;
this->server_2_ = server_2;
this->server_3_ = server_3;
}
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
void loop() override;
protected:
std::string server_1_;
std::string server_2_;
std::string server_3_;
bool has_time_{false};
};
} // namespace sntp
} // namespace esphome