mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
added link to the EMS-ESP web interface in HA (IPv4 only)
This commit is contained in:
10
src/mqtt.cpp
10
src/mqtt.cpp
@@ -628,6 +628,10 @@ void Mqtt::ha_status() {
|
|||||||
dev["sw"] = "v" + std::string(EMSESP_APP_VERSION);
|
dev["sw"] = "v" + std::string(EMSESP_APP_VERSION);
|
||||||
dev["mf"] = "proddy";
|
dev["mf"] = "proddy";
|
||||||
dev["mdl"] = "EMS-ESP";
|
dev["mdl"] = "EMS-ESP";
|
||||||
|
if (EMSESP::system_.ethernet_connected())
|
||||||
|
dev["cu"] = ETH.localIP().toString();
|
||||||
|
else
|
||||||
|
dev["cu"] = WiFi.localIP().toString();
|
||||||
JsonArray ids = dev.createNestedArray("ids");
|
JsonArray ids = dev.createNestedArray("ids");
|
||||||
ids.add("ems-esp");
|
ids.add("ems-esp");
|
||||||
|
|
||||||
@@ -1066,7 +1070,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
|||||||
doc["obj_id"] = uniq_id; // same as unique_id
|
doc["obj_id"] = uniq_id; // same as unique_id
|
||||||
|
|
||||||
const char * ic_ha = "ic"; // icon - only set this if there is no device class
|
const char * ic_ha = "ic"; // icon - only set this if there is no device class
|
||||||
const char * sc_ha = "state_class"; // state class
|
const char * sc_ha = "stat_cla"; // state class
|
||||||
const char * uom_ha = "unit_of_meas"; // unit of measure
|
const char * uom_ha = "unit_of_meas"; // unit of measure
|
||||||
|
|
||||||
// handle commands, which are device entities that are writable
|
// handle commands, which are device entities that are writable
|
||||||
@@ -1084,7 +1088,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
|||||||
|
|
||||||
// for enums, add options
|
// for enums, add options
|
||||||
if (type == DeviceValueType::ENUM) {
|
if (type == DeviceValueType::ENUM) {
|
||||||
JsonArray option_list = doc.createNestedArray("options");
|
JsonArray option_list = doc.createNestedArray("ops"); //options
|
||||||
for (uint8_t i = 0; i < options_size; i++) {
|
for (uint8_t i = 0; i < options_size; i++) {
|
||||||
option_list.add(Helpers::translated_word(options[i]));
|
option_list.add(Helpers::translated_word(options[i]));
|
||||||
}
|
}
|
||||||
@@ -1187,7 +1191,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
|||||||
// this next section is adding the state class, device class and sometimes the icon
|
// this next section is adding the state class, device class and sometimes the icon
|
||||||
// used for Sensor and Binary Sensor Entities in HA
|
// used for Sensor and Binary Sensor Entities in HA
|
||||||
if (set_ha_classes) {
|
if (set_ha_classes) {
|
||||||
const char * dc_ha = "device_class"; // device class
|
const char * dc_ha = "dev_cla"; // device class
|
||||||
|
|
||||||
switch (uom) {
|
switch (uom) {
|
||||||
case DeviceValueUOM::DEGREES:
|
case DeviceValueUOM::DEGREES:
|
||||||
|
|||||||
Reference in New Issue
Block a user