Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
Add network information
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhaus committed Oct 27, 2023
1 parent c1c133e commit 4a53a0a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/deebot/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand All @@ -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:
Expand Down
28 changes: 28 additions & 0 deletions custom_components/deebot/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Event,
LifeSpan,
LifeSpanEvent,
NetworkInfoEvent,
StatsEvent,
TotalStatsEvent,
)
Expand Down Expand Up @@ -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,
),
)


Expand Down
9 changes: 9 additions & 0 deletions custom_components/deebot/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@
},
"stats_type": {
"name": "Stats type"
},
"wifi_ip": {
"name": "Ip"
},
"wifi_rssi": {
"name": "Wifi rssi"
},
"wifi_ssid": {
"name": "Wifi ssid"
}
},
"switch": {
Expand Down
9 changes: 9 additions & 0 deletions translations.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 4a53a0a

Please sign in to comment.