home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.67k stars 30.42k forks source link

Text-based battery sensors do not include device_class:battery? #81555

Closed igorsantos07 closed 1 year ago

igorsantos07 commented 1 year ago

this is a re-post of #79021 since it got closed for lack of interaction from maintainers and myself. I've set a reminder so I can come back every now and then to make sure this one doesn't get closed until addressed in one way or another.

The problem

Imprecise battery sensors (low/middle/high) from Tuya devices do not include the device_class: battery attribute, which makes it a tad harder for searches and filters. Both text and percentage-based battery levels show in a "Diagnostic" box in the device page, though, but the text-based battery won't show in the device list nor the top-right corner. I wonder if this is caused by the lack of that attribute?

image

Bonus: why do the percentage battery shows an ellipsis after the complete value? :thinking:

image image


I should also note there's a lack of pattern in the default entity ID naming: battery sensors from the HA mobile app are named «device»_battery_level, while the Tuya water sensor is just «device»_battery (in %) and these imprecise sensors use «device»_battery_state. I see battery_state is used to identify if a device is charging or not, so this is definitely confusing. Should I open a different issue to discuss these default entity IDs?

What version of Home Assistant Core has the issue?

2022.9.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Tuya

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tuya/

Diagnostics information

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @tuya, @zlinoliver, @frenck, mind taking a look at this issue as it has been labeled with an integration (tuya) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `tuya` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign tuya` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


tuya documentation tuya source (message by IssueLinks)

igorsantos07 commented 1 year ago

ping

igorsantos07 commented 1 year ago

👀

igorsantos07 commented 1 year ago

ping ping

frenck commented 1 year ago

Imprecise battery sensors (low/middle/high) from Tuya devices do not include the device_class: battery attribute, which makes it a tad harder for searches and filters.

That is correct, the device class requires the unit of measurement to be a percentage.

Both text and percentage-based battery levels show in a "Diagnostic" box in the device page

That is entirely possible, any entity can be marked diagnostic, that is not related to batter based sensors specifically.

I wonder if this is caused by the lack of that attribute?

Nope, it is by it not meeting the requirements for the battery device class, which is numeric.

I should also note there's a lack of pattern in the default entity ID naming: battery sensors from the HA mobile app are named «device»_battery_level, while the Tuya water sensor is just «device»_battery (in %) and these imprecise sensors use «device»_battery_state. I see battery_state is used to identify if a device is charging or not, so this is definitely confusing. Should I open a different issue to discuss these default entity IDs?

Entity IDs are not statically defined or guaranteed. You can rename them in the Home Assistant frontend if you'd like them to be different for your cases.

Closing this issue, as these are not bugs.

../Frenck

igorsantos07 commented 1 year ago

@frenck thanks for the response!

Given that many times, smaller devices are not able to give a precise number for battery state, wouldn't it make sense for low/mid/high to be accepted in that battery column? It doesn't seem to be a rare scenario. Or, otherwise, have HA "convert" those values into 33/66/100%, for instance. After all, HA is all about bridging gaps and unifying devices, right? That's one of the reasons I opened the issue in the first place.

The other reason is about the entity names: where do they come from? From manufacturers? Or from who implements the device inside the Tuya integration?

It shouldn't be up to the user to fix the inconsistencies in default entity names, nor adapt their simpler battery-powered devices to "make sense" in Home Assistant. Thus, it doesn't make much sense for me just getting this kind of answer as "non bugs". They might not be actual "bugs" but are definitely inconsistencies and things that can be improved in HA to improve the overall user experience.

frenck commented 1 year ago

After all, HA is all about bridging gaps and unifying devices, right?

Thus we need standardization. Unfortunately, Tuya won't provide such a thing.

They might not be actual "bugs" but are definitely inconsistencies and things that can be improved in HA to improve the overall user experience.

It is not a bug, nor inconsistent, standards are documented in both end-user and developer documentation.

That's one of the reasons I opened the issue in the first place.

That would not make it an bug, but a request, which is not what we use our issue tracker for. Hence I closed it.

If you have other questions or requests, please use our community forums or Discord chat.

Thanks! 👍

../Frenck