mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-17 13:19:55 +03:00
dev 37, add SRC thermostat icons to climate
This commit is contained in:
@@ -2134,9 +2134,16 @@ void EMSdevice::mqtt_ha_entity_config_create() {
|
|||||||
|
|
||||||
// SRC thermostats mapped to connect/src1/...
|
// SRC thermostats mapped to connect/src1/...
|
||||||
if (dv.tag >= DeviceValueTAG::TAG_SRC1 && dv.tag <= DeviceValueTAG::TAG_SRC16 && !strcmp(dv.short_name, FL_(selRoomTemp)[0])) {
|
if (dv.tag >= DeviceValueTAG::TAG_SRC1 && dv.tag <= DeviceValueTAG::TAG_SRC16 && !strcmp(dv.short_name, FL_(selRoomTemp)[0])) {
|
||||||
|
const char * icon = nullptr;
|
||||||
|
for (auto & d : devicevalues_) {
|
||||||
|
if (d.tag == dv.tag && !strcmp(d.short_name, FL_(icon)[0]) && *(uint8_t *)(d.value_p != 0)) {
|
||||||
|
icon = d.options[*(uint8_t *)(d.value_p)][0];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
// add all modes - auto, heat, off, cool
|
// add all modes - auto, heat, off, cool
|
||||||
// https://github.com/emsesp/EMS-ESP32/issues/2636
|
// https://github.com/emsesp/EMS-ESP32/issues/2636
|
||||||
Mqtt::publish_ha_climate_config(dv, true, nullptr, false);
|
Mqtt::publish_ha_climate_config(dv, true, nullptr, false, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
|
|||||||
@@ -1244,7 +1244,7 @@ void Mqtt::add_ha_classes(JsonObject doc, const uint8_t device_type, const uint8
|
|||||||
|
|
||||||
// publish the HA climate config
|
// publish the HA climate config
|
||||||
// https://www.home-assistant.io/integrations/climate.mqtt/
|
// https://www.home-assistant.io/integrations/climate.mqtt/
|
||||||
bool Mqtt::publish_ha_climate_config(const DeviceValue & dv, const bool has_roomtemp, const char * const ** mode_options, const bool remove) {
|
bool Mqtt::publish_ha_climate_config(const DeviceValue & dv, const bool has_roomtemp, const char * const ** mode_options, const bool remove, const char * icon) {
|
||||||
int8_t tag = dv.tag;
|
int8_t tag = dv.tag;
|
||||||
int16_t min = dv.min;
|
int16_t min = dv.min;
|
||||||
uint32_t max = dv.max;
|
uint32_t max = dv.max;
|
||||||
@@ -1402,6 +1402,9 @@ bool Mqtt::publish_ha_climate_config(const DeviceValue & dv, const bool has_room
|
|||||||
modes.add("cool");
|
modes.add("cool");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (icon != nullptr) {
|
||||||
|
doc["ic"] = icon;
|
||||||
|
}
|
||||||
add_ha_dev_section(doc.as<JsonObject>(), devicename, nullptr, nullptr, nullptr, false); // add dev section
|
add_ha_dev_section(doc.as<JsonObject>(), devicename, nullptr, nullptr, nullptr, false); // add dev section
|
||||||
add_ha_avty_section(doc.as<JsonObject>(), topic_t, seltemp_cond, has_roomtemp ? currtemp_cond : nullptr, hc_mode_cond); // add availability section
|
add_ha_avty_section(doc.as<JsonObject>(), topic_t, seltemp_cond, has_roomtemp ? currtemp_cond : nullptr, hc_mode_cond); // add availability section
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,11 @@ class Mqtt {
|
|||||||
const bool create_device_config = false);
|
const bool create_device_config = false);
|
||||||
|
|
||||||
static bool publish_system_ha_sensor_config(uint8_t type, const char * name, const char * entity, const uint8_t uom);
|
static bool publish_system_ha_sensor_config(uint8_t type, const char * name, const char * entity, const uint8_t uom);
|
||||||
static bool publish_ha_climate_config(const DeviceValue & dv, const bool has_roomtemp, const char * const ** mode_options, const bool remove = false);
|
static bool publish_ha_climate_config(const DeviceValue & dv,
|
||||||
|
const bool has_roomtemp,
|
||||||
|
const char * const ** mode_options,
|
||||||
|
const bool remove = false,
|
||||||
|
const char * icon = nullptr);
|
||||||
|
|
||||||
static void show_topic_handlers(uuid::console::Shell & shell, const uint8_t device_type);
|
static void show_topic_handlers(uuid::console::Shell & shell, const uint8_t device_type);
|
||||||
static void show_mqtt(uuid::console::Shell & shell);
|
static void show_mqtt(uuid::console::Shell & shell);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.7.3-dev.36"
|
#define EMSESP_APP_VERSION "3.7.3-dev.37"
|
||||||
|
|||||||
Reference in New Issue
Block a user