Skip to content

Commit e040eb0

Browse files
authored
Remove extra state attributes from some QNAP sensors (#130310)
1 parent d7f41ff commit e040eb0

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

homeassistant/components/qnap/sensor.py

-61
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
SensorStateClass,
1414
)
1515
from homeassistant.const import (
16-
ATTR_NAME,
1716
PERCENTAGE,
1817
EntityCategory,
1918
UnitOfDataRate,
@@ -375,17 +374,6 @@ def native_value(self):
375374

376375
return None
377376

378-
# Deprecated since Home Assistant 2024.6.0
379-
# Can be removed completely in 2024.12.0
380-
@property
381-
def extra_state_attributes(self) -> dict[str, Any] | None:
382-
"""Return the state attributes."""
383-
if self.coordinator.data:
384-
data = self.coordinator.data["system_stats"]["memory"]
385-
size = round(float(data["total"]) / 1024, 2)
386-
return {ATTR_MEMORY_SIZE: f"{size} {UnitOfInformation.GIBIBYTES}"}
387-
return None
388-
389377

390378
class QNAPNetworkSensor(QNAPSensor):
391379
"""A QNAP sensor that monitors network stats."""
@@ -414,22 +402,6 @@ def native_value(self):
414402

415403
return None
416404

417-
# Deprecated since Home Assistant 2024.6.0
418-
# Can be removed completely in 2024.12.0
419-
@property
420-
def extra_state_attributes(self) -> dict[str, Any] | None:
421-
"""Return the state attributes."""
422-
if self.coordinator.data:
423-
data = self.coordinator.data["system_stats"]["nics"][self.monitor_device]
424-
return {
425-
ATTR_IP: data["ip"],
426-
ATTR_MASK: data["mask"],
427-
ATTR_MAC: data["mac"],
428-
ATTR_MAX_SPEED: data["max_speed"],
429-
ATTR_PACKETS_ERR: data["err_packets"],
430-
}
431-
return None
432-
433405

434406
class QNAPSystemSensor(QNAPSensor):
435407
"""A QNAP sensor that monitors overall system health."""
@@ -455,25 +427,6 @@ def native_value(self):
455427

456428
return None
457429

458-
# Deprecated since Home Assistant 2024.6.0
459-
# Can be removed completely in 2024.12.0
460-
@property
461-
def extra_state_attributes(self) -> dict[str, Any] | None:
462-
"""Return the state attributes."""
463-
if self.coordinator.data:
464-
data = self.coordinator.data["system_stats"]
465-
days = int(data["uptime"]["days"])
466-
hours = int(data["uptime"]["hours"])
467-
minutes = int(data["uptime"]["minutes"])
468-
469-
return {
470-
ATTR_NAME: data["system"]["name"],
471-
ATTR_MODEL: data["system"]["model"],
472-
ATTR_SERIAL: data["system"]["serial_number"],
473-
ATTR_UPTIME: f"{days:0>2d}d {hours:0>2d}h {minutes:0>2d}m",
474-
}
475-
return None
476-
477430

478431
class QNAPDriveSensor(QNAPSensor):
479432
"""A QNAP sensor that monitors HDD/SSD drive stats."""
@@ -533,17 +486,3 @@ def native_value(self):
533486
return used_gb / total_gb * 100
534487

535488
return None
536-
537-
# Deprecated since Home Assistant 2024.6.0
538-
# Can be removed completely in 2024.12.0
539-
@property
540-
def extra_state_attributes(self) -> dict[str, Any] | None:
541-
"""Return the state attributes."""
542-
if self.coordinator.data:
543-
data = self.coordinator.data["volumes"][self.monitor_device]
544-
total_gb = int(data["total_size"]) / 1024 / 1024 / 1024
545-
546-
return {
547-
ATTR_VOLUME_SIZE: f"{round(total_gb, 1)} {UnitOfInformation.GIBIBYTES}"
548-
}
549-
return None

0 commit comments

Comments
 (0)