Skip to content

Commit

Permalink
ECO preset replaced with Quiet fan speed
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo Dudnytskyi committed Aug 30, 2024
1 parent 870ec08 commit c6dcec1
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 56 deletions.
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ This component requires a `UART Bus <https://esphome.io/components/uart#uart>`_
- BOTH
supported_presets:
- AWAY
- ECO
- BOOST
- SLEEP
on_alarm_start:
Expand Down Expand Up @@ -123,7 +122,7 @@ Configuration variables:
- **beeper** (*Optional*, boolean): Can be used to disable beeping on commands from AC. Supported only by hOn protocol.
- **supported_modes** (*Optional*, list): Can be used to disable some of AC modes. Possible values: ``'OFF'``, ``HEAT_COOL``, ``COOL``, ``HEAT``, ``DRY``, ``FAN_ONLY``.
- **supported_swing_modes** (*Optional*, list): Can be used to disable some swing modes if your AC does not support it. Possible values: ``'OFF'``, ``VERTICAL``, ``HORIZONTAL``, ``BOTH``.
- **supported_presets** (*Optional*, list): Can be used to disable some presets. Possible values for smartair2 are: ``AWAY``, ``BOOST``, ``COMFORT``. Possible values for hOn are: ``AWAY``, ``ECO``, ``BOOST``, ``SLEEP``. ``AWAY`` preset can be enabled only in ``HEAT`` mode, it is disabled by default.
- **supported_presets** (*Optional*, list): Can be used to disable some presets. Possible values for smartair2 are: ``AWAY``, ``BOOST``, ``COMFORT``. Possible values for hOn are: ``AWAY``, ``BOOST``, ``SLEEP``. ``AWAY`` preset can be enabled only in ``HEAT`` mode, it is disabled by default.
- **on_alarm_start** (*Optional*, `Automation <https://esphome.io/guides/automations#automation>`_): (supported only by hOn) Automation to perform when AC activates a new alarm. See `on_alarm_start Trigger`_.
- **on_alarm_end** (*Optional*, `Automation <https://esphome.io/guides/automations#automation>`_): (supported only by hOn) Automation to perform when AC deactivates a new alarm. See `on_alarm_end Trigger`_.
- **on_status_message** (*Optional*, `Automation <https://esphome.io/guides/automations#automation>`_): Automation to perform when status message received from AC. See `on_status_message Trigger`_.
Expand Down
3 changes: 1 addition & 2 deletions components/haier/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
SUPPORTED_CLIMATE_PRESETS_HON_OPTIONS = {
"AWAY": ClimatePreset.CLIMATE_PRESET_AWAY,
"BOOST": ClimatePreset.CLIMATE_PRESET_BOOST,
"ECO": ClimatePreset.CLIMATE_PRESET_ECO,
"SLEEP": ClimatePreset.CLIMATE_PRESET_SLEEP,
}

Expand Down Expand Up @@ -256,7 +255,7 @@ def validate_visual(config):
): cv.int_range(min=PROTOCOL_STATUS_MESSAGE_HEADER_SIZE),
cv.Optional(
CONF_SUPPORTED_PRESETS,
default=["BOOST", "ECO", "SLEEP"], # No AWAY by default
default=["BOOST", "SLEEP"], # No AWAY by default
): cv.ensure_list(
cv.enum(SUPPORTED_CLIMATE_PRESETS_HON_OPTIONS, upper=True)
),
Expand Down
110 changes: 63 additions & 47 deletions components/haier/hon_climate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ HonClimate::HonClimate()
0x00, 0x00} {
this->fan_mode_speed_ = (uint8_t) hon_protocol::FanMode::FAN_MID;
this->other_modes_fan_speed_ = (uint8_t) hon_protocol::FanMode::FAN_AUTO;
this->traits_.add_supported_fan_mode(CLIMATE_FAN_QUIET);
}

HonClimate::~HonClimate() {}
Expand Down Expand Up @@ -546,16 +547,26 @@ haier_protocol::HaierMessage HonClimate::get_control_message() {
switch (climate_control.fan_mode.value()) {
case CLIMATE_FAN_LOW:
out_data->fan_mode = (uint8_t) hon_protocol::FanMode::FAN_LOW;
out_data->quiet_mode = 0;
break;
case CLIMATE_FAN_MEDIUM:
out_data->fan_mode = (uint8_t) hon_protocol::FanMode::FAN_MID;
out_data->quiet_mode = 0;
break;
case CLIMATE_FAN_HIGH:
out_data->fan_mode = (uint8_t) hon_protocol::FanMode::FAN_HIGH;
out_data->quiet_mode = 0;
break;
case CLIMATE_FAN_AUTO:
if (mode != CLIMATE_MODE_FAN_ONLY) // if we are not in fan only mode
if (mode != CLIMATE_MODE_FAN_ONLY) { // if we are not in fan only mode
out_data->fan_mode = (uint8_t) hon_protocol::FanMode::FAN_AUTO;
out_data->quiet_mode = 0;
}
break;
case CLIMATE_FAN_QUIET:
if (mode != CLIMATE_MODE_FAN_ONLY) { // if we are not in fan only mode
out_data->quiet_mode = 1;
}
break;
default:
ESP_LOGE("Control", "Unsupported fan mode");
Expand Down Expand Up @@ -601,13 +612,6 @@ haier_protocol::HaierMessage HonClimate::get_control_message() {
out_data->sleep_mode = 0;
out_data->ten_degree = 0;
break;
case CLIMATE_PRESET_ECO:
// Eco is not supported in Fan only mode
out_data->quiet_mode = (this->mode != CLIMATE_MODE_FAN_ONLY) ? 1 : 0;
out_data->fast_mode = 0;
out_data->sleep_mode = 0;
out_data->ten_degree = 0;
break;
case CLIMATE_PRESET_BOOST:
out_data->quiet_mode = 0;
// Boost is not supported in Fan only mode
Expand Down Expand Up @@ -846,9 +850,7 @@ haier_protocol::HandlerError HonClimate::process_status_message_(const uint8_t *
{
// Extra modes/presets
optional<ClimatePreset> old_preset = this->preset;
if (packet.control.quiet_mode != 0) {
this->preset = CLIMATE_PRESET_ECO;
} else if (packet.control.fast_mode != 0) {
if (packet.control.fast_mode != 0) {
this->preset = CLIMATE_PRESET_BOOST;
} else if (packet.control.sleep_mode != 0) {
this->preset = CLIMATE_PRESET_SLEEP;
Expand Down Expand Up @@ -881,24 +883,36 @@ haier_protocol::HandlerError HonClimate::process_status_message_(const uint8_t *
} else {
this->other_modes_fan_speed_ = packet.control.fan_mode;
}
switch (packet.control.fan_mode) {
case (uint8_t) hon_protocol::FanMode::FAN_AUTO:
if (packet.control.ac_mode != (uint8_t) hon_protocol::ConditioningMode::FAN) {
this->fan_mode = CLIMATE_FAN_AUTO;
} else {
// Shouldn't accept fan speed auto in fan-only mode even if AC reports it
ESP_LOGI(TAG, "Fan speed Auto is not supported in Fan only AC mode, ignoring");
}
break;
case (uint8_t) hon_protocol::FanMode::FAN_MID:
this->fan_mode = CLIMATE_FAN_MEDIUM;
break;
case (uint8_t) hon_protocol::FanMode::FAN_LOW:
this->fan_mode = CLIMATE_FAN_LOW;
break;
case (uint8_t) hon_protocol::FanMode::FAN_HIGH:
this->fan_mode = CLIMATE_FAN_HIGH;
break;
bool fan_mode_processed = false;
if (packet.control.quiet_mode != 0) {
if (packet.control.ac_mode != (uint8_t) hon_protocol::ConditioningMode::FAN) {
this->fan_mode = CLIMATE_FAN_QUIET;
fan_mode_processed = true;
} else {
// Shouldn't accept quiet mode in fan-only mode even if AC reports it
ESP_LOGI(TAG, "Quiet mode is not supported in Fan only AC mode, ignoring");
}
}
if (!fan_mode_processed) {
switch (packet.control.fan_mode) {
case (uint8_t) hon_protocol::FanMode::FAN_AUTO:
if (packet.control.ac_mode != (uint8_t) hon_protocol::ConditioningMode::FAN) {
this->fan_mode = CLIMATE_FAN_AUTO;
} else {
// Shouldn't accept fan speed auto in fan-only mode even if AC reports it
ESP_LOGI(TAG, "Fan speed Auto is not supported in Fan only AC mode, ignoring");
}
break;
case (uint8_t) hon_protocol::FanMode::FAN_MID:
this->fan_mode = CLIMATE_FAN_MEDIUM;
break;
case (uint8_t) hon_protocol::FanMode::FAN_LOW:
this->fan_mode = CLIMATE_FAN_LOW;
break;
case (uint8_t) hon_protocol::FanMode::FAN_HIGH:
this->fan_mode = CLIMATE_FAN_HIGH;
break;
}
}
should_publish = should_publish || (!old_fan_mode.has_value()) || (old_fan_mode.value() != fan_mode.value());
}
Expand Down Expand Up @@ -1126,30 +1140,20 @@ void HonClimate::fill_control_messages_queue_() {
uint8_t away_mode_buf[] = {0x00, 0xFF};
if (!new_power) {
// If AC is off - no presets allowed
quiet_mode_buf[1] = 0x00;
fast_mode_buf[1] = 0x00;
away_mode_buf[1] = 0x00;
} else if (climate_control.preset.has_value()) {
switch (climate_control.preset.value()) {
case CLIMATE_PRESET_NONE:
quiet_mode_buf[1] = 0x00;
fast_mode_buf[1] = 0x00;
away_mode_buf[1] = 0x00;
break;
case CLIMATE_PRESET_ECO:
// Eco is not supported in Fan only mode
quiet_mode_buf[1] = (this->mode != CLIMATE_MODE_FAN_ONLY) ? 0x01 : 0x00;
fast_mode_buf[1] = 0x00;
away_mode_buf[1] = 0x00;
break;
case CLIMATE_PRESET_BOOST:
quiet_mode_buf[1] = 0x00;
// Boost is not supported in Fan only mode
fast_mode_buf[1] = (this->mode != CLIMATE_MODE_FAN_ONLY) ? 0x01 : 0x00;
away_mode_buf[1] = 0x00;
break;
case CLIMATE_PRESET_AWAY:
quiet_mode_buf[1] = 0x00;
fast_mode_buf[1] = 0x00;
away_mode_buf[1] = (this->mode == CLIMATE_MODE_HEAT) ? 0x01 : 0x00;
break;
Expand All @@ -1159,13 +1163,6 @@ void HonClimate::fill_control_messages_queue_() {
}
}
auto presets = this->traits_.get_supported_presets();
if ((quiet_mode_buf[1] != 0xFF) && ((presets.find(climate::ClimatePreset::CLIMATE_PRESET_ECO) != presets.end()))) {
this->control_messages_queue_.push(
haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
(uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
(uint8_t) hon_protocol::DataParameters::QUIET_MODE,
quiet_mode_buf, 2));
}
if ((fast_mode_buf[1] != 0xFF) && ((presets.find(climate::ClimatePreset::CLIMATE_PRESET_BOOST) != presets.end()))) {
this->control_messages_queue_.push(
haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
Expand Down Expand Up @@ -1225,21 +1222,40 @@ void HonClimate::fill_control_messages_queue_() {
switch (climate_control.fan_mode.value()) {
case CLIMATE_FAN_LOW:
fan_mode_buf[1] = (uint8_t) hon_protocol::FanMode::FAN_LOW;
quiet_mode_buf[1] = 0;
break;
case CLIMATE_FAN_MEDIUM:
fan_mode_buf[1] = (uint8_t) hon_protocol::FanMode::FAN_MID;
quiet_mode_buf[1] = 0;
break;
case CLIMATE_FAN_HIGH:
fan_mode_buf[1] = (uint8_t) hon_protocol::FanMode::FAN_HIGH;
quiet_mode_buf[1] = 0;
break;
case CLIMATE_FAN_AUTO:
if (mode != CLIMATE_MODE_FAN_ONLY) // if we are not in fan only mode
if (mode != CLIMATE_MODE_FAN_ONLY) { // if we are not in fan only mode
fan_mode_buf[1] = (uint8_t) hon_protocol::FanMode::FAN_AUTO;
quiet_mode_buf[1] = 0;
}
break;
case CLIMATE_FAN_QUIET:
if (mode != CLIMATE_MODE_FAN_ONLY) { // if we are not in fan only mode
quiet_mode_buf[1] = 1;
} else {
ESP_LOGI(TAG, "Quiet mode is not supported in Fan only AC mode, ignoring");
}
break;
default:
ESP_LOGE("Control", "Unsupported fan mode");
break;
}
if (quiet_mode_buf[1] != 0xFF) {
this->control_messages_queue_.push(
haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
(uint16_t) hon_protocol::SubcommandsControl::SET_SINGLE_PARAMETER +
(uint8_t) hon_protocol::DataParameters::QUIET_MODE,
quiet_mode_buf, 2));
}
if (fan_mode_buf[1] != 0xFF) {
this->control_messages_queue_.push(
haier_protocol::HaierMessage(haier_protocol::FrameType::CONTROL,
Expand Down
1 change: 0 additions & 1 deletion configs/climate/haier_hon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
- HORIZONTAL
- BOTH
supported_presets: # Optional, can be used to disable some presets if your AC does not support it
- ECO
- BOOST
- SLEEP
# Next two triggers calling Home Assistant services to notify user about alarms triggered by AC
Expand Down
3 changes: 1 addition & 2 deletions docs/esphome-docs/climate/haier.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ This component requires a :ref:`uart` to be setup.
- BOTH
supported_presets:
- AWAY
- ECO
- BOOST
- SLEEP
on_alarm_start:
Expand Down Expand Up @@ -125,7 +124,7 @@ Configuration variables:
- **beeper** (*Optional*, boolean): Can be used to disable beeping on commands from AC. Supported only by hOn protocol.
- **supported_modes** (*Optional*, list): Can be used to disable some of AC modes. Possible values: ``'OFF'``, ``HEAT_COOL``, ``COOL``, ``HEAT``, ``DRY``, ``FAN_ONLY``.
- **supported_swing_modes** (*Optional*, list): Can be used to disable some swing modes if your AC does not support it. Possible values: ``'OFF'``, ``VERTICAL``, ``HORIZONTAL``, ``BOTH``.
- **supported_presets** (*Optional*, list): Can be used to disable some presets. Possible values for smartair2 are: ``AWAY``, ``BOOST``, ``COMFORT``. Possible values for hOn are: ``AWAY``, ``ECO``, ``BOOST``, ``SLEEP``. ``AWAY`` preset can be enabled only in ``HEAT`` mode, it is disabled by default.
- **supported_presets** (*Optional*, list): Can be used to disable some presets. Possible values for smartair2 are: ``AWAY``, ``BOOST``, ``COMFORT``. Possible values for hOn are: ``AWAY``, ``BOOST``, ``SLEEP``. ``AWAY`` preset can be enabled only in ``HEAT`` mode, it is disabled by default.
- **on_alarm_start** (*Optional*, :ref:`Automation <automation>`): (supported only by hOn) Automation to perform when AC activates a new alarm. See :ref:`haier-on_alarm_start`.
- **on_alarm_end** (*Optional*, :ref:`Automation <automation>`): (supported only by hOn) Automation to perform when AC deactivates a new alarm. See :ref:`haier-on_alarm_end`.
- **on_status_message** (*Optional*, :ref:`Automation <automation>`): Automation to perform when status message received from AC. See :ref:`haier-on_status_message`.
Expand Down
1 change: 0 additions & 1 deletion docs/examples/max-hon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ climate:
- HORIZONTAL
- BOTH
supported_presets:
- ECO
- BOOST
- SLEEP
on_alarm_start:
Expand Down
1 change: 0 additions & 1 deletion docs/hon_example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ Maximum configuration witch will use all possible options will look like this:
- HORIZONTAL
- BOTH
supported_presets:
- ECO
- BOOST
- SLEEP
on_alarm_start:
Expand Down
20 changes: 20 additions & 0 deletions docs/update_docs.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@echo off
SET base_path=%~dp0
cd %base_path%..
echo ===============================================================================================================
echo Updaiting README.rst
echo ===============================================================================================================
python %base_path%script/make_doc.py README.rst
echo ===============================================================================================================
echo Updaiting docs/hon_example.rst
echo ===============================================================================================================
python %base_path%script/process_examples.py %base_path%examples/hon_example.rst %base_path%hon_example.rst
echo ===============================================================================================================
echo Updaiting docs/smartair2_example.rst
echo ===============================================================================================================
python %base_path%script/process_examples.py %base_path%examples/smartair2_example.rst %base_path%smartair2_example.rst
echo ===============================================================================================================
echo Updaiting docs/usb_2_uart_boards.rst
echo ===============================================================================================================
python %base_path%script/process_examples.py %base_path%examples/usb_2_uart_boards.rst %base_path%usb_2_uart_boards.rst
cd %base_path%

0 comments on commit c6dcec1

Please sign in to comment.