frontend icon indicating copy to clipboard operation
frontend copied to clipboard

Climate more-info calls service unnecessarily if preset mode changed by integration

Open msp1974 opened this issue 1 year ago • 0 comments

Checklist

  • [X] I have updated to the latest available Home Assistant version.
  • [X] I have cleared the cache of my browser.
  • [X] I have tried a different browser to see if it is related to my browser.

Describe the issue you are experiencing

On the climate control (maybe applies to others too), if the more info dialog is open and the preset mode (looking at the code think also applies to all supported functions that can be changed in more info) is changed by the integration (not the UI), the UI in _handlePresetmodeChanged calls the service to change preset mode. However, this is unnecessary as it has already been set.

This issue is very prevalent when an integration uses preset modes to both set a mode but also display modes that cannot be set directly but are from logic on the heating controller. Selecting the preset mode in the UI does correctly set the preset mode but then the integration reports a preset mode of None. If the more info dialog is open, this updates the select box and causes it to call the service again, resulting in an error:

Failed to call service climate/set_preset_mode. String value is None for dictionary value @ data['preset_mode']

Describe the behavior you expected

If the select box is changed by a re-render and not by UI interaction, it should not call the service to set preset mode. Equally if the preset mode is None, it should not call the service.

Steps to reproduce the issue

  1. Access more-info dialog for a climate entity
  2. Set preset mode to x
  3. Change the preset mode outside the more info dialog
  4. Monitor the service calls to the integration and see another service call made.
  5. Additionally, set the preset mode outside the more info to an option not available in preset modes in UI
  6. Get the error as described above ...

What version of Home Assistant Core has the issue?

2022.9.4

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Firefox 104.0 and Chrome 105.0.5195.127

Which operating system are you using to run this browser?

Ubuntu 20.04 and Windows 11

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

Video Example

https://www.loom.com/share/f9ef44680149423e9ff203cebc5e1a44

msp1974 avatar Sep 18 '22 16:09 msp1974