9 #ifdef USE_DATETIME_TIME 14 static const char *
const TAG =
"mqtt.datetime.time";
23 if (root.containsKey(
"hour")) {
24 call.set_hour(root[
"hour"]);
26 if (root.containsKey(
"minute")) {
27 call.set_minute(root[
"minute"]);
29 if (root.containsKey(
"second")) {
30 call.set_second(root[
"second"]);
40 LOG_MQTT_COMPONENT(
true,
true)
67 #endif // USE_DATETIME_TIME
void dump_config() override
std::string component_type() const override
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
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 setup() override
Override setup.
bool has_state() const
Return whether this Datetime has gotten a full state yet.
Simple Helper struct used for Home Assistant MQTT send_discovery().
void add_on_state_callback(std::function< void()> &&callback)
constexpr const char * c_str() const
const EntityBase * get_entity() const override
MQTTTimeComponent(datetime::TimeEntity *time)
Construct this MQTTTimeComponent instance with the provided friendly_name and time.
Implementation of SPI Controller mode.
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.
datetime::TimeEntity * time_
const StringRef & get_name() const
bool send_initial_state() override
bool publish_state(uint8_t hour, uint8_t minute, uint8_t second)