diff --git a/docs/source/Plugin/P093.rst b/docs/source/Plugin/P093.rst index 19dba41dd3..105aad1225 100644 --- a/docs/source/Plugin/P093.rst +++ b/docs/source/Plugin/P093.rst @@ -74,7 +74,7 @@ See: :ref:`SerialHelper_page` Once we hit submit, the plugin will start sending messages through controller, i.e. MQTT with payload: -``{"roomTemperature":25.5,"wideVane":"|","power":"OFF","mode":"COOL","fan":"AUTO","vane":"AUTO","iSee":true,"operating":true,"compressorFrequency":5,"temperature":24.0}`` +``{"roomTemperature":19.5,"wideVane":"|","power":"OFF","mode":"HEAT","fan":"AUTO","vane":"AUTO","iSee":false,"operating":false,"compressorFrequency":2,"temperature":22.0,"remoteTemperature":19.5}`` Message is send every time a change is detected (i.e. one changes settings using IR remote control) and every X seconds, as set in the settings (60 seconds in above screenshot). @@ -127,6 +127,12 @@ Special thanks Change log ---------- +.. versionchanged:: 2023/09/25 + ... + + |added| + Set Remote Temperature. (value > 0: Use external temperature sensor, value = 0: Use internal temperature sensor) + .. versionchanged:: 2021/08/03 ... diff --git a/docs/source/Plugin/P093_commands.repl b/docs/source/Plugin/P093_commands.repl index 4f7a036f09..ce6a14dd60 100644 --- a/docs/source/Plugin/P093_commands.repl +++ b/docs/source/Plugin/P093_commands.repl @@ -32,3 +32,8 @@ "," Value = ``<<``, ``<``, ``|``, ``>``, ``>>``, ``<>`` or ``SWING`` " + " + ``MitsubishiHP,remotetemperature,`` + "," + Value > ``0.0``: Use external temperature sensor, Value = ``0.0``: Use internal temperature sensor. + " diff --git a/docs/source/Plugin/P093_config_values.repl b/docs/source/Plugin/P093_config_values.repl index 23940e3117..cb142f1e69 100644 --- a/docs/source/Plugin/P093_config_values.repl +++ b/docs/source/Plugin/P093_config_values.repl @@ -6,6 +6,7 @@ | ``[#roomTemperature]`` "," | Value as received from the connected device, includes 1 decimal. + | When Remote Temperature is used, received value is rounded to the nearest 0.5 C. " " | ``[#wideVane]`` @@ -52,3 +53,8 @@ "," | Value as received from the connected device, when ``Include AC status`` is enabled. " + " + | ``[#remoteTemperature]`` + "," + | Value as received from the connected device, includes 1 decimal. + " diff --git a/src/_P093_MitsubishiHP.ino b/src/_P093_MitsubishiHP.ino index 8a6f641c69..2c7db6e17d 100644 --- a/src/_P093_MitsubishiHP.ino +++ b/src/_P093_MitsubishiHP.ino @@ -6,6 +6,7 @@ // ####################################################################################################### /** Changelog: + * 2023-09-21 jfmennedy: Add support for "SetRemoteTemperature" Issue#4711 * 2023-05-04 tonhuisman: Add support for PLUGIN_GET_CONFIG_VALUE to enable fetching all available values (as included in the json) * 2023-05-04 tonhuisman: Start Changelog */ @@ -14,6 +15,7 @@ * Usage: [#] * Supported configNames are: (not case-sensitive) * - roomTemperature + * - remoteTemperature * - wideVane * - power * - mode diff --git a/src/src/PluginStructs/P093_data_struct.cpp b/src/src/PluginStructs/P093_data_struct.cpp index 3e25aa01fa..abda89fe6f 100644 --- a/src/src/PluginStructs/P093_data_struct.cpp +++ b/src/src/PluginStructs/P093_data_struct.cpp @@ -10,6 +10,10 @@ * * Plugin is based on "Arduino library to control Mitsubishi Heat Pumps" from * https://github.com/SwiCago/HeatPump. + * + * SetRemoteTemperature is based on following Issue and Resolve + * https://github.com/SwiCago/HeatPump/pull/144#issue-514996963 + * https://github.com/SwiCago/HeatPump/pull/144/commits/c50372c7632b9e7324caf0c0fc0773871645688e * */ @@ -78,7 +82,9 @@ bool P093_data_struct::read(String& result) const { result += _currentValues.compressorFrequency; } result += F(",\"temperature\":"); - result += toString(_currentValues.temperature, 1) + '}'; + result += toString(_currentValues.temperature, 1); + result += F(",\"remoteTemperature\":"); + result += toString(_currentValues.remoteTemperature, 1) + '}'; return true; } @@ -120,6 +126,9 @@ bool P093_data_struct::plugin_get_config_value(struct EventStruct *event, } else if (_includeStatus && equals(command, F("compressorfrequency"))) { string = _currentValues.compressorFrequency; + } else + if (equals(command, F("remotetemperature"))) { + string = toString(_currentValues.remoteTemperature, 1); } else { success = false; } @@ -149,6 +158,13 @@ void P093_data_struct::write(const String& command, const String& value) { _writeStatus.set(Vane); } else if ((equals(command, F("widevane"))) && lookup(value, _mappings.wideVane, _wantedSettings.wideVane)) { _writeStatus.set(WideVane); + } else if (equals(command, F("remotetemperature"))) { + float remotetemperature = 0; + + if (string2float(value, remotetemperature)) { + _wantedSettings.remoteTemperature = remotetemperature; + _writeStatus.set(RemoteTemperature); + } } # undef lookup @@ -294,6 +310,10 @@ void P093_data_struct::applySettingsLocally() { if (_writeStatus.isDirty(WideVane)) { _currentValues.wideVane = _wantedSettings.wideVane; } + + if (_writeStatus.isDirty(RemoteTemperature)) { + _currentValues.remoteTemperature = _wantedSettings.remoteTemperature; + } } void P093_data_struct::cancelWaitingAndTransitTo(P093_data_struct::State state) { @@ -359,8 +379,26 @@ void P093_data_struct::applySettings() { packet[7] |= 0x01; } + if (_writeStatus.isDirty(RemoteTemperature)) { + memset(packet + 6, 0, 15); + packet[5] = 0x07; + if(_wantedSettings.remoteTemperature > 0) { + packet[6] |= 0x01; + _wantedSettings.remoteTemperature = _wantedSettings.remoteTemperature * 2; + _wantedSettings.remoteTemperature = round(_wantedSettings.remoteTemperature); + _wantedSettings.remoteTemperature = _wantedSettings.remoteTemperature / 2; + if (_tempMode) { //units that don't support 0.5 increment + packet[8] = static_cast(_wantedSettings.remoteTemperature * 2.0f + 128.0f); + } else { //units that do support 0.5 increment + packet[7] = static_cast(3.0f + ((_wantedSettings.remoteTemperature - 10.0f) * 2.0f)); + } + } + else { + packet[6] = 0x00; + packet[8] = 0x80; //MHK1 send 80, even though it could be 00, since ControlByte is 00 + } + } packet[21] = checkSum(packet, 21); - sendPacket(packet, PACKET_LEN); } diff --git a/src/src/PluginStructs/P093_data_struct.h b/src/src/PluginStructs/P093_data_struct.h index 19bf81be0a..df95e65c38 100644 --- a/src/src/PluginStructs/P093_data_struct.h +++ b/src/src/PluginStructs/P093_data_struct.h @@ -118,12 +118,13 @@ struct P093_data_struct : public PluginTaskData_base { ReadTimeout }; - static const uint8_t Temperature = 0x01; - static const uint8_t Power = 0x02; - static const uint8_t Mode = 0x04; - static const uint8_t Fan = 0x08; - static const uint8_t Vane = 0x10; - static const uint8_t WideVane = 0x20; + static const uint8_t Temperature = 0x01; + static const uint8_t Power = 0x02; + static const uint8_t Mode = 0x04; + static const uint8_t Fan = 0x08; + static const uint8_t Vane = 0x10; + static const uint8_t WideVane = 0x20; + static const uint8_t RemoteTemperature = 0x30; struct WriteStatus { WriteStatus() : _flags(0) {} @@ -158,6 +159,7 @@ struct P093_data_struct : public PluginTaskData_base { uint8_t vane; uint8_t wideVane; float roomTemperature; + float remoteTemperature; bool operating; uint8_t compressorFrequency; @@ -165,23 +167,25 @@ struct P093_data_struct : public PluginTaskData_base { power(0), iSee(false), mode(0), - temperature(0), + temperature(0.0f), fan(0), vane(0), wideVane(0), - roomTemperature(0), + roomTemperature(0.0f), + remoteTemperature(0.0f), operating(false), compressorFrequency(0) {} bool operator!=(const Values& rhs) const { return power != rhs.power || mode != rhs.mode || - temperature != rhs.temperature || + !essentiallyEqual(temperature, rhs.temperature) || fan != rhs.fan || vane != rhs.vane || wideVane != rhs.wideVane || iSee != rhs.iSee || - roomTemperature != rhs.roomTemperature || + !essentiallyEqual(roomTemperature, rhs.roomTemperature) || + !essentiallyEqual(remoteTemperature, rhs.remoteTemperature) || operating != rhs.operating || compressorFrequency != rhs.compressorFrequency; }