Add entity translations to Neato (#98067)
* Add entity translations to Neato * Use robot namepull/87856/head
parent
66e3d69606
commit
524a26d9e1
|
@ -25,6 +25,8 @@ async def async_setup_entry(
|
|||
class NeatoDismissAlertButton(ButtonEntity):
|
||||
"""Representation of a dismiss_alert button entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_translation_key = "dismiss_alert"
|
||||
_attr_entity_category = EntityCategory.CONFIG
|
||||
|
||||
def __init__(
|
||||
|
@ -33,9 +35,11 @@ class NeatoDismissAlertButton(ButtonEntity):
|
|||
) -> None:
|
||||
"""Initialize a dismiss_alert Neato button entity."""
|
||||
self.robot = robot
|
||||
self._attr_name = f"{robot.name} Dismiss Alert"
|
||||
self._attr_unique_id = f"{robot.serial}_dismiss_alert"
|
||||
self._attr_device_info = DeviceInfo(identifiers={(NEATO_DOMAIN, robot.serial)})
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(NEATO_DOMAIN, robot.serial)},
|
||||
name=robot.name,
|
||||
)
|
||||
|
||||
async def async_press(self) -> None:
|
||||
"""Press the button."""
|
||||
|
|
|
@ -51,6 +51,9 @@ async def async_setup_entry(
|
|||
class NeatoCleaningMap(Camera):
|
||||
"""Neato cleaning map for last clean."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_translation_key = "cleaning_map"
|
||||
|
||||
def __init__(
|
||||
self, neato: NeatoHub, robot: Robot, mapdata: dict[str, Any] | None
|
||||
) -> None:
|
||||
|
@ -60,7 +63,6 @@ class NeatoCleaningMap(Camera):
|
|||
self.neato = neato
|
||||
self._mapdata = mapdata
|
||||
self._available = neato is not None
|
||||
self._robot_name = f"{self.robot.name} Cleaning Map"
|
||||
self._robot_serial: str = self.robot.serial
|
||||
self._generated_at: str | None = None
|
||||
self._image_url: str | None = None
|
||||
|
@ -114,11 +116,6 @@ class NeatoCleaningMap(Camera):
|
|||
self._generated_at = map_data.get("generated_at")
|
||||
self._available = True
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of this camera."""
|
||||
return self._robot_name
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return unique ID."""
|
||||
|
@ -132,7 +129,10 @@ class NeatoCleaningMap(Camera):
|
|||
@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,
|
||||
)
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any]:
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -19,6 +19,23 @@
|
|||
"default": "[%key:common::config_flow::create_entry::authenticated%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"button": {
|
||||
"dismiss_alert": {
|
||||
"name": "Dismiss alert"
|
||||
}
|
||||
},
|
||||
"camera": {
|
||||
"cleaning_map": {
|
||||
"name": "Cleaning map"
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
"schedule": {
|
||||
"name": "Schedule"
|
||||
}
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
"custom_cleaning": {
|
||||
"name": "Zone cleaning service",
|
||||
|
|
|
@ -48,12 +48,14 @@ async def async_setup_entry(
|
|||
class NeatoConnectedSwitch(SwitchEntity):
|
||||
"""Neato Connected Switches."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
_attr_translation_key = "schedule"
|
||||
|
||||
def __init__(self, neato: NeatoHub, robot: Robot, switch_type: str) -> None:
|
||||
"""Initialize the Neato Connected switches."""
|
||||
self.type = switch_type
|
||||
self.robot = robot
|
||||
self._available = False
|
||||
self._robot_name = f"{self.robot.name} {SWITCH_TYPES[self.type][0]}"
|
||||
self._state: dict[str, Any] | None = None
|
||||
self._schedule_state: str | None = None
|
||||
self._clean_state = None
|
||||
|
@ -85,11 +87,6 @@ class NeatoConnectedSwitch(SwitchEntity):
|
|||
"Schedule state for '%s': %s", self.entity_id, self._schedule_state
|
||||
)
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""Return the name of the switch."""
|
||||
return self._robot_name
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available."""
|
||||
|
@ -115,7 +112,10 @@ class NeatoConnectedSwitch(SwitchEntity):
|
|||
@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,
|
||||
)
|
||||
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch on."""
|
||||
|
|
|
@ -106,6 +106,8 @@ class NeatoConnectedVacuum(StateVacuumEntity):
|
|||
| VacuumEntityFeature.MAP
|
||||
| VacuumEntityFeature.LOCATE
|
||||
)
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -118,7 +120,6 @@ class NeatoConnectedVacuum(StateVacuumEntity):
|
|||
self.robot = robot
|
||||
self._attr_available: bool = neato is not None
|
||||
self._mapdata = mapdata
|
||||
self._attr_name: str = self.robot.name
|
||||
self._robot_has_map: bool = self.robot.has_persistent_maps
|
||||
self._robot_maps = persistent_maps
|
||||
self._robot_serial: str = self.robot.serial
|
||||
|
@ -304,7 +305,7 @@ class NeatoConnectedVacuum(StateVacuumEntity):
|
|||
identifiers={(NEATO_DOMAIN, self._robot_serial)},
|
||||
manufacturer=stats["battery"]["vendor"] if stats else None,
|
||||
model=stats["model"] if stats else None,
|
||||
name=self._attr_name,
|
||||
name=self.robot.name,
|
||||
sw_version=stats["firmware"] if stats else None,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue