Allow user to change entity category

it depends on the integration, if an sensor entity like battery will be assigned as a DIAGNOSTIC entity or a regular device Entity.

This can be difficult, if you want to show certain information - for example - battery as an alert state to the area-card - which does not work, if the battery sensor is classified as diagnostic entity.

This can either be addressed, by allowing also diagnostic entities to be used in the alert-states for area cards, but it would also work if the user could just change the classification of a sensor, similar as the user can do it for other information.

Therefore, a simple input field within the entity settings could be implemented where a selection can be made:


Entity Type should support “Diagnostic Sensor”, “Sensors”, “Configuration Sensor”

Why doesn’t this work? A diagnostics sensor is still a sensor: sensor_xyz_battery. And should be able to be selected a such.
I’m suspecting that the area-card may be the root of your problem?

Update: alert_classes can only be binary_sensors from what I read here: Area card - Home Assistant
You can make it work by creating an additional binary sensor based on the battery-sensor value being above of below a certain threshold.

ah … wait… sorry, it was not the alert_state class…
It was the sensor which you can select to be shown in the bottom of the area-card.

anyway… since it depends on the integration, it can be that battery-sensors are classified as diagnostic sensor - or as regular sensor… and I think, the ability to change the classification could be an improvement in terms of a consistent system-setup.

Again, sorry, I don’t agree. The classification of the sensor should not matter in my opinion (as a codeowner :slight_smile: ).

I still wonder what your exact problem is? Can you show the problem via a screenshot and explanatory text?

yes, just need to see, where it actually was… ^^
It’s not that important - I just came across over this when I was trying some small changes - and then forgot about this again…

I will also try to setup a simple installation within the next days, where I am sure, that no other devices / entities could come across…

If I was a betting man I’d wager that what was holding you back wasn’t the category the entity is listed under. So this request will likely not fix your problem. So best to first figure out what it was exactly.

So, I found my own github issue and the crosslink to a “duplicate”
this was it…

Anyway, not yet tried to reproduce this on one of my test-machines again.
Not sure, if I can setup this before weekend

What you would want is the integration to have a binary_sensor for the battery status:

class BinarySensorDeviceClass(StrEnum):
    """Device class for binary sensors."""

    # On means low, Off means normal
    BATTERY = "battery"

When this one is present, it should be shown as an alert I think.

Now that I realize this, I should add these to the Plugwise integration :slight_smile:

I’m pretty sure, that’s not all.

I will provide another update asap

Yes, agreed, the battery-binary_sensor cannot be in an entity_category as shown in Area Card: Diagnostic binary sensor for battery are not shown · Issue #19951 · home-assistant/frontend · GitHub

That should be fixed by the integration-owner. Which you already did, for Midea :slight_smile:

so, as mentioned - the area card does NOT show battery binary-sensors as alert-icon if they are in the DIAGNOSTIC section.

The area card does also not show any Battery Information when the sensor is set as DIAGNOSTIC

Tested with an ESP device, battery Information is configured as diagnostic:
image

Battery Information moved from Diagnostic to SENSORS


this is exactly the point of the FR:

  • Either, the Area Card CAN include the Diagnostic Sensors - If I want to add them to the Card;
  • OR the user should have an option to set, if a specific sensor should be a Diagnostic Sensor or not.

I would prefer the first option - but could also live with the other one, rather than submitting PR’s / issues to each component or integration, while someone decided how this should behave and where it should belong.

If the Area Card would be able to show the Diagnostic Sensors, I can still hide them…

and here’s the same with a binary_sensor for the battery added as diagnostic:

image

What I’ve learned and come to accept, these kind of decisions are taken by the HA Core Devs with a certain reasoning in mind :slight_smile:

You can try to overturn such decisions but you might not be successful. You can try both methods but in the end there will be a HA Dev reviewing and not approving the PR('s).

Have you looked for an alternative card on HACS? Integrations and cards etc. available on HACS are not “regulated” by the HA Devs.

It seems to me that alerts are likely to be found in a diagnostics area. So the card deciding those are not allowed seems foolish. Besides that, if there is no obvious reason it should not be allowed, why go through the trouble of taking the choice away from the user.

However, assigning Diagnostics entities to the Sensor category to work around that feels like a very ugly workaround to me.

so, but with this test case, the Feature-Request itself would be valid :wink:

I know such discussions from my daily job - and what I’ve learned over the years - just because someone has made a decision at some point, it does not mean that the decision was made with all certain cases in mind - or the facts might have changed in the time being.

The purpose of the feature request is, trying to convience, why something needs / should be changed.

In case of showing the Battery state (percentage) - I can agree, that it doesn’t make sense to show this information if the battery sensor is set up as a diagnostic sensor.
Unfortunately, sometimes, such sensors are set as Diagnostic ones in different components - and it would be much easier, if I would have the option to change that within the UI of the Sensor (customize).

Not reading Diagnostic “Binary” information - such as Battery State “Low” - should still be possible for the area card, since the purpose of it is to alert about “diagnostic” and “important” information.

I don’t expect that these information will be shown all the time - and everywhere - except, the Alert State is designed in the way it is done currently (state needs to be ON → always showing “connected=true” instead of “disconnected”)…

so, there are several decisions, that should be reviewed in my opinion…
And switching to a custom card for this, isn’t the approach I would prefer.

This should be a platform topic :slight_smile:

probably - yes.
But:

Such an option would allow the following:

I could move a sensor / entity between the different categories, if I consider them as Diagnostic, Configuration or anything else - and don’t need to raise an issue for each component, where this might be wrong in my opinion