mirror of
https://github.com/esphome/esphome.git
synced 2025-04-15 15:20:27 +01:00
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "esphome/core/defines.h"
|
|
|
|
#ifdef USE_MQTT
|
|
#ifdef USE_DATETIME_TIME
|
|
|
|
#include "esphome/components/datetime/datetime_entity.h"
|
|
#include "mqtt_component.h"
|
|
|
|
namespace esphome {
|
|
namespace mqtt {
|
|
|
|
class MQTTDateTimeComponent : public mqtt::MQTTComponent {
|
|
public:
|
|
/** Construct this MQTTDateTimeComponent instance with the provided friendly_name and time
|
|
*
|
|
* @param time The time entity.
|
|
*/
|
|
explicit MQTTDateTimeComponent(datetime::DateTimeEntity *time);
|
|
|
|
// ========== INTERNAL METHODS ==========
|
|
// (In most use cases you won't need these)
|
|
/// Override setup.
|
|
void setup() override;
|
|
void dump_config() override;
|
|
|
|
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override;
|
|
|
|
bool send_initial_state() override;
|
|
|
|
bool publish_state(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second);
|
|
|
|
protected:
|
|
std::string component_type() const override;
|
|
const EntityBase *get_entity() const override;
|
|
|
|
datetime::DateTimeEntity *datetime_;
|
|
};
|
|
|
|
} // namespace mqtt
|
|
} // namespace esphome
|
|
|
|
#endif // USE_DATETIME_DATE
|
|
#endif // USE_MQTT
|