Skip to content

Commit

Permalink
Make huawei_lte operator search and preferred network modes translata…
Browse files Browse the repository at this point in the history
…ble (#104673)
  • Loading branch information
scop authored Nov 29, 2023
1 parent 634785a commit afc3f1d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
20 changes: 1 addition & 19 deletions homeassistant/components/huawei_lte/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import logging
import re

from huawei_lte_api.enums.net import NetworkModeEnum

from homeassistant.components.sensor import (
DOMAIN as SENSOR_DOMAIN,
SensorDeviceClass,
Expand Down Expand Up @@ -575,10 +573,6 @@ class HuaweiSensorEntityDescription(SensorEntityDescription):
"State": HuaweiSensorEntityDescription(
key="State",
translation_key="operator_search_mode",
format_fn=lambda x: (
{"0": "Auto", "1": "Manual"}.get(x),
None,
),
entity_category=EntityCategory.DIAGNOSTIC,
),
},
Expand All @@ -588,19 +582,7 @@ class HuaweiSensorEntityDescription(SensorEntityDescription):
descriptions={
"NetworkMode": HuaweiSensorEntityDescription(
key="NetworkMode",
translation_key="preferred_mode",
format_fn=lambda x: (
{
NetworkModeEnum.MODE_AUTO.value: "4G/3G/2G",
NetworkModeEnum.MODE_4G_3G_AUTO.value: "4G/3G",
NetworkModeEnum.MODE_4G_2G_AUTO.value: "4G/2G",
NetworkModeEnum.MODE_4G_ONLY.value: "4G",
NetworkModeEnum.MODE_3G_2G_AUTO.value: "3G/2G",
NetworkModeEnum.MODE_3G_ONLY.value: "3G",
NetworkModeEnum.MODE_2G_ONLY.value: "2G",
}.get(x),
None,
),
translation_key="preferred_network_mode",
entity_category=EntityCategory.DIAGNOSTIC,
),
},
Expand Down
19 changes: 16 additions & 3 deletions homeassistant/components/huawei_lte/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,23 @@
"name": "Operator code"
},
"operator_search_mode": {
"name": "Operator search mode"
"name": "Operator search mode",
"state": {
"0": "Auto",
"1": "Manual"
}
},
"preferred_mode": {
"name": "Preferred mode"
"preferred_network_mode": {
"name": "Preferred network mode",
"state": {
"00": "4G/3G/2G auto",
"0302": "4G/3G auto",
"0301": "4G/2G auto",
"03": "4G only",
"0201": "3G/2G auto",
"02": "3G only",
"01": "2G only"
}
},
"sms_deleted_device": {
"name": "SMS deleted (device)"
Expand Down

0 comments on commit afc3f1d

Please sign in to comment.