mqtt discovery: Set icon for soil moisture sensor
parent
1ea3de712e
commit
c933b4cdcd
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue