1
0
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:
Jesse Hills
2021-12-01 04:18:21 +13:00
committed by GitHub
parent 0f47ffd908
commit b32b918936
11 changed files with 64 additions and 4 deletions

View File

@@ -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_; }

View File

@@ -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.