Open Mariusthvdb opened 2 weeks ago
made a second one:
and that does show alright. checking the entity_registry on those reveals something interesting:
{"aliases":[],"area_id":null,"categories":{},"capabilities":null,"config_entry_id":"c81b18ff91b463722f311755b7c13f6d","device_class":null,"device_id":null,"disabled_by":null,"entity_category":null,"entity_id":"binary_sensor.donker_thema_2","hidden_by":null,"icon":null,"id":"8fed530249c0e3efe9f8afa346ff2a9f","has_entity_name":false,"labels":[],"name":null,"options":{"cloud.google_assistant":{"should_expose":false},"conversation":{"should_expose":false}},"original_device_class":null,"original_icon":null,"original_name":"Donker thema","platform":"template","supported_features":0,"translation_key":null,"unique_id":"c81b18ff91b463722f311755b7c13f6d","previous_unique_id":null,"unit_of_measurement":null}
has device_class set to null, while the first try has:
{"aliases":[],"area_id":null,"categories":{},"capabilities":null,"config_entry_id":"6b66880d8b2992b11a731f176d96997a","device_class":"","device_id":null,"disabled_by":null,"entity_category":null,"entity_id":"binary_sensor.donker_thema","hidden_by":null,"icon":null,"id":"9ba19e6d01b96ae70c7fb6d89adc9b89","has_entity_name":false,"labels":[],"name":null,"options":{"cloud.google_assistant":{"should_expose":false},"conversation":{"should_expose":false}},"original_device_class":"running","original_icon":null,"original_name":"Donker thema","platform":"template","supported_features":0,"translation_key":null,"unique_id":"6b66880d8b2992b11a731f176d96997a","previous_unique_id":null,"unit_of_measurement":null}
device_class set to "".
Still can Not select None, or No class in the drop down
I don't think there's anything that can be done from the frontend.
No matter what is sent in the config/entity_registry/update
API for device_class, core will always revert back to the entity's original_device_class if we request a nullish value for device_class. That logic in the entity registry would need to be changed.
but... are you saying now that if we dont set a device_class (I did not do that), it would set it to active? Because that is what happened and really shouldnt.
And, as Ive found, the X does not do anything in this case, while it should really unset any choice previously set? If this needs to be taken to the Core, can you move that? I wont be able to describe what you just said above...
No I'm not saying that.
Entity registry has two fields: original_device_class
and device_class
.
original_device_class
is set by the integration. In the case of the template binary sensor, it is set by the choice made in the config flow when the entity was first created. This can't be changed after creation.
device_class
can be set by user picking a value in the show_as field. This can be changed at any time.
Even after changing device_class
, the original_device_class
always remains its original value. The device class attribute for an entity is defined as: if device_class
has a value, use that, else use original_device_class
.
This means when you clear the device_class/show_as field in the registry settings, the device class attribute reverts back to original_device_class
.
If clearing device_class field sets your entity to Active
device_class, than I believe that would have been the value selected at entity creation, and that must be the value of original_device_class
. You can check this in your entity registry entries that you posted. If you claim you didn't set that, I would ask you to try one more time to make sure, since if I do:
it reverts back to no device class as expected.
Checklist
Describe the issue you are experiencing
as title, creating a new Helper template binary
then check the config options in the more info reveals:
but we can not select the None as displayed on:
https://www.home-assistant.io/integrations/binary_sensor/#device-class
which is the only possible option to show those icons And the correct state
Describe the behavior you expected
be able to select None
I did try to click the X in that Show_as dropdown, and save. It returns to the Active device_class though
Steps to reproduce the issue
...
What version of Home Assistant Core has the issue?
2024.6.3
What was the last working version of Home Assistant Core?
No response
In which browser are you experiencing the issue with?
Any
Which operating system are you using to run this browser?
Mac OS
State of relevant entities
see screenshot
Problem-relevant frontend configuration
No response
Javascript errors shown in your browser console/inspector
No response
Additional information
Note the icon in the preview on the UI is correct below the template field, and how that differs from the one in the show as line
Note there also is an odd separator line, that probably shoulknt be there