mirror of
https://github.com/esphome/esphome.git
synced 2025-01-19 04:20:56 +00:00
Add HA Entity Category support to MQTT (#2678)
This commit is contained in:
parent
be9439f10d
commit
a17a6d5346
@ -77,6 +77,17 @@ bool MQTTComponent::send_discovery_() {
|
|||||||
if (!this->get_icon().empty())
|
if (!this->get_icon().empty())
|
||||||
root[MQTT_ICON] = this->get_icon();
|
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)
|
if (config.state_topic)
|
||||||
root[MQTT_STATE_TOPIC] = this->get_state_topic_();
|
root[MQTT_STATE_TOPIC] = this->get_state_topic_();
|
||||||
if (config.command_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";
|
constexpr const char *const MQTT_DEVICE_SUGGESTED_AREA = "suggested_area";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Additional MQTT fields where no abbreviation is defined in HA source
|
||||||
|
constexpr const char *const MQTT_ENTITY_CATEGORY = "entity_category";
|
||||||
|
|
||||||
} // namespace mqtt
|
} // namespace mqtt
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user