9 #ifdef USE_DATETIME_DATE 14 static const char *
const TAG =
"mqtt.datetime";
23 if (root.containsKey(
"year")) {
24 call.set_year(root[
"year"]);
26 if (root.containsKey(
"month")) {
27 call.set_month(root[
"month"]);
29 if (root.containsKey(
"day")) {
30 call.set_day(root[
"day"]);
40 LOG_MQTT_COMPONENT(
true,
true)
59 root[
"month"] =
month;
67 #endif // USE_DATETIME_DATE
bool publish_state(uint16_t year, uint8_t month, uint8_t day)
void setup() override
Override setup.
datetime::DateEntity * date_
bool publish_json(const std::string &topic, const json::json_build_t &f)
Construct and send a JSON MQTT message.
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.
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
bool has_state() const
Return whether this Datetime has gotten a full state yet.
Simple Helper struct used for Home Assistant MQTT send_discovery().
const EntityBase * get_entity() const override
bool send_initial_state() override
void add_on_state_callback(std::function< void()> &&callback)
constexpr const char * c_str() const
Implementation of SPI Controller mode.
void dump_config() override
std::string component_type() const override
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.
MQTTDateComponent(datetime::DateEntity *date)
Construct this MQTTDateComponent instance with the provided friendly_name and date.
const StringRef & get_name() const