mirror of
https://github.com/esphome/esphome.git
synced 2025-11-19 00:05:43 +00:00
Button device class (#2835)
This commit is contained in:
@@ -30,6 +30,11 @@ void MQTTButtonComponent::dump_config() {
|
||||
LOG_MQTT_COMPONENT(true, true);
|
||||
}
|
||||
|
||||
void MQTTButtonComponent::send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) {
|
||||
if (!this->button_->get_device_class().empty())
|
||||
root[MQTT_DEVICE_CLASS] = this->button_->get_device_class();
|
||||
}
|
||||
|
||||
std::string MQTTButtonComponent::component_type() const { return "button"; }
|
||||
const EntityBase *MQTTButtonComponent::get_entity() const { return this->button_; }
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class MQTTButtonComponent : public mqtt::MQTTComponent {
|
||||
/// Buttons do not send a state so just return true.
|
||||
bool send_initial_state() override { return true; }
|
||||
|
||||
void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override {}
|
||||
void send_discovery(JsonObject &root, mqtt::SendDiscoveryConfig &config) override;
|
||||
|
||||
protected:
|
||||
/// "button" component type.
|
||||
|
||||
Reference in New Issue
Block a user