9#ifdef USE_DATETIME_DATE
13static const char *
const TAG =
"mqtt.datetime";
22 if (root[ESPHOME_F(
"year")].is<uint16_t>()) {
23 call.set_year(root[ESPHOME_F(
"year")]);
25 if (root[ESPHOME_F(
"month")].is<uint8_t>()) {
26 call.set_month(root[ESPHOME_F(
"month")]);
28 if (root[ESPHOME_F(
"day")].is<uint8_t>()) {
29 call.set_day(root[ESPHOME_F(
"day")]);
39 LOG_MQTT_COMPONENT(
true,
true)
58 root[ESPHOME_F(
"year")] =
year;
59 root[ESPHOME_F(
"month")] =
month;
60 root[ESPHOME_F(
"day")] =
day;
const StringRef & get_name() const
constexpr const char * c_str() const
void add_on_state_callback(std::function< void()> &&callback)
void subscribe_json(const std::string &topic, const mqtt_json_callback_t &callback, uint8_t qos=0)
Subscribe to a MQTT topic and automatically parse JSON payload.
bool publish_json(const std::string &topic, const json::json_build_t &f)
Construct and send a JSON MQTT message.
std::string get_state_topic_() const
Get the MQTT topic that new states will be shared to.
std::string get_command_topic_() const
Get the MQTT topic for listening to commands.
void dump_config() override
MQTTDateComponent(datetime::DateEntity *date)
Construct this MQTTDateComponent instance with the provided friendly_name and date.
bool send_initial_state() override
datetime::DateEntity * date_
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
bool publish_state(uint16_t year, uint8_t month, uint8_t day)
void setup() override
Override setup.
MQTT_COMPONENT_TYPE(MQTTAlarmControlPanelComponent, "alarm_control_panel") const EntityBase *MQTTAlarmControlPanelComponent
Simple Helper struct used for Home Assistant MQTT send_discovery().