Use shorthand device info attribute for roomba (#103176)

pull/103191/head
Jan-Philipp Benecke 2023-11-01 16:27:51 +01:00 committed by GitHub
parent ae02e3f903
commit e48cb909f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 23 deletions

View File

@ -69,10 +69,23 @@ class IRobotEntity(Entity):
self.vacuum = roomba
self._blid = blid
self.vacuum_state = roomba_reported_state(roomba)
self._name = self.vacuum_state.get("name")
self._version = self.vacuum_state.get("softwareVer")
self._hw_version = self.vacuum_state.get("hardwareRev")
self._sku = self.vacuum_state.get("sku")
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self.robot_unique_id)},
serial_number=self.vacuum_state.get("hwPartsRev", {}).get("navSerialNo"),
manufacturer="iRobot",
model=self.vacuum_state.get("sku"),
name=str(self.vacuum_state.get("name")),
sw_version=self.vacuum_state.get("softwareVer"),
hw_version=self.vacuum_state.get("hardwareRev"),
)
if mac_address := self.vacuum_state.get("hwPartsRev", {}).get(
"wlan0HwAddr", self.vacuum_state.get("mac")
):
self._attr_device_info["connections"] = {
(dr.CONNECTION_NETWORK_MAC, mac_address)
}
@property
def robot_unique_id(self):
@ -84,25 +97,6 @@ class IRobotEntity(Entity):
"""Return the uniqueid of the vacuum cleaner."""
return self.robot_unique_id
@property
def device_info(self):
"""Return the device info of the vacuum cleaner."""
connections = None
if mac_address := self.vacuum_state.get("hwPartsRev", {}).get(
"wlan0HwAddr", self.vacuum_state.get("mac")
):
connections = {(dr.CONNECTION_NETWORK_MAC, mac_address)}
return DeviceInfo(
connections=connections,
identifiers={(DOMAIN, self.robot_unique_id)},
serial_number=self.vacuum_state.get("hwPartsRev", {}).get("navSerialNo"),
manufacturer="iRobot",
model=self._sku,
name=str(self._name),
sw_version=self._version,
hw_version=self._hw_version,
)
@property
def battery_level(self):
"""Return the battery level of the vacuum cleaner."""