ESPHome 2025.5.0
Loading...
Searching...
No Matches
sntp_component.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome {
7namespace sntp {
8
16 public:
17 SNTPComponent(const std::vector<std::string> &servers) : servers_(servers) {}
18
19 // Note: set_servers() has been removed and replaced by a constructor - calling set_servers after setup would
20 // have had no effect anyway, and making the strings immutable avoids the need to strdup their contents.
21
22 void setup() override;
23 void dump_config() override;
24 float get_setup_priority() const override { return setup_priority::BEFORE_CONNECTION; }
25
26 void update() override;
27 void loop() override;
28
29 protected:
30 std::vector<std::string> servers_;
31 bool has_time_{false};
32};
33
34} // namespace sntp
35} // namespace esphome
The SNTP component allows you to configure local timekeeping via Simple Network Time Protocol.
std::vector< std::string > servers_
SNTPComponent(const std::vector< std::string > &servers)
float get_setup_priority() const override
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock.
const float BEFORE_CONNECTION
For components that should be initialized after WiFi and before API is connected.
Definition component.cpp:25
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7