-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
Use entity descriptions in Roomba #102323
Conversation
Hey there @pschmitt, @cyr-ius, @shenxn, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
# Conflicts: # homeassistant/components/roomba/irobot_base.py # homeassistant/components/roomba/sensor.py
Co-authored-by: J. Nick Koston <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, looks like there is an issue I didn't see in review
2023-10-19 06:34:05.245 ERROR (MainThread) [homeassistant.components.sensor] Platform roomba does not generate unique IDs. ID roomba_6BCDC6ED83A24782B24D53F0E2F1A1F1 already exists - ignoring sensor.89_upstairroomba_battery
2023-10-19 06:34:05.245 ERROR (MainThread) [homeassistant.components.sensor] Platform roomba does not generate unique IDs. ID roomba_6BCDC6ED83A24782B24D53F0E2F1A1F1 already exists - ignoring sensor.89_upstairroomba_battery
2023-10-19 06:34:05.245 ERROR (MainThread) [homeassistant.components.sensor] Platform roomba does not generate unique IDs. ID roomba_6BCDC6ED83A24782B24D53F0E2F1A1F1 already exists - ignoring sensor.89_upstairroomba_battery
2023-10-19 06:34:05.246 ERROR (MainThread) [homeassistant.components.sensor] Platform roomba does not generate unique IDs. ID roomba_6BCDC6ED83A24782B24D53F0E2F1A1F1 already exists - ignoring sensor.89_upstairroomba_battery
2023-10-19 06:34:05.246 ERROR (MainThread) [homeassistant.components.sensor] Platform roomba does not generate unique IDs. ID roomba_6BCDC6ED83A24782B24D53F0E2F1A1F1 already exists - ignoring sensor.89_upstairroomba_battery
2023-10-19 06:34:05.246 ERROR (MainThread) [homeassistant.components.sensor] Platform roomba does not generate unique IDs. ID roomba_6BCDC6ED83A24782B24D53F0E2F1A1F1 already exists - ignoring sensor.89_upstairroomba_battery
2023-10-19 06:34:05.246 ERROR (MainThread) [homeassistant.components.sensor] Platform roomba does not generate unique IDs. ID roomba_6BCDC6ED83A24782B24D53F0E2F1A1F1 already exists - ignoring sensor.89_upstairroomba_battery
2023-10-19 06:34:05.246 ERROR (MainThread) [homeassistant.components.sensor] Platform roomba does not generate unique IDs. ID roomba_6BCDC6ED83A24782B24D53F0E2F1A1F1 already exists - ignoring sensor.89_upstairroomba_battery
2023-10-19 06:34:05.294 ERROR (MainThread) [homeassistant.components.vacuum] Error adding entities for domain vacuum with platform roomba
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 1023, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 743, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 843, in _async_write_ha_state
state, attr = self._async_generate_attributes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 786, in _async_generate_attributes
attr.update(self.state_attributes or {})
^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/vacuum/__init__.py", line 281, in state_attributes
data[ATTR_BATTERY_LEVEL] = self.battery_level
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/roomba/irobot_base.py", line 167, in battery_level
return self._battery_level
^^^^^^^^^^^^^^^^^^^
AttributeError: 'RoombaVacuumCarpetBoost' object has no attribute '_battery_level'
2023-10-19 06:34:05.299 ERROR (MainThread) [homeassistant.components.vacuum] Error while setting up roomba platform for vacuum
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 367, in _async_setup_platform
await asyncio.gather(*pending)
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 1023, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 743, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 843, in _async_write_ha_state
state, attr = self._async_generate_attributes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 786, in _async_generate_attributes
attr.update(self.state_attributes or {})
^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/vacuum/__init__.py", line 281, in state_attributes
data[ATTR_BATTERY_LEVEL] = self.battery_level
^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/roomba/irobot_base.py", line 167, in battery_level
return self._battery_level
^^^^^^^^^^^^^^^^^^^
AttributeError: 'RoombaVacuumCarpetBoost' object has no attribute '_battery_level'
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Oh
The property is overwritten in the base class |
and it looks like |
oh right, I made it public |
Heh, I tested that other PR. That seamed to work. This one suddenly doesn't work. |
ooooh, I know whats going on |
Tested locally, works |
Latest push looks good Running to grab breakfast and errands and will test when I get back |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to generate translations. If this is your production env
|
I must say, I also had that problem with the battery, but I couldn't figure out why. I reinstalled the integration like twice and it did not show up twice anymore, so its strange |
Let me try deleting it and re-adding it to see if I can replicate the battery issue |
Thanks, I didn't know that. Now the translations are working properly. |
Here is what the battery looks like in the registry on
|
Its the same with this PR. I can't replicate the issue on a test env or on production. I will update my other production instance now |
Yea I checked my registry and got 2 entities with the same unique id. So it was kinda strange |
I'm going to clean up the typing a bit in #102350 |
I saw the PR, nice one |
@Xitee1 If you plan on working on this integration long term, you should add yourself to codeowners https://github.com/home-assistant/architecture/blob/master/adr/0008-code-owners.md as we generally prioritize review for codeowners higher |
Okay, I'll most likely do that. |
state_class=SensorStateClass.MEASUREMENT, | ||
icon="mdi:counter", | ||
entity_category=EntityCategory.DIAGNOSTIC, | ||
value_fn=lambda self: self.battery_stats.get("nLithChrg") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use parenthesis to add indentation so that the lambda is easier to read?
Proposed change
Use entity descriptions in Roomba.
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: