mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-03 19:38:30 +02:00
Add new time.has_time condition (#1255)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/automation.h"
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <bitset>
|
||||
@@ -133,5 +134,14 @@ class RealTimeClock : public Component {
|
||||
std::string timezone_{};
|
||||
};
|
||||
|
||||
template<typename... Ts> class TimeHasTimeCondition : public Condition<Ts...> {
|
||||
public:
|
||||
TimeHasTimeCondition(RealTimeClock *parent) : parent_(parent) {}
|
||||
bool check(Ts... x) override { return this->parent_->now().is_valid(); }
|
||||
|
||||
protected:
|
||||
RealTimeClock *parent_;
|
||||
};
|
||||
|
||||
} // namespace time
|
||||
} // namespace esphome
|
||||
|
||||
Reference in New Issue
Block a user