Skip to content

Error adding entity None for domain sensor with platform minibrew #9

@Bjsulla

Description

@Bjsulla

I get the following error in the Home Assistant log file:

`Traceback (most recent call last): 
File 
"/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", 
line 684, in _async_add_entities 
await self._async_add_entity( 
 entity, False, entity_registry, config_subentry_id )

File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", 
line 805, in _async_add_entity 
  entity.add_to_platform_start( 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 
   self.hass, 
  ^^^^^^^^^^ 
  self, 
  ^^^^^ 
  self._get_parallel_updates_semaphore(hasattr(entity, "update")),    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ 

File "
/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 224, 
in add_to_platform_start 
  if self.unique_id is None or self.device_class is None: 
     ^^^^^^^^^^^^^^ 

File 
"/config/custom_components/minibrew/sensor.py", line 655, in unique_id 
  return f"{self.device_id.serial_number}_{self.name}" 
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
AttributeError: 'str' object has no attribute 'serial_number'`

Not a developer but when I asked AI I got the following suggested fix

In custom_components/minibrew/sensor.py

- return f"{self.device_id.serial_number}_{self.name}"
+ return f"{self.device_id}_{self.name}"

That at least seems to get rid of the error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions