1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-01 17:42:22 +01:00
Files
esphome/esphome/components/demo/demo_date.h
2025-05-28 15:23:45 -05:00

35 lines
732 B
C++

#pragma once
#include "esphome/core/defines.h"
#ifdef USE_DATETIME_DATE
#include "esphome/components/datetime/date_entity.h"
#include "esphome/core/component.h"
namespace esphome {
namespace demo {
class DemoDate : public datetime::DateEntity, public Component {
public:
void setup() override {
this->year_ = 2038;
this->month_ = 01;
this->day_ = 19;
this->publish_state();
}
protected:
void control(const datetime::DateCall &call) override {
this->year_ = call.get_year().value_or(this->year_);
this->month_ = call.get_month().value_or(this->month_);
this->day_ = call.get_day().value_or(this->day_);
this->publish_state();
}
};
} // namespace demo
} // namespace esphome
#endif