mirror of
https://github.com/home-assistant/core.git
synced 2025-08-07 14:45:09 +02:00
Add Model and Software version
This commit is contained in:
@@ -14,6 +14,7 @@ from homeassistant.components.vacuum import (
|
|||||||
SUPPORT_TURN_ON,
|
SUPPORT_TURN_ON,
|
||||||
VacuumDevice,
|
VacuumDevice,
|
||||||
)
|
)
|
||||||
|
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
@@ -55,41 +56,49 @@ SUPPORT_ROOMBA_CARPET_BOOST = SUPPORT_ROOMBA | SUPPORT_FAN_SPEED
|
|||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up the iRobot Roomba vacuum cleaner."""
|
"""Set up the iRobot Roomba vacuum cleaner."""
|
||||||
|
|
||||||
name = hass.data[DOMAIN]["name"]
|
|
||||||
roomba = hass.data[DOMAIN]["roomba"]
|
roomba = hass.data[DOMAIN]["roomba"]
|
||||||
roomba_vac = RoombaVacuum(name, roomba)
|
roomba_vac = RoombaVacuum(roomba)
|
||||||
async_add_entities([roomba_vac], True)
|
async_add_entities([roomba_vac], True)
|
||||||
|
|
||||||
|
|
||||||
class RoombaVacuum(VacuumDevice):
|
class RoombaVacuum(VacuumDevice):
|
||||||
"""Representation of a Roomba Vacuum cleaner robot."""
|
"""Representation of a Roomba Vacuum cleaner robot."""
|
||||||
|
|
||||||
def __init__(self, name, roomba):
|
def __init__(self, roomba):
|
||||||
"""Initialize the Roomba handler."""
|
"""Initialize the Roomba handler."""
|
||||||
self._available = False
|
self._available = False
|
||||||
self._battery_level = None
|
self._battery_level = None
|
||||||
self._capabilities = {}
|
self._capabilities = {}
|
||||||
self._fan_speed = None
|
self._fan_speed = None
|
||||||
self._is_on = False
|
self._is_on = False
|
||||||
self._name = name
|
|
||||||
self._state_attrs = {}
|
self._state_attrs = {}
|
||||||
self._status = None
|
self._status = None
|
||||||
self.vacuum = roomba
|
self.vacuum = roomba
|
||||||
self.vacuum_state = None
|
self.vacuum_state = self.vacuum.master_state.get("state", {}).get(
|
||||||
|
"reported", {}
|
||||||
|
)
|
||||||
|
self._mac = self.vacuum_state.get("mac")
|
||||||
|
self._name = self.vacuum_state.get("name")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return the uniqueid of the vacuum cleaner."""
|
"""Return the uniqueid of the vacuum cleaner."""
|
||||||
return self._name
|
return "roomba_{}".format(self._mac)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self):
|
def device_info(self):
|
||||||
"""Return the device info of the vacuum cleaner."""
|
"""Return the device info of the vacuum cleaner."""
|
||||||
return {
|
return {
|
||||||
"identifiers": {(DOMAIN, self.unique_id)},
|
"identifiers": {(DOMAIN, self.unique_id)},
|
||||||
|
"connections": {(CONNECTION_NETWORK_MAC, self._mac)},
|
||||||
"manufacturer": "iRobots",
|
"manufacturer": "iRobots",
|
||||||
"name": str(self._name),
|
"name": str(self._name),
|
||||||
|
"sw_version": self.vacuum.master_state.get("state", {})
|
||||||
|
.get("reported", {})
|
||||||
|
.get("softwareVer"),
|
||||||
|
"model": self.vacuum.master_state.get("state", {})
|
||||||
|
.get("reported", {})
|
||||||
|
.get("sku"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Reference in New Issue
Block a user