Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity sensor XXX cannot be added as the entity category is set to config #103192

Closed
garry0garry opened this issue Nov 1, 2023 · 9 comments · Fixed by #103210
Closed

Entity sensor XXX cannot be added as the entity category is set to config #103192

garry0garry opened this issue Nov 1, 2023 · 9 comments · Fixed by #103210

Comments

@garry0garry
Copy link

The problem

Smart plug (with power monitoring) (TS011F_plug_1) by TuYa

After updating 2023.10.5 to 2023.11.0, “sensor” magically turned into “select”, but both remained in HA. What to do about it now?
изображение

What version of Home Assistant Core has the issue?

2023.11.0

What was the last working version of Home Assistant Core?

2023.10.5

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Sensor

Link to integration documentation on our website

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

Diagnostics information

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:507
Integration: Sensor (documentation, issues)
First occurred: 9:32:07 PM (8 occurrences)
Last logged: 9:32:07 PM

Error adding entities for domain sensor with platform mqtt
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1021, in add_to_platform_finish
    await self.async_internal_added_to_hass()
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 279, in async_internal_added_to_hass
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity sensor.0xa4c138c20463410f_power_outage_memory cannot be added as the entity category is set to config

Logger: homeassistant
Source: components/sensor/__init__.py:279
First occurred: 9:32:07 PM (8 occurrences)
Last logged: 9:32:07 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1021, in add_to_platform_finish
    await self.async_internal_added_to_hass()
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 279, in async_internal_added_to_hass
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity sensor.0xa4c138c20463410f_power_outage_memory cannot be added as the entity category is set to config

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

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

@home-assistant
Copy link

home-assistant bot commented Nov 1, 2023

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (sensor) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of sensor can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign sensor Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


sensor documentation
sensor source
(message by IssueLinks)

@home-assistant
Copy link

home-assistant bot commented Nov 1, 2023

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

Code owner commands

Code owners of mqtt can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign mqtt Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


mqtt documentation
mqtt source
(message by IssueLinks)

@garry0garry
Copy link
Author

Similar problem with Aqara presence detector FP1 (RTCZCGQ11LM) by Xiaomi
изображение

@jbouwh
Copy link
Contributor

jbouwh commented Nov 1, 2023

config in an invalid entity category for sensor, as a sensor can not be configured. See documentation. https://developers.home-assistant.io/docs/core/entity/

Changes to enforce validation were added to the sensor base class.

Solution is setting the entity category to diagnostic or leaving the config setting away.

@jbouwh
Copy link
Contributor

jbouwh commented Nov 1, 2023

home-assistant/home-assistant.io#29651

May be this change (#101471) should have been a breaking change.

@garry0garry
Copy link
Author

Thanks, I removed the sensors manually.

@jbouwh
Copy link
Contributor

jbouwh commented Nov 1, 2023

I will open a PR to ensure the error handling is correct. That PR will close this issue when it is merged.

@kamaradclimber
Copy link

With the correct warning (in 2023.11), the behavior is effectively breaking some integrations (some custom integrations at least, see kamaradclimber/heishamon-homeassistant#163).

I think it would have deserved a breaking change mention because setting an entity as config was a legitimate understanding of the documentation (I understand doc has been updated to be clearer 👍 )

@jbouwh
Copy link
Contributor

jbouwh commented Nov 28, 2023

Am sorry this was not added to the patch release. But a fix will be added to HA Core 2023.12

@github-actions github-actions bot locked and limited conversation to collaborators Dec 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants