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