Skip to content

Commit

Permalink
added link to the EMS-ESP web interface in HA (IPv4 only)
Browse files Browse the repository at this point in the history
  • Loading branch information
pswid committed Jan 30, 2023
1 parent d36f877 commit b3ee5f4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,8 @@ void Mqtt::ha_status() {
strcpy(uniq, "system_status");
}

doc["uniq_id"] = uniq;
doc["obj_id"] = uniq;
doc["uniq_id"] = uniq;
doc["obj_id"] = uniq;

doc["stat_t"] = mqtt_base_ + "/status";
doc["name"] = "EMS-ESP status";
Expand All @@ -628,7 +628,11 @@ void Mqtt::ha_status() {
dev["sw"] = "v" + std::string(EMSESP_APP_VERSION);
dev["mf"] = "proddy";
dev["mdl"] = "EMS-ESP";
JsonArray ids = dev.createNestedArray("ids");
if (EMSESP::system_.ethernet_connected())
dev["cu"] = ETH.localIP().toString();
else
dev["cu"] = WiFi.localIP().toString();
JsonArray ids = dev.createNestedArray("ids");
ids.add("ems-esp");

char topic[MQTT_TOPIC_MAX_SIZE];
Expand Down Expand Up @@ -1066,7 +1070,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
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 * sc_ha = "state_class"; // state class
const char * sc_ha = "stat_cla"; // state class
const char * uom_ha = "unit_of_meas"; // unit of measure

// handle commands, which are device entities that are writable
Expand All @@ -1084,7 +1088,7 @@ void Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev

// for enums, add options
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++) {
option_list.add(Helpers::translated_word(options[i]));
}
Expand Down Expand Up @@ -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
// used for Sensor and Binary Sensor Entities in HA
if (set_ha_classes) {
const char * dc_ha = "device_class"; // device class
const char * dc_ha = "dev_cla"; // device class

switch (uom) {
case DeviceValueUOM::DEGREES:
Expand Down

0 comments on commit b3ee5f4

Please sign in to comment.