Add entity translations to Neato (#98067)

* Add entity translations to Neato

* Use robot name
This commit is contained in:
Joost Lekkerkerker 2023-08-08 22:05:12 +02:00 committed by GitHub
parent 66e3d69606
commit 524a26d9e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 25 deletions

View file

@ -44,11 +44,12 @@ async def async_setup_entry(
class NeatoSensor(SensorEntity):
"""Neato sensor."""
_attr_has_entity_name = True
def __init__(self, neato: NeatoHub, robot: Robot) -> None:
"""Initialize Neato sensor."""
self.robot = robot
self._available: bool = False
self._robot_name: str = f"{self.robot.name} {BATTERY}"
self._robot_serial: str = self.robot.serial
self._state: dict[str, Any] | None = None
@ -68,11 +69,6 @@ class NeatoSensor(SensorEntity):
self._available = True
_LOGGER.debug("self._state=%s", self._state)
@property
def name(self) -> str:
"""Return the name of this sensor."""
return self._robot_name
@property
def unique_id(self) -> str:
"""Return unique ID."""
@ -108,4 +104,7 @@ class NeatoSensor(SensorEntity):
@property
def device_info(self) -> DeviceInfo:
"""Device info for neato robot."""
return DeviceInfo(identifiers={(NEATO_DOMAIN, self._robot_serial)})
return DeviceInfo(
identifiers={(NEATO_DOMAIN, self._robot_serial)},
name=self.robot.name,
)