-
Notifications
You must be signed in to change notification settings - Fork 45
Feature improve lte sensor value conversions and mappings #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 16 commits
a6c5f09
bcae74c
e491181
bfca2a6
74de31e
d188a94
b495693
7a144e0
4134d64
509ea9d
7838453
0096fcc
44b3000
7457af3
0b729a1
133bb56
5c14cf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| SensorEntity, | ||
| SensorEntityDescription, | ||
| ) | ||
| from homeassistant.const import PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, UnitOfDataRate | ||
| from homeassistant.const import PERCENTAGE, SIGNAL_STRENGTH_DECIBELS_MILLIWATT, UnitOfDataRate, UnitOfInformation | ||
| from homeassistant.config_entries import ConfigEntry | ||
| from homeassistant.core import HomeAssistant, callback | ||
| from .const import DOMAIN | ||
|
|
@@ -106,6 +106,29 @@ class TPLinkRouterLTESensorEntityDescription( | |
| ), | ||
| ) | ||
|
|
||
| network_types = { | ||
| 0: "No Service", | ||
| 1: "GSM", | ||
| 2: "WCDMA", | ||
| 3: "4G LTE", | ||
| 4: "TD-SCDMA", | ||
| 5: "CDMA 1x", | ||
| 6: "CDMA 1x Ev-Do", | ||
| 7: "4G+ LTE" | ||
| } | ||
|
|
||
| sim_statuses = { | ||
| 0: "No SIM card detected or SIM card error.", | ||
| 1: "No SIM card detected.", | ||
| 2: "SIM card error.", | ||
| 3: "SIM card prepared.", | ||
| 4: "SIM locked.", | ||
| 5: "SIM unlocked. Authentication succeeded.", | ||
| 6: "PIN locked.", | ||
| 7: "SIM card is locked permanently.", | ||
| 8: "suspension of transmission", | ||
| 9: "Unopened" | ||
| } | ||
|
|
||
| LTE_SENSOR_TYPES: tuple[TPLinkRouterLTESensorEntityDescription, ...] = ( | ||
| TPLinkRouterLTESensorEntityDescription( | ||
|
|
@@ -124,19 +147,20 @@ class TPLinkRouterLTESensorEntityDescription( | |
| key="lte_network_type", | ||
| name="LTE Network Type", | ||
| icon="mdi:sim-outline", | ||
| value=lambda status: status.network_type, | ||
| value=lambda status: network_types[status.network_type], | ||
| ), | ||
| TPLinkRouterLTESensorEntityDescription( | ||
| key="lte_sim_status", | ||
| name="LTE SIM Status", | ||
| icon="mdi:sim-outline", | ||
| value=lambda status: status.sim_status, | ||
| value=lambda status: sim_statuses[status.sim_status], | ||
|
||
| ), | ||
| TPLinkRouterLTESensorEntityDescription( | ||
| key="lte_total_statistics", | ||
| name="LTE Total Statistics", | ||
| icon="mdi:sim-outline", | ||
| state_class=SensorStateClass.TOTAL, | ||
| native_unit_of_measurement=UnitOfInformation.BYTES, | ||
| value=lambda status: status.total_statistics, | ||
| ), | ||
| TPLinkRouterLTESensorEntityDescription( | ||
|
|
@@ -168,7 +192,7 @@ class TPLinkRouterLTESensorEntityDescription( | |
| icon="mdi:sim-outline", | ||
| state_class=SensorStateClass.MEASUREMENT, | ||
| native_unit_of_measurement=PERCENTAGE, | ||
| value=lambda status: status.sig_level, | ||
| value=lambda status: status.sig_level * 25, | ||
| ), | ||
| TPLinkRouterLTESensorEntityDescription( | ||
| key="lte_rsrp", | ||
|
|
@@ -192,7 +216,7 @@ class TPLinkRouterLTESensorEntityDescription( | |
| icon="mdi:sim-outline", | ||
| state_class=SensorStateClass.MEASUREMENT, | ||
| native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT, | ||
| value=lambda status: status.snr, | ||
| value=lambda status: 0.1 * status.snr, | ||
| ), | ||
| TPLinkRouterLTESensorEntityDescription( | ||
| key="lte_isp_name", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would be more useful to move this dict to the client. So I have added this to client