1 """Support for Netgear LTE sensors."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
8 from eternalegypt.eternalegypt
import Information
13 SensorEntityDescription,
17 SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
25 from .
import NetgearLTEConfigEntry
26 from .entity
import LTEEntity
29 @dataclass(frozen=True, kw_only=True)
31 """Class describing Netgear LTE entities."""
33 value_fn: Callable[[Information], StateType] |
None =
None
36 SENSORS: tuple[NetgearLTESensorEntityDescription, ...] = (
39 translation_key=
"sms",
40 native_unit_of_measurement=
"unread",
41 value_fn=
lambda data: sum(1
for x
in data.sms
if x.unread),
45 translation_key=
"sms_total",
46 native_unit_of_measurement=
"messages",
47 value_fn=
lambda data: len(data.sms),
51 translation_key=
"usage",
52 device_class=SensorDeviceClass.DATA_SIZE,
53 entity_registry_enabled_default=
False,
54 native_unit_of_measurement=UnitOfInformation.BYTES,
55 suggested_unit_of_measurement=UnitOfInformation.MEBIBYTES,
56 suggested_display_precision=1,
57 value_fn=
lambda data: data.usage,
61 translation_key=
"radio_quality",
62 entity_registry_enabled_default=
False,
63 entity_category=EntityCategory.DIAGNOSTIC,
64 native_unit_of_measurement=PERCENTAGE,
68 translation_key=
"rx_level",
69 device_class=SensorDeviceClass.SIGNAL_STRENGTH,
70 entity_registry_enabled_default=
False,
71 entity_category=EntityCategory.DIAGNOSTIC,
72 native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
76 translation_key=
"tx_level",
77 device_class=SensorDeviceClass.SIGNAL_STRENGTH,
78 entity_registry_enabled_default=
False,
79 entity_category=EntityCategory.DIAGNOSTIC,
80 native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
84 translation_key=
"upstream",
85 entity_registry_enabled_default=
False,
86 entity_category=EntityCategory.DIAGNOSTIC,
89 key=
"connection_text",
90 translation_key=
"connection_text",
91 entity_registry_enabled_default=
False,
92 entity_category=EntityCategory.DIAGNOSTIC,
95 key=
"connection_type",
96 translation_key=
"connection_type",
97 entity_registry_enabled_default=
False,
98 entity_category=EntityCategory.DIAGNOSTIC,
101 key=
"current_ps_service_type",
102 translation_key=
"service_type",
103 entity_registry_enabled_default=
False,
104 entity_category=EntityCategory.DIAGNOSTIC,
107 key=
"register_network_display",
108 translation_key=
"register_network_display",
109 entity_registry_enabled_default=
False,
110 entity_category=EntityCategory.DIAGNOSTIC,
114 translation_key=
"band",
115 entity_registry_enabled_default=
False,
116 entity_category=EntityCategory.DIAGNOSTIC,
120 translation_key=
"cell_id",
121 entity_registry_enabled_default=
False,
122 entity_category=EntityCategory.DIAGNOSTIC,
129 entry: NetgearLTEConfigEntry,
130 async_add_entities: AddEntitiesCallback,
132 """Set up the Netgear LTE sensor."""
137 """Base LTE sensor entity."""
139 entity_description: NetgearLTESensorEntityDescription
143 """Return the state of the sensor."""
StateType native_value(self)
None async_setup_entry(HomeAssistant hass, NetgearLTEConfigEntry entry, AddEntitiesCallback async_add_entities)