1 """Support for SMS dongle sensor."""
6 SensorEntityDescription,
16 from .const
import DOMAIN, GATEWAY, NETWORK_COORDINATOR, SIGNAL_COORDINATOR, SMS_GATEWAY
21 device_class=SensorDeviceClass.SIGNAL_STRENGTH,
22 entity_category=EntityCategory.DIAGNOSTIC,
23 native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
24 entity_registry_enabled_default=
False,
25 state_class=SensorStateClass.MEASUREMENT,
29 translation_key=
"signal_percent",
30 native_unit_of_measurement=PERCENTAGE,
31 entity_registry_enabled_default=
True,
32 state_class=SensorStateClass.MEASUREMENT,
36 translation_key=
"bit_error_rate",
37 entity_category=EntityCategory.DIAGNOSTIC,
38 native_unit_of_measurement=PERCENTAGE,
39 entity_registry_enabled_default=
False,
40 state_class=SensorStateClass.MEASUREMENT,
47 translation_key=
"network_name",
48 entity_category=EntityCategory.DIAGNOSTIC,
49 entity_registry_enabled_default=
False,
53 translation_key=
"state",
54 entity_registry_enabled_default=
True,
58 translation_key=
"network_code",
59 entity_category=EntityCategory.DIAGNOSTIC,
60 entity_registry_enabled_default=
False,
64 translation_key=
"cid",
65 entity_category=EntityCategory.DIAGNOSTIC,
66 entity_registry_enabled_default=
False,
70 translation_key=
"lac",
71 entity_category=EntityCategory.DIAGNOSTIC,
72 entity_registry_enabled_default=
False,
79 config_entry: ConfigEntry,
80 async_add_entities: AddEntitiesCallback,
82 """Set up all device sensors."""
83 sms_data = hass.data[DOMAIN][SMS_GATEWAY]
84 signal_coordinator = sms_data[SIGNAL_COORDINATOR]
85 network_coordinator = sms_data[NETWORK_COORDINATOR]
86 gateway = sms_data[GATEWAY]
87 unique_id =
str(await gateway.get_imei_async())
89 DeviceSensor(signal_coordinator, description, unique_id, gateway)
90 for description
in SIGNAL_SENSORS
93 DeviceSensor(network_coordinator, description, unique_id, gateway)
94 for description
in NETWORK_SENSORS
100 """Implementation of a device sensor."""
102 _attr_has_entity_name =
True
104 def __init__(self, coordinator, description, unique_id, gateway):
105 """Initialize the device sensor."""
108 identifiers={(DOMAIN, unique_id)},
110 manufacturer=gateway.manufacturer,
112 sw_version=gateway.firmware,
119 """Return the state of the device."""
def __init__(self, coordinator, description, unique_id, gateway)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)