From c7d38b85478ed0b01aa13889923b001a7334b7f8 Mon Sep 17 00:00:00 2001 From: Brett Rowan <121075405+b-rowan@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:27:51 -0600 Subject: [PATCH] Add IP to connection info. --- custom_components/miner/coordinator.py | 4 ++-- custom_components/miner/number.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/custom_components/miner/coordinator.py b/custom_components/miner/coordinator.py index 34640e0..e3e418e 100644 --- a/custom_components/miner/coordinator.py +++ b/custom_components/miner/coordinator.py @@ -114,8 +114,8 @@ async def _async_update_data(self): "is_mining": miner_data.is_mining, "fw_ver": miner_data.fw_ver, "miner_sensors": { - "hashrate": round(float(miner_data.hashrate or 0), 2), - "ideal_hashrate": round(float(miner_data.expected_hashrate or 0), 2), + "hashrate": hashrate, + "ideal_hashrate": expected_hashrate, "temperature": miner_data.temperature_avg, "power_limit": miner_data.wattage_limit, "miner_consumption": miner_data.wattage, diff --git a/custom_components/miner/number.py b/custom_components/miner/number.py index e5222cb..e19e061 100644 --- a/custom_components/miner/number.py +++ b/custom_components/miner/number.py @@ -8,7 +8,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import callback from homeassistant.core import HomeAssistant -from homeassistant.helpers import entity +from homeassistant.helpers import entity, device_registry from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -55,10 +55,13 @@ def device_info(self) -> entity.DeviceInfo: """Return device info.""" return entity.DeviceInfo( identifiers={(DOMAIN, self.coordinator.data["mac"])}, + connections={("ip", self.coordinator.data["ip"]), (device_registry.CONNECTION_NETWORK_MAC, self.coordinator.data["mac"])}, + configuration_url=f"http://{self.coordinator.data['ip']}", manufacturer=self.coordinator.data["make"], model=self.coordinator.data["model"], sw_version=self.coordinator.data["fw_ver"], name=f"{self.coordinator.entry.title}", + ) @property