1 """Support for monitoring an SABnzbd NZB client."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
10 SensorEntityDescription,
18 from .
import SabnzbdConfigEntry
19 from .entity
import SabnzbdEntity
22 @dataclass(frozen=True, kw_only=True)
24 """Describes Sabnzbd sensor entity."""
29 SENSOR_TYPES: tuple[SabnzbdSensorEntityDescription, ...] = (
32 translation_key=
"status",
36 translation_key=
"speed",
37 device_class=SensorDeviceClass.DATA_RATE,
38 native_unit_of_measurement=UnitOfDataRate.KILOBYTES_PER_SECOND,
39 suggested_unit_of_measurement=UnitOfDataRate.MEGABYTES_PER_SECOND,
40 suggested_display_precision=1,
41 state_class=SensorStateClass.MEASUREMENT,
45 translation_key=
"queue",
46 native_unit_of_measurement=UnitOfInformation.MEGABYTES,
47 device_class=SensorDeviceClass.DATA_SIZE,
48 state_class=SensorStateClass.MEASUREMENT,
52 translation_key=
"left",
53 native_unit_of_measurement=UnitOfInformation.MEGABYTES,
54 device_class=SensorDeviceClass.DATA_SIZE,
55 state_class=SensorStateClass.MEASUREMENT,
58 key=
"diskspacetotal1",
59 translation_key=
"total_disk_space",
60 native_unit_of_measurement=UnitOfInformation.GIGABYTES,
61 device_class=SensorDeviceClass.DATA_SIZE,
62 state_class=SensorStateClass.MEASUREMENT,
66 translation_key=
"free_disk_space",
67 native_unit_of_measurement=UnitOfInformation.GIGABYTES,
68 device_class=SensorDeviceClass.DATA_SIZE,
69 state_class=SensorStateClass.MEASUREMENT,
72 key=
"noofslots_total",
73 translation_key=
"queue_count",
74 state_class=SensorStateClass.TOTAL,
75 suggested_display_precision=2,
79 translation_key=
"daily_total",
80 native_unit_of_measurement=UnitOfInformation.GIGABYTES,
81 device_class=SensorDeviceClass.DATA_SIZE,
82 entity_registry_enabled_default=
False,
83 state_class=SensorStateClass.TOTAL_INCREASING,
84 suggested_display_precision=2,
88 translation_key=
"weekly_total",
89 native_unit_of_measurement=UnitOfInformation.GIGABYTES,
90 device_class=SensorDeviceClass.DATA_SIZE,
91 entity_registry_enabled_default=
False,
92 state_class=SensorStateClass.TOTAL_INCREASING,
93 suggested_display_precision=2,
97 translation_key=
"monthly_total",
98 native_unit_of_measurement=UnitOfInformation.GIGABYTES,
99 device_class=SensorDeviceClass.DATA_SIZE,
100 entity_registry_enabled_default=
False,
101 state_class=SensorStateClass.TOTAL_INCREASING,
102 suggested_display_precision=2,
106 translation_key=
"overall_total",
107 native_unit_of_measurement=UnitOfInformation.GIGABYTES,
108 device_class=SensorDeviceClass.DATA_SIZE,
109 state_class=SensorStateClass.TOTAL_INCREASING,
110 suggested_display_precision=2,
117 config_entry: SabnzbdConfigEntry,
118 async_add_entities: AddEntitiesCallback,
120 """Set up a Sabnzbd sensor entry."""
121 coordinator = config_entry.runtime_data
127 """Representation of an SABnzbd sensor."""
129 entity_description: SabnzbdSensorEntityDescription
133 """Return latest sensor data."""
StateType native_value(self)
None async_setup_entry(HomeAssistant hass, SabnzbdConfigEntry config_entry, AddEntitiesCallback async_add_entities)