From c933b4cdcdd85d11934f200b5f49af0a29f05901 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Mon, 16 May 2022 21:42:41 -0500 Subject: [PATCH] mqtt discovery: Set icon for soil moisture sensor --- mqtt_discovery.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mqtt_discovery.cpp b/mqtt_discovery.cpp index a7c4465..736c948 100644 --- a/mqtt_discovery.cpp +++ b/mqtt_discovery.cpp @@ -13,6 +13,7 @@ struct sensor_config { const char* unit; const char* state_class; const char* entity_category; + const char* icon; }; static bool publish_config(PubSubClient* mqtt, const char* topic, @@ -34,6 +35,9 @@ static bool publish_config(PubSubClient* mqtt, const char* topic, if (config->entity_category != NULL) { doc["entity_category"] = config->entity_category; } + if (config->icon != NULL) { + doc["icon"] = config->icon; + } auto device = doc.createNestedObject("device"); device["manufacturer"] = DEVICE_MANUFACTURER; device["name"] = DEVICE_NAME; @@ -61,7 +65,9 @@ bool publish_all_config(PubSubClient* mqtt, const char* ident) { .device_class = NULL, .unit = NULL, .state_class = "measurement", - .entity_category = NULL}; + .entity_category = NULL, + .icon = "mdi:water", + }; publish_config(mqtt, TOPIC_CFG_MOISTURE, &moisture); struct sensor_config temperature = { .name = "Garden Sensor Temperature",