home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
4.11k stars 2.81k forks source link

Invalid Fan Mode error when switching HVAC mode #19620

Open RobertD502 opened 9 months ago

RobertD502 commented 9 months ago

Checklist

Describe the issue you are experiencing

When switching from an HVAC mode with a Fan speed (fan_mode) of Auto to a HVAC mode that only supports a fan speed of Auto, an error message pops up indicating Fan mode is not valid. Valid fan modes are: auto.

For example, if the climate entity is currently in HVAC mode Heat with a Fan mode of Auto, when switching to a HVAC mode that only supports a single Fan Mode (Auto), such as Dry or Heat/Cool in my case, the error pops up in the UI.

Video example shown below

https://github.com/home-assistant/frontend/assets/52541649/db8dc9b3-cc6f-4355-a901-ef3dad0bdb7f

Note: This behavior only happens when switching from a HVAC mode that supports multiple fan modes in addition to the Auto mode, but not when switching from a HVAC mode that only supports an Auto fan_mode to another HVAC mode that only supports an Auto fan_mode (i.e., Going from Dry mode with a Fan mode of Auto to a HVAC mode of Heat/Cool).

Related async_set_hvac_mode code below:

            if hvac_mode in [HVACMode.DRY, HVACMode.HEAT_COOL]:
                # When switching to Dry or Heat_Cool (Auto) mode,
                # a fan speed of Auto is expected

                mode_attributes = self.set_attributes('hvac_mode', mode, False)
                flair_speed = HASS_HVAC_FAN_SPEED_TO_FLAIR.get(FAN_AUTO)
                if self.hvac_data.attributes['fan-speed'] != flair_speed:
                    fan_attributes = self.set_attributes('fan_mode', flair_speed, False)
                    await self.coordinator.client.update('hvac-units', self.hvac_data.id, attributes=mode_attributes, relationships={})
                    await self.coordinator.client.update('hvac-units', self.hvac_data.id, attributes=fan_attributes, relationships={})
                    self.hvac_data.attributes['fan-speed'] = flair_speed
                else:
                    await self.coordinator.client.update('hvac-units', self.hvac_data.id, attributes=mode_attributes, relationships={})

                self.hvac_data.attributes['mode'] = mode
                self.async_write_ha_state()
                await self.coordinator.async_request_refresh()
                return None

As you can see, I am not setting self.hvac_data.attributes['fan-speed'] to flair_speed (which results in the fan_mode property returning the Home Assistant FAN_AUTO constant) prior to writing the HA state when the current fan mode is already Auto.

During my debugging of the error, I have identified that the Climate fan_mode property is correctly returning auto prior to calling self.async_write_ha_state(), after calling self.async_write_ha_state(), and after a refresh is requested from the coordinator. With all of this said, the error seems to be contradicting the actual state of the fan_mode property.

Describe the behavior you expected

When switching from an HVAC mode (which supports multiple fan modes) with a fan mode of Auto, to a HVAC mode that only supports a fan mode of Auto, no error message should be presented.

Steps to reproduce the issue

  1. Start with climate entity in a HVAC mode that supports multiple fan modes (auto, high, medium, low).
  2. Ensure the climate entity has a current fan mode of Auto.
  3. Change the HVAC mode to a HVAC mode that only supports Auto as its fan mode. ...

What version of Home Assistant Core has the issue?

2024.2.0b2

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

No response

Which operating system are you using to run this browser?

No response

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

image

ChristophCaina commented 7 months ago

I have similar issues with my Thermostats when i Change between "Auto", "heating" and "Off"...

ChristophCaina commented 7 months ago

Also, it appears the Same when I select the Program in my Coffee machine...

github-actions[bot] commented 4 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

RobertD502 commented 4 months ago

Still an issue in the latest 20240705.0 frontend.

karwosts commented 4 months ago

I'm able to reproduce a similar effect by messing in developer tools. E.g. load up the climate.ecobee more-info from the demo integration.

Has the following fan modes, with default set to on_high

fan_modes:
  - on_low
  - on_high
  - auto_low
  - auto_high
  - "off"

While the more info is open, in developer tools in a separate window change the attribute fan modes to this:

fan_modes:
  - on_high

The fan mode control becomes bugged and it sends the invalid service call.

I guess the dropdown does not like it when it is selected to a particular index, and then the number of options changes to be less than that index, it resets the control to undefined and triggers a spurious service call. Same with any of the other dropdowns.

github-actions[bot] commented 1 month ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

RobertD502 commented 1 month ago

Bump

nchieffo commented 1 month ago

I'm also affected