home-assistant / frontend

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

ha-service-control displays unsupported values in selector #17122

Closed gbleaney closed 8 months ago

gbleaney commented 1 year ago

Checklist

Describe the issue you are experiencing

This issue manifested as the bug described here, where I set up a script to call the climate service to set the mode to off. The UI picker displayed an off mode option and allowed me to do it, but in reality the flair integration I'm using correctly advertises supported HVAC modes. This resulted in me setting up a script that called an unsupported mode in the background.

Describe the behavior you expected

I believe ha-service-control should only be displaying values that are actually supported by the devices that are being configured. I think this information is already available in the front end via capabilities inExtEntityRegistyEntry` and that it's just a matter of filtering: https://github.com/home-assistant/frontend/blob/ff59e31530f45af2a6557e821fbf20088a71dafa/src/data/entity_registry.ts#L58-L64

I understand that this is borderline between a bug and a feature request, and I'm happy to do the work myself to address this, but I wanted to get buy in from the repo maintainers before I put in the effort to put up a PR.

Steps to reproduce the issue

  1. Set up an HVAC integration such as home-assistant-flair
  2. Configure an HVAC system that supports only a subset of the standard climate HVAC modes
  3. Create a script and edit through the UI at /config/script/edit/SCRIPT_NAME
  4. Call the climate.set_hvac_mode service, and configure it for your device. Notice that the HVAC mode drop down shows unsupported modes

What version of Home Assistant Core has the issue?

2023.6.3

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

No response

karwosts commented 11 months ago

This kind of makes sense to me, but I think it feels like more than just a frontend change to do it correctly.

You'll notice that the service control is not full of hardcoded behaviors for specific services, but rather all the information about how the controls are to be presented comes from the backend, based on the services.yaml of the integration providing the service.

We have a something that feels similar for some services like light.turn_on where we don't show certain fields that are not supported by the light entity being targeted. That's not hardcoded in the frontend though for each service, you'll see that in the services.yaml for light.turn_on the yaml specificies which supportedFeatures flags or attributes are required for the target light to support to show that field.

Unfortunately there's no existing syntax for applying a similar filtering to individual items in a select list. Maybe something like that could be added in the backend to the individual services, then we could use it to filter in the frontend.

github-actions[bot] commented 8 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.