esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
291 stars 34 forks source link

[Climate] Fan mode Middle appears after High #5860

Open loongyh opened 1 month ago

loongyh commented 1 month ago

The problem

The fan mode Middle is ordered after High which causes this weird quirk in the frontend:

1

Proper ordering should be Auto, Low, Medium, Middle, High.

Looking at the entity's state attributes, Middle is indeed defined after High in fan_modes:

2

Home Assistant orders the fan modes according to what is passed in the entity's fan_modes attribute. Could this be caused by Middle being enumed after High in ClimateFanMode?

I'm using a custom component as in attached YAML snippet but after skimming through the code I don't see anything relevant to fan mode ordering.

Which version of ESPHome has the issue?

2024.5.2

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2024.5.5

What platform are you using?

ESP32

Board

No response

Component causing the issue

climate

Example YAML snippet

external_components:
  - source: github://echavet/MitsubishiCN105ESPHome

logger:
  level: INFO

uart:
  id: HP_UART
  baud_rate: 2400
  tx_pin: 17
  rx_pin: 16

climate:
  - platform: cn105
    name: "AC"
    supports:
      mode: [COOL, DRY]
      fan_mode: [AUTO, LOW, MEDIUM, MIDDLE, HIGH]
      swing_mode: ["OFF", VERTICAL]
    visual:
      min_temperature: 16
      max_temperature: 31
      temperature_step:
        target_temperature: 1
        current_temperature: 0.1
    compressor_frequency_sensor:
      name: AC Compressor Frequency
      icon: mdi:hvac
    vertical_vane_select:
      name: AC Vane
      icon: mdi:arrow-oscillating

Anything in the logs that might be useful for us?

No response

Additional information

This quirk can also be seen in another issue.

ssieb commented 1 month ago

Modes aren't really expected to have an ordering.

loongyh commented 1 month ago

Hmm do you mean ordering should be done in the frontend regardless of the order passed? It seems there's consensus on this as according to this issue of the climate card I'm using there was an attempt to implement ordering logic.

Still in the context of ESPHome's climate component, is there a reason why Middle is enumed after High?

...
  /// The fan mode is set to Medium
  CLIMATE_FAN_MEDIUM = 4,
  /// The fan mode is set to High
  CLIMATE_FAN_HIGH = 5,
  /// The fan mode is set to Middle
  CLIMATE_FAN_MIDDLE = 6,
...

I'm thinking it's a straightforward fix to simply swap High and Middle. However, we need to make sure there are no dependencies on the enum integers by other components.