Code Monkey home page Code Monkey logo

Comments (5)

Mariusthvdb avatar Mariusthvdb commented on August 16, 2024

made a second one:

Scherm­afbeelding 2024-06-21 om 12 01 57

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

from frontend.

karwosts avatar karwosts commented on August 16, 2024

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.

from frontend.

Mariusthvdb avatar Mariusthvdb commented on August 16, 2024

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...

from frontend.

karwosts avatar karwosts commented on August 16, 2024

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:

  • create a template binary_sensor
  • leave the device_class blank,
  • and then assign a show_as class,
  • and then clear the show_as class...

it reverts back to no device class as expected.

from frontend.

hmmbob avatar hmmbob commented on August 16, 2024

This is also happening to ping binary sensors. I'd very much would like to be able to override the device class also to none, instead of the default 'connectivity'.

Fun fact: an older ping sensor I have shows perfectly fine as "none" (reverting to default device classnone ), while a newer one cannot be set to none.

none is supposed to be a supported device class though:
image
https://www.home-assistant.io/integrations/binary_sensor/#device-class

The one ping sensor that has none as device class:
image
Shows as
image

And the one I cannot clear out (as empty is not accepted, and none is not in the list):
image
Shows as
image

from frontend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.