diff --git a/src/mitsubishi2mqtt/config.h b/src/mitsubishi2mqtt/config.h index 0c05238..27ea0f1 100644 --- a/src/mitsubishi2mqtt/config.h +++ b/src/mitsubishi2mqtt/config.h @@ -16,7 +16,7 @@ /*#define MY_LANGUAGE fr-FR // define your language*/ -const PROGMEM char* m2mqtt_version = "2023.8.0"; +const PROGMEM char* m2mqtt_version = "2024.8.1"; //Define global variables for files #ifdef ESP32 diff --git a/src/mitsubishi2mqtt/languages/da-DA.h b/src/mitsubishi2mqtt/languages/da-DA.h index e14d736..dc38830 100644 --- a/src/mitsubishi2mqtt/languages/da-DA.h +++ b/src/mitsubishi2mqtt/languages/da-DA.h @@ -138,4 +138,4 @@ const char txt_upload_refresh[] PROGMEM = "Refresh in"; //Page Init const char txt_init_title[] PROGMEM = "Initial setup"; const char txt_init_reboot_mes[] PROGMEM = "Rebooting and connecting to your WiFi network! You should see it listed in on your access point."; -const char txt_init_reboot[] PROGMEM = "Rebooting..."; \ No newline at end of file +const char txt_init_reboot[] PROGMEM = "Rebooting..."; diff --git a/src/mitsubishi2mqtt/languages/de-DE.h b/src/mitsubishi2mqtt/languages/de-DE.h index b5225e0..0bc31d5 100644 --- a/src/mitsubishi2mqtt/languages/de-DE.h +++ b/src/mitsubishi2mqtt/languages/de-DE.h @@ -136,4 +136,4 @@ const char txt_upload_refresh[] PROGMEM = "Aktualisierung in"; //Page Init const char txt_init_title[] PROGMEM = "Ersteinrichtung"; const char txt_init_reboot_mes[] PROGMEM = "Neustart und Verbindung zu deinem WLAN-Netzwerk wird hergestellt! Du solltest es in deiner AccessPoint Auflistung sehen."; -const char txt_init_reboot[] PROGMEM = "Neustart..."; \ No newline at end of file +const char txt_init_reboot[] PROGMEM = "Neustart..."; diff --git a/src/mitsubishi2mqtt/languages/fr-FR.h b/src/mitsubishi2mqtt/languages/fr-FR.h index aeaf2f8..96e7b22 100644 --- a/src/mitsubishi2mqtt/languages/fr-FR.h +++ b/src/mitsubishi2mqtt/languages/fr-FR.h @@ -136,4 +136,4 @@ const char txt_upload_refresh[] PROGMEM = "Rafaichissement dans "; //Page Init const char txt_init_title[] PROGMEM = "Initialisation"; const char txt_init_reboot_mes[] PROGMEM = "Redémarrage et connexion à votre WIFI. L'appareil doit apparaitre dans votre réseau"; -const char txt_init_reboot[] PROGMEM = "Redémarrage..."; \ No newline at end of file +const char txt_init_reboot[] PROGMEM = "Redémarrage..."; diff --git a/src/mitsubishi2mqtt/languages/ja-JP.h b/src/mitsubishi2mqtt/languages/ja-JP.h index ad83675..e8f1299 100644 --- a/src/mitsubishi2mqtt/languages/ja-JP.h +++ b/src/mitsubishi2mqtt/languages/ja-JP.h @@ -137,4 +137,4 @@ const char txt_upload_refresh[] PROGMEM = "再読込中"; //Page Init const char txt_init_title[] PROGMEM = "初期設定"; const char txt_init_reboot_mes[] PROGMEM = "Rebooting and connecting to your WiFi network! You should see it listed in on your access point."; -const char txt_init_reboot[] PROGMEM = "Rebooting..."; \ No newline at end of file +const char txt_init_reboot[] PROGMEM = "Rebooting..."; diff --git a/src/mitsubishi2mqtt/mitsubishi2mqtt.ino b/src/mitsubishi2mqtt/mitsubishi2mqtt.ino index b63931f..07aa1c7 100644 --- a/src/mitsubishi2mqtt/mitsubishi2mqtt.ino +++ b/src/mitsubishi2mqtt/mitsubishi2mqtt.ino @@ -192,7 +192,7 @@ void setup() { heatpumpSettings currentSettings = hp.getSettings(); rootInfo["roomTemperature"] = convertCelsiusToLocalUnit(currentStatus.roomTemperature, useFahrenheit); rootInfo["temperature"] = convertCelsiusToLocalUnit(currentSettings.temperature, useFahrenheit); - rootInfo["fan"] = currentSettings.fan; + rootInfo["fan"] = hpGetFan(currentSettings); rootInfo["vane"] = currentSettings.vane; rootInfo["wideVane"] = currentSettings.wideVane; rootInfo["mode"] = hpGetMode(currentSettings); @@ -1291,7 +1291,7 @@ void readHeatPumpSettings() { rootInfo.clear(); rootInfo["temperature"] = convertCelsiusToLocalUnit(currentSettings.temperature, useFahrenheit); - rootInfo["fan"] = currentSettings.fan; + rootInfo["fan"] = hpGetFan(currentSettings); rootInfo["vane"] = currentSettings.vane; rootInfo["wideVane"] = currentSettings.wideVane; rootInfo["mode"] = hpGetMode(currentSettings); @@ -1313,7 +1313,7 @@ void hpSettingsChanged() { String hpGetMode(heatpumpSettings hpSettings) { // Map the heat pump state to one of HA's HVAC_MODE_* values. - // https://github.com/home-assistant/core/blob/master/homeassistant/components/climate/const.py#L3-L23 + // https://github.com/home-assistant/core/blob/master/homeassistant/components/climate/const.py#L17-L37 String hppower = String(hpSettings.power); if (hppower.equalsIgnoreCase("off")){ @@ -1328,6 +1328,21 @@ String hpGetMode(heatpumpSettings hpSettings) { else return hpmode; // cool, heat, dry } +String hpGetFan(heatpumpSettings hpSettings) { + // Map the fan speed to one of HA's FAN_* values. + // https://github.com/home-assistant/core/blob/master/homeassistant/components/climate/const.py#L75-L85 + + String hpfan = String(hpSettings.fan); + hpfan.toLowerCase(); + + if (hpfan == "quiet") return "diffuse"; + else if (hpfan == "1") return "low"; + else if (hpfan == "2") return "middle"; + else if (hpfan == "3") return "medium"; + else if (hpfan == "4") return "high"; + else return hpfan; // auto +} + String hpGetAction(heatpumpStatus hpStatus, heatpumpSettings hpSettings) { // Map heat pump state to one of HA's CURRENT_HVAC_* values. // https://github.com/home-assistant/core/blob/master/homeassistant/components/climate/const.py#L80-L86 @@ -1361,7 +1376,7 @@ void hpStatusChanged(heatpumpStatus currentStatus) { rootInfo.clear(); rootInfo["roomTemperature"] = convertCelsiusToLocalUnit(currentStatus.roomTemperature, useFahrenheit); rootInfo["temperature"] = convertCelsiusToLocalUnit(currentSettings.temperature, useFahrenheit); - rootInfo["fan"] = currentSettings.fan; + rootInfo["fan"] = hpGetFan(currentSettings); rootInfo["vane"] = currentSettings.vane; rootInfo["wideVane"] = currentSettings.wideVane; rootInfo["mode"] = hpGetMode(currentSettings); @@ -1483,9 +1498,23 @@ void mqttCallback(char* topic, byte* payload, unsigned int length) { hp.setTemperature(temperature_c); } else if (strcmp(topic, ha_fan_set_topic.c_str()) == 0) { + String fanUpper = message; + fanUpper.toUpperCase(); + String fanSpeed = fanUpper; + if (fanUpper == "DIFFUSE") { + fanSpeed = "QUIET"; + } else if (fanUpper == "LOW") { + fanSpeed = "1"; + } else if (fanUpper == "MIDDLE") { + fanSpeed = "2"; + } else if (fanUpper == "MEDIUM") { + fanSpeed = "3"; + } else if (fanUpper == "HIGH") { + fanSpeed = "4"; + } rootInfo["fan"] = (String) message; hpSendLocalState(); - hp.setFanSpeed(message); + hp.setFanSpeed(fanSpeed.c_str()); } else if (strcmp(topic, ha_vane_set_topic.c_str()) == 0) { rootInfo["vane"] = (String) message; @@ -1606,12 +1635,12 @@ void haConfig() { haConfig["temperature_unit"] = useFahrenheit ? "F" : "C"; JsonArray haConfigFan_modes = haConfig.createNestedArray("fan_modes"); - haConfigFan_modes.add("AUTO"); - haConfigFan_modes.add("QUIET"); - haConfigFan_modes.add("1"); - haConfigFan_modes.add("2"); - haConfigFan_modes.add("3"); - haConfigFan_modes.add("4"); + haConfigFan_modes.add("auto"); + haConfigFan_modes.add("diffuse"); + haConfigFan_modes.add("low"); + haConfigFan_modes.add("middle"); + haConfigFan_modes.add("medium"); + haConfigFan_modes.add("high"); haConfig["fan_mode_cmd_t"] = ha_fan_set_topic; haConfig["fan_mode_stat_t"] = ha_state_topic;