ESPHome  2022.12.8
automation.h
Go to the documentation of this file.
1 #pragma once
2 
5 #include "real_time_clock.h"
6 
7 #include <vector>
8 
9 namespace esphome {
10 namespace time {
11 
12 class CronTrigger : public Trigger<>, public Component {
13  public:
14  explicit CronTrigger(RealTimeClock *rtc);
15  void add_second(uint8_t second);
16  void add_seconds(const std::vector<uint8_t> &seconds);
17  void add_minute(uint8_t minute);
18  void add_minutes(const std::vector<uint8_t> &minutes);
19  void add_hour(uint8_t hour);
20  void add_hours(const std::vector<uint8_t> &hours);
21  void add_day_of_month(uint8_t day_of_month);
22  void add_days_of_month(const std::vector<uint8_t> &days_of_month);
23  void add_month(uint8_t month);
24  void add_months(const std::vector<uint8_t> &months);
25  void add_day_of_week(uint8_t day_of_week);
26  void add_days_of_week(const std::vector<uint8_t> &days_of_week);
27  bool matches(const ESPTime &time);
28  void loop() override;
29  float get_setup_priority() const override;
30 
31  protected:
32  std::bitset<61> seconds_;
33  std::bitset<60> minutes_;
34  std::bitset<24> hours_;
35  std::bitset<32> days_of_month_;
36  std::bitset<13> months_;
37  std::bitset<8> days_of_week_;
40 };
41 
42 class SyncTrigger : public Trigger<>, public Component {
43  public:
44  explicit SyncTrigger(RealTimeClock *rtc);
45 
46  protected:
48 };
49 } // namespace time
50 } // namespace esphome
void add_days_of_week(const std::vector< uint8_t > &days_of_week)
Definition: automation.cpp:83
void add_hour(uint8_t hour)
Definition: automation.cpp:14
bool matches(const ESPTime &time)
Definition: automation.cpp:18
The RealTimeClock class exposes common timekeeping functions via the device&#39;s local real-time clock...
void add_minutes(const std::vector< uint8_t > &minutes)
Definition: automation.cpp:67
std::bitset< 61 > seconds_
Definition: automation.h:32
float get_setup_priority() const override
Definition: automation.cpp:87
void add_seconds(const std::vector< uint8_t > &seconds)
Definition: automation.cpp:63
CronTrigger(RealTimeClock *rtc)
Definition: automation.cpp:62
std::bitset< 13 > months_
Definition: automation.h:36
A more user-friendly version of struct tm from time.h.
void add_month(uint8_t month)
Definition: automation.cpp:16
std::bitset< 60 > minutes_
Definition: automation.h:33
void add_day_of_month(uint8_t day_of_month)
Definition: automation.cpp:15
RealTimeClock * rtc_
Definition: automation.h:38
void add_months(const std::vector< uint8_t > &months)
Definition: automation.cpp:79
void add_days_of_month(const std::vector< uint8_t > &days_of_month)
Definition: automation.cpp:75
std::bitset< 8 > days_of_week_
Definition: automation.h:37
std::bitset< 32 > days_of_month_
Definition: automation.h:35
optional< ESPTime > last_check_
Definition: automation.h:39
RealTimeClock * rtc_
Definition: automation.h:47
std::bitset< 24 > hours_
Definition: automation.h:34
void add_second(uint8_t second)
Definition: automation.cpp:12
Definition: a4988.cpp:4
void add_day_of_week(uint8_t day_of_week)
Definition: automation.cpp:17
void add_hours(const std::vector< uint8_t > &hours)
Definition: automation.cpp:71
void add_minute(uint8_t minute)
Definition: automation.cpp:13