diff --git a/custom_components/deebot/entity.py b/custom_components/deebot/entity.py index d134f27..1f802e5 100644 --- a/custom_components/deebot/entity.py +++ b/custom_components/deebot/entity.py @@ -7,6 +7,7 @@ from deebot_client.device import Device from deebot_client.events import AvailabilityEvent from deebot_client.events.base import Event +from homeassistant.helpers import device_registry as dr from homeassistant.helpers.entity import DeviceInfo, Entity, EntityDescription from .const import DOMAIN @@ -61,8 +62,7 @@ def __init__( self._device = device self._capability = capability - device_info = self._device.device_info - self._attr_unique_id = device_info.did + self._attr_unique_id = self._device.device_info.did if self.entity_description.key: self._attr_unique_id += f"_{self.entity_description.key}" @@ -83,6 +83,9 @@ def device_info(self) -> DeviceInfo | None: if model := device.api_device_info.get("deviceName"): info["model"] = model + if mac := self._device.mac: + info["connections"] = {(dr.CONNECTION_NETWORK_MAC, mac)} + return info async def async_added_to_hass(self) -> None: diff --git a/custom_components/deebot/sensor.py b/custom_components/deebot/sensor.py index 4716c1d..cbcbef9 100644 --- a/custom_components/deebot/sensor.py +++ b/custom_components/deebot/sensor.py @@ -13,6 +13,7 @@ Event, LifeSpan, LifeSpanEvent, + NetworkInfoEvent, StatsEvent, TotalStatsEvent, ) @@ -170,6 +171,33 @@ def _clean_log_event_attributes(event: CleanLogEvent) -> MutableMapping[str, Any icon="mdi:history", entity_registry_enabled_default=False, ), + DeebotSensorEntityDescription[NetworkInfoEvent]( + capability_fn=lambda caps: caps.network, + value_fn=lambda e: e.ip, + key="wifi_ip", + translation_key="wifi_ip", + icon="mdi:ip-network-outline", + entity_registry_enabled_default=False, + entity_category=EntityCategory.DIAGNOSTIC, + ), + DeebotSensorEntityDescription[NetworkInfoEvent]( + capability_fn=lambda caps: caps.network, + value_fn=lambda e: e.rssi, + key="wifi_rssi", + translation_key="wifi_rssi", + icon="mdi:signal-variant", + entity_registry_enabled_default=False, + entity_category=EntityCategory.DIAGNOSTIC, + ), + DeebotSensorEntityDescription[NetworkInfoEvent]( + capability_fn=lambda caps: caps.network, + value_fn=lambda e: e.ssid, + key="wifi_ssid", + translation_key="wifi_ssid", + icon="mdi:wifi", + entity_registry_enabled_default=False, + entity_category=EntityCategory.DIAGNOSTIC, + ), ) diff --git a/custom_components/deebot/translations/en.json b/custom_components/deebot/translations/en.json index 9e826e6..cae26e9 100644 --- a/custom_components/deebot/translations/en.json +++ b/custom_components/deebot/translations/en.json @@ -128,6 +128,15 @@ }, "stats_type": { "name": "Stats type" + }, + "wifi_ip": { + "name": "Ip" + }, + "wifi_rssi": { + "name": "Wifi rssi" + }, + "wifi_ssid": { + "name": "Wifi ssid" } }, "switch": { diff --git a/translations.schema.json b/translations.schema.json index 8d33782..6da69c1 100644 --- a/translations.schema.json +++ b/translations.schema.json @@ -282,6 +282,15 @@ }, "stats_type": { "$ref": "#/definitions/translation_name" + }, + "wifi_ip": { + "$ref": "#/definitions/translation_name" + }, + "wifi_rssi": { + "$ref": "#/definitions/translation_name" + }, + "wifi_ssid": { + "$ref": "#/definitions/translation_name" } }, "type": "object"