mirror of
https://github.com/esphome/esphome.git
synced 2024-11-13 02:37:47 +01:00
Add HA Entity Category support to MQTT (#2678)
This commit is contained in:
parent
be9439f10d
commit
a17a6d5346
2 changed files with 14 additions and 0 deletions
|
@ -77,6 +77,17 @@ bool MQTTComponent::send_discovery_() {
|
|||
if (!this->get_icon().empty())
|
||||
root[MQTT_ICON] = this->get_icon();
|
||||
|
||||
switch (this->get_entity()->get_entity_category()) {
|
||||
case ENTITY_CATEGORY_NONE:
|
||||
break;
|
||||
case ENTITY_CATEGORY_CONFIG:
|
||||
root[MQTT_ENTITY_CATEGORY] = "config";
|
||||
break;
|
||||
case ENTITY_CATEGORY_DIAGNOSTIC:
|
||||
root[MQTT_ENTITY_CATEGORY] = "diagnostic";
|
||||
break;
|
||||
}
|
||||
|
||||
if (config.state_topic)
|
||||
root[MQTT_STATE_TOPIC] = this->get_state_topic_();
|
||||
if (config.command_topic)
|
||||
|
|
|
@ -512,6 +512,9 @@ constexpr const char *const MQTT_DEVICE_SW_VERSION = "sw_version";
|
|||
constexpr const char *const MQTT_DEVICE_SUGGESTED_AREA = "suggested_area";
|
||||
#endif
|
||||
|
||||
// Additional MQTT fields where no abbreviation is defined in HA source
|
||||
constexpr const char *const MQTT_ENTITY_CATEGORY = "entity_category";
|
||||
|
||||
} // namespace mqtt
|
||||
} // namespace esphome
|
||||
|
||||
|
|
Loading…
Reference in a new issue