9#ifdef USE_DATETIME_TIME
13static const char *
const TAG =
"mqtt.datetime.time";
22 if (root[ESPHOME_F(
"hour")].is<uint8_t>()) {
23 call.set_hour(root[ESPHOME_F(
"hour")]);
25 if (root[ESPHOME_F(
"minute")].is<uint8_t>()) {
26 call.set_minute(root[ESPHOME_F(
"minute")]);
28 if (root[ESPHOME_F(
"second")].is<uint8_t>()) {
29 call.set_second(root[ESPHOME_F(
"second")]);
39 LOG_MQTT_COMPONENT(
true,
true)
58 root[ESPHOME_F(
"hour")] =
hour;
59 root[ESPHOME_F(
"minute")] =
minute;
60 root[ESPHOME_F(
"second")] =
second;
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.
MQTTTimeComponent(datetime::TimeEntity *time)
Construct this MQTTTimeComponent instance with the provided friendly_name and time.
datetime::TimeEntity * time_
bool send_initial_state() override
void dump_config() override
void send_discovery(JsonObject root, mqtt::SendDiscoveryConfig &config) override
void setup() override
Override setup.
bool publish_state(uint8_t hour, uint8_t minute, uint8_t second)
MQTT_COMPONENT_TYPE(MQTTAlarmControlPanelComponent, "alarm_control_panel") const EntityBase *MQTTAlarmControlPanelComponent
Simple Helper struct used for Home Assistant MQTT send_discovery().