Use new enums in huawei-lte (#61771)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/61791/head
epenet 2021-12-14 12:59:00 +01:00 committed by GitHub
parent 96e54ca939
commit cec43fe868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 68 additions and 72 deletions

View File

@ -10,26 +10,22 @@ from typing import NamedTuple
import attr import attr
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_SIGNAL_STRENGTH,
DOMAIN as SENSOR_DOMAIN, DOMAIN as SENSOR_DOMAIN,
STATE_CLASS_MEASUREMENT, SensorDeviceClass,
STATE_CLASS_TOTAL_INCREASING,
SensorEntity, SensorEntity,
SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
DATA_BYTES, DATA_BYTES,
DATA_RATE_BYTES_PER_SECOND, DATA_RATE_BYTES_PER_SECOND,
ENTITY_CATEGORY_CONFIG,
ENTITY_CATEGORY_DIAGNOSTIC,
FREQUENCY_MEGAHERTZ, FREQUENCY_MEGAHERTZ,
PERCENTAGE, PERCENTAGE,
STATE_UNKNOWN, STATE_UNKNOWN,
TIME_SECONDS, TIME_SECONDS,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity, EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType from homeassistant.helpers.typing import StateType
@ -73,32 +69,32 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
(KEY_DEVICE_INFORMATION, "WanIPAddress"): SensorMeta( (KEY_DEVICE_INFORMATION, "WanIPAddress"): SensorMeta(
name="WAN IP address", name="WAN IP address",
icon="mdi:ip", icon="mdi:ip",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
enabled_default=True, enabled_default=True,
), ),
(KEY_DEVICE_INFORMATION, "WanIPv6Address"): SensorMeta( (KEY_DEVICE_INFORMATION, "WanIPv6Address"): SensorMeta(
name="WAN IPv6 address", name="WAN IPv6 address",
icon="mdi:ip", icon="mdi:ip",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_INFORMATION, "uptime"): SensorMeta( (KEY_DEVICE_INFORMATION, "uptime"): SensorMeta(
name="Uptime", name="Uptime",
icon="mdi:timer-outline", icon="mdi:timer-outline",
unit=TIME_SECONDS, unit=TIME_SECONDS,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "band"): SensorMeta( (KEY_DEVICE_SIGNAL, "band"): SensorMeta(
name="Band", name="Band",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "cell_id"): SensorMeta( (KEY_DEVICE_SIGNAL, "cell_id"): SensorMeta(
name="Cell ID", name="Cell ID",
icon="mdi:transmission-tower", icon="mdi:transmission-tower",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "dl_mcs"): SensorMeta( (KEY_DEVICE_SIGNAL, "dl_mcs"): SensorMeta(
name="Downlink MCS", name="Downlink MCS",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "dlbandwidth"): SensorMeta( (KEY_DEVICE_SIGNAL, "dlbandwidth"): SensorMeta(
name="Downlink bandwidth", name="Downlink bandwidth",
@ -107,47 +103,47 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
"mdi:speedometer-medium", "mdi:speedometer-medium",
"mdi:speedometer", "mdi:speedometer",
)[bisect((8, 15), x if x is not None else -1000)], )[bisect((8, 15), x if x is not None else -1000)],
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "earfcn"): SensorMeta( (KEY_DEVICE_SIGNAL, "earfcn"): SensorMeta(
name="EARFCN", name="EARFCN",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "lac"): SensorMeta( (KEY_DEVICE_SIGNAL, "lac"): SensorMeta(
name="LAC", name="LAC",
icon="mdi:map-marker", icon="mdi:map-marker",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "plmn"): SensorMeta( (KEY_DEVICE_SIGNAL, "plmn"): SensorMeta(
name="PLMN", name="PLMN",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "rac"): SensorMeta( (KEY_DEVICE_SIGNAL, "rac"): SensorMeta(
name="RAC", name="RAC",
icon="mdi:map-marker", icon="mdi:map-marker",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "rrc_status"): SensorMeta( (KEY_DEVICE_SIGNAL, "rrc_status"): SensorMeta(
name="RRC status", name="RRC status",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "tac"): SensorMeta( (KEY_DEVICE_SIGNAL, "tac"): SensorMeta(
name="TAC", name="TAC",
icon="mdi:map-marker", icon="mdi:map-marker",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "tdd"): SensorMeta( (KEY_DEVICE_SIGNAL, "tdd"): SensorMeta(
name="TDD", name="TDD",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "txpower"): SensorMeta( (KEY_DEVICE_SIGNAL, "txpower"): SensorMeta(
name="Transmit power", name="Transmit power",
device_class=DEVICE_CLASS_SIGNAL_STRENGTH, device_class=SensorDeviceClass.SIGNAL_STRENGTH,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "ul_mcs"): SensorMeta( (KEY_DEVICE_SIGNAL, "ul_mcs"): SensorMeta(
name="Uplink MCS", name="Uplink MCS",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "ulbandwidth"): SensorMeta( (KEY_DEVICE_SIGNAL, "ulbandwidth"): SensorMeta(
name="Uplink bandwidth", name="Uplink bandwidth",
@ -156,7 +152,7 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
"mdi:speedometer-medium", "mdi:speedometer-medium",
"mdi:speedometer", "mdi:speedometer",
)[bisect((8, 15), x if x is not None else -1000)], )[bisect((8, 15), x if x is not None else -1000)],
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "mode"): SensorMeta( (KEY_DEVICE_SIGNAL, "mode"): SensorMeta(
name="Mode", name="Mode",
@ -166,16 +162,16 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
str(x), "mdi:signal" str(x), "mdi:signal"
) )
), ),
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "pci"): SensorMeta( (KEY_DEVICE_SIGNAL, "pci"): SensorMeta(
name="PCI", name="PCI",
icon="mdi:transmission-tower", icon="mdi:transmission-tower",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "rsrq"): SensorMeta( (KEY_DEVICE_SIGNAL, "rsrq"): SensorMeta(
name="RSRQ", name="RSRQ",
device_class=DEVICE_CLASS_SIGNAL_STRENGTH, device_class=SensorDeviceClass.SIGNAL_STRENGTH,
# http://www.lte-anbieter.info/technik/rsrq.php # http://www.lte-anbieter.info/technik/rsrq.php
icon=lambda x: ( icon=lambda x: (
"mdi:signal-cellular-outline", "mdi:signal-cellular-outline",
@ -183,13 +179,13 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
"mdi:signal-cellular-2", "mdi:signal-cellular-2",
"mdi:signal-cellular-3", "mdi:signal-cellular-3",
)[bisect((-11, -8, -5), x if x is not None else -1000)], )[bisect((-11, -8, -5), x if x is not None else -1000)],
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
enabled_default=True, enabled_default=True,
), ),
(KEY_DEVICE_SIGNAL, "rsrp"): SensorMeta( (KEY_DEVICE_SIGNAL, "rsrp"): SensorMeta(
name="RSRP", name="RSRP",
device_class=DEVICE_CLASS_SIGNAL_STRENGTH, device_class=SensorDeviceClass.SIGNAL_STRENGTH,
# http://www.lte-anbieter.info/technik/rsrp.php # http://www.lte-anbieter.info/technik/rsrp.php
icon=lambda x: ( icon=lambda x: (
"mdi:signal-cellular-outline", "mdi:signal-cellular-outline",
@ -197,13 +193,13 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
"mdi:signal-cellular-2", "mdi:signal-cellular-2",
"mdi:signal-cellular-3", "mdi:signal-cellular-3",
)[bisect((-110, -95, -80), x if x is not None else -1000)], )[bisect((-110, -95, -80), x if x is not None else -1000)],
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
enabled_default=True, enabled_default=True,
), ),
(KEY_DEVICE_SIGNAL, "rssi"): SensorMeta( (KEY_DEVICE_SIGNAL, "rssi"): SensorMeta(
name="RSSI", name="RSSI",
device_class=DEVICE_CLASS_SIGNAL_STRENGTH, device_class=SensorDeviceClass.SIGNAL_STRENGTH,
# https://eyesaas.com/wi-fi-signal-strength/ # https://eyesaas.com/wi-fi-signal-strength/
icon=lambda x: ( icon=lambda x: (
"mdi:signal-cellular-outline", "mdi:signal-cellular-outline",
@ -211,13 +207,13 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
"mdi:signal-cellular-2", "mdi:signal-cellular-2",
"mdi:signal-cellular-3", "mdi:signal-cellular-3",
)[bisect((-80, -70, -60), x if x is not None else -1000)], )[bisect((-80, -70, -60), x if x is not None else -1000)],
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
enabled_default=True, enabled_default=True,
), ),
(KEY_DEVICE_SIGNAL, "sinr"): SensorMeta( (KEY_DEVICE_SIGNAL, "sinr"): SensorMeta(
name="SINR", name="SINR",
device_class=DEVICE_CLASS_SIGNAL_STRENGTH, device_class=SensorDeviceClass.SIGNAL_STRENGTH,
# http://www.lte-anbieter.info/technik/sinr.php # http://www.lte-anbieter.info/technik/sinr.php
icon=lambda x: ( icon=lambda x: (
"mdi:signal-cellular-outline", "mdi:signal-cellular-outline",
@ -225,13 +221,13 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
"mdi:signal-cellular-2", "mdi:signal-cellular-2",
"mdi:signal-cellular-3", "mdi:signal-cellular-3",
)[bisect((0, 5, 10), x if x is not None else -1000)], )[bisect((0, 5, 10), x if x is not None else -1000)],
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
enabled_default=True, enabled_default=True,
), ),
(KEY_DEVICE_SIGNAL, "rscp"): SensorMeta( (KEY_DEVICE_SIGNAL, "rscp"): SensorMeta(
name="RSCP", name="RSCP",
device_class=DEVICE_CLASS_SIGNAL_STRENGTH, device_class=SensorDeviceClass.SIGNAL_STRENGTH,
# https://wiki.teltonika.lt/view/RSCP # https://wiki.teltonika.lt/view/RSCP
icon=lambda x: ( icon=lambda x: (
"mdi:signal-cellular-outline", "mdi:signal-cellular-outline",
@ -239,12 +235,12 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
"mdi:signal-cellular-2", "mdi:signal-cellular-2",
"mdi:signal-cellular-3", "mdi:signal-cellular-3",
)[bisect((-95, -85, -75), x if x is not None else -1000)], )[bisect((-95, -85, -75), x if x is not None else -1000)],
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "ecio"): SensorMeta( (KEY_DEVICE_SIGNAL, "ecio"): SensorMeta(
name="EC/IO", name="EC/IO",
device_class=DEVICE_CLASS_SIGNAL_STRENGTH, device_class=SensorDeviceClass.SIGNAL_STRENGTH,
# https://wiki.teltonika.lt/view/EC/IO # https://wiki.teltonika.lt/view/EC/IO
icon=lambda x: ( icon=lambda x: (
"mdi:signal-cellular-outline", "mdi:signal-cellular-outline",
@ -252,17 +248,17 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
"mdi:signal-cellular-2", "mdi:signal-cellular-2",
"mdi:signal-cellular-3", "mdi:signal-cellular-3",
)[bisect((-20, -10, -6), x if x is not None else -1000)], )[bisect((-20, -10, -6), x if x is not None else -1000)],
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "transmode"): SensorMeta( (KEY_DEVICE_SIGNAL, "transmode"): SensorMeta(
name="Transmission mode", name="Transmission mode",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "cqi0"): SensorMeta( (KEY_DEVICE_SIGNAL, "cqi0"): SensorMeta(
name="CQI 0", name="CQI 0",
icon="mdi:speedometer", icon="mdi:speedometer",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "cqi1"): SensorMeta( (KEY_DEVICE_SIGNAL, "cqi1"): SensorMeta(
name="CQI 1", name="CQI 1",
@ -270,7 +266,7 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
), ),
(KEY_DEVICE_SIGNAL, "enodeb_id"): SensorMeta( (KEY_DEVICE_SIGNAL, "enodeb_id"): SensorMeta(
name="eNodeB ID", name="eNodeB ID",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "ltedlfreq"): SensorMeta( (KEY_DEVICE_SIGNAL, "ltedlfreq"): SensorMeta(
name="Downlink frequency", name="Downlink frequency",
@ -278,7 +274,7 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
round(int(x) / 10) if x is not None else None, round(int(x) / 10) if x is not None else None,
FREQUENCY_MEGAHERTZ, FREQUENCY_MEGAHERTZ,
), ),
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_DEVICE_SIGNAL, "lteulfreq"): SensorMeta( (KEY_DEVICE_SIGNAL, "lteulfreq"): SensorMeta(
name="Uplink frequency", name="Uplink frequency",
@ -286,7 +282,7 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
round(int(x) / 10) if x is not None else None, round(int(x) / 10) if x is not None else None,
FREQUENCY_MEGAHERTZ, FREQUENCY_MEGAHERTZ,
), ),
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
KEY_MONITORING_CHECK_NOTIFICATIONS: SensorMeta( KEY_MONITORING_CHECK_NOTIFICATIONS: SensorMeta(
exclude=re.compile( exclude=re.compile(
@ -304,13 +300,13 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
name="Current month download", name="Current month download",
unit=DATA_BYTES, unit=DATA_BYTES,
icon="mdi:download", icon="mdi:download",
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
(KEY_MONITORING_MONTH_STATISTICS, "CurrentMonthUpload"): SensorMeta( (KEY_MONITORING_MONTH_STATISTICS, "CurrentMonthUpload"): SensorMeta(
name="Current month upload", name="Current month upload",
unit=DATA_BYTES, unit=DATA_BYTES,
icon="mdi:upload", icon="mdi:upload",
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
KEY_MONITORING_STATUS: SensorMeta( KEY_MONITORING_STATUS: SensorMeta(
include=re.compile( include=re.compile(
@ -320,36 +316,36 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
), ),
(KEY_MONITORING_STATUS, "BatteryPercent"): SensorMeta( (KEY_MONITORING_STATUS, "BatteryPercent"): SensorMeta(
name="Battery", name="Battery",
device_class=DEVICE_CLASS_BATTERY, device_class=SensorDeviceClass.BATTERY,
unit=PERCENTAGE, unit=PERCENTAGE,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_MONITORING_STATUS, "CurrentWifiUser"): SensorMeta( (KEY_MONITORING_STATUS, "CurrentWifiUser"): SensorMeta(
name="WiFi clients connected", name="WiFi clients connected",
icon="mdi:wifi", icon="mdi:wifi",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_MONITORING_STATUS, "PrimaryDns"): SensorMeta( (KEY_MONITORING_STATUS, "PrimaryDns"): SensorMeta(
name="Primary DNS server", name="Primary DNS server",
icon="mdi:ip", icon="mdi:ip",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_MONITORING_STATUS, "SecondaryDns"): SensorMeta( (KEY_MONITORING_STATUS, "SecondaryDns"): SensorMeta(
name="Secondary DNS server", name="Secondary DNS server",
icon="mdi:ip", icon="mdi:ip",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_MONITORING_STATUS, "PrimaryIPv6Dns"): SensorMeta( (KEY_MONITORING_STATUS, "PrimaryIPv6Dns"): SensorMeta(
name="Primary IPv6 DNS server", name="Primary IPv6 DNS server",
icon="mdi:ip", icon="mdi:ip",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_MONITORING_STATUS, "SecondaryIPv6Dns"): SensorMeta( (KEY_MONITORING_STATUS, "SecondaryIPv6Dns"): SensorMeta(
name="Secondary IPv6 DNS server", name="Secondary IPv6 DNS server",
icon="mdi:ip", icon="mdi:ip",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
KEY_MONITORING_TRAFFIC_STATISTICS: SensorMeta( KEY_MONITORING_TRAFFIC_STATISTICS: SensorMeta(
exclude=re.compile(r"^showtraffic$", re.IGNORECASE) exclude=re.compile(r"^showtraffic$", re.IGNORECASE)
@ -361,43 +357,43 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
name="Current connection download", name="Current connection download",
unit=DATA_BYTES, unit=DATA_BYTES,
icon="mdi:download", icon="mdi:download",
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
(KEY_MONITORING_TRAFFIC_STATISTICS, "CurrentDownloadRate"): SensorMeta( (KEY_MONITORING_TRAFFIC_STATISTICS, "CurrentDownloadRate"): SensorMeta(
name="Current download rate", name="Current download rate",
unit=DATA_RATE_BYTES_PER_SECOND, unit=DATA_RATE_BYTES_PER_SECOND,
icon="mdi:download", icon="mdi:download",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
(KEY_MONITORING_TRAFFIC_STATISTICS, "CurrentUpload"): SensorMeta( (KEY_MONITORING_TRAFFIC_STATISTICS, "CurrentUpload"): SensorMeta(
name="Current connection upload", name="Current connection upload",
unit=DATA_BYTES, unit=DATA_BYTES,
icon="mdi:upload", icon="mdi:upload",
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
(KEY_MONITORING_TRAFFIC_STATISTICS, "CurrentUploadRate"): SensorMeta( (KEY_MONITORING_TRAFFIC_STATISTICS, "CurrentUploadRate"): SensorMeta(
name="Current upload rate", name="Current upload rate",
unit=DATA_RATE_BYTES_PER_SECOND, unit=DATA_RATE_BYTES_PER_SECOND,
icon="mdi:upload", icon="mdi:upload",
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
(KEY_MONITORING_TRAFFIC_STATISTICS, "TotalConnectTime"): SensorMeta( (KEY_MONITORING_TRAFFIC_STATISTICS, "TotalConnectTime"): SensorMeta(
name="Total connected duration", name="Total connected duration",
unit=TIME_SECONDS, unit=TIME_SECONDS,
icon="mdi:timer-outline", icon="mdi:timer-outline",
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
(KEY_MONITORING_TRAFFIC_STATISTICS, "TotalDownload"): SensorMeta( (KEY_MONITORING_TRAFFIC_STATISTICS, "TotalDownload"): SensorMeta(
name="Total download", name="Total download",
unit=DATA_BYTES, unit=DATA_BYTES,
icon="mdi:download", icon="mdi:download",
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
(KEY_MONITORING_TRAFFIC_STATISTICS, "TotalUpload"): SensorMeta( (KEY_MONITORING_TRAFFIC_STATISTICS, "TotalUpload"): SensorMeta(
name="Total upload", name="Total upload",
unit=DATA_BYTES, unit=DATA_BYTES,
icon="mdi:upload", icon="mdi:upload",
state_class=STATE_CLASS_TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
KEY_NET_CURRENT_PLMN: SensorMeta( KEY_NET_CURRENT_PLMN: SensorMeta(
exclude=re.compile(r"^(Rat|ShortName|Spn)$", re.IGNORECASE) exclude=re.compile(r"^(Rat|ShortName|Spn)$", re.IGNORECASE)
@ -405,15 +401,15 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
(KEY_NET_CURRENT_PLMN, "State"): SensorMeta( (KEY_NET_CURRENT_PLMN, "State"): SensorMeta(
name="Operator search mode", name="Operator search mode",
formatter=lambda x: ({"0": "Auto", "1": "Manual"}.get(x, "Unknown"), None), formatter=lambda x: ({"0": "Auto", "1": "Manual"}.get(x, "Unknown"), None),
entity_category=ENTITY_CATEGORY_CONFIG, entity_category=EntityCategory.CONFIG,
), ),
(KEY_NET_CURRENT_PLMN, "FullName"): SensorMeta( (KEY_NET_CURRENT_PLMN, "FullName"): SensorMeta(
name="Operator name", name="Operator name",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
(KEY_NET_CURRENT_PLMN, "Numeric"): SensorMeta( (KEY_NET_CURRENT_PLMN, "Numeric"): SensorMeta(
name="Operator code", name="Operator code",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
KEY_NET_NET_MODE: SensorMeta(include=re.compile(r"^NetworkMode$", re.IGNORECASE)), KEY_NET_NET_MODE: SensorMeta(include=re.compile(r"^NetworkMode$", re.IGNORECASE)),
(KEY_NET_NET_MODE, "NetworkMode"): SensorMeta( (KEY_NET_NET_MODE, "NetworkMode"): SensorMeta(
@ -430,7 +426,7 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
}.get(x, "Unknown"), }.get(x, "Unknown"),
None, None,
), ),
entity_category=ENTITY_CATEGORY_CONFIG, entity_category=EntityCategory.CONFIG,
), ),
(KEY_SMS_SMS_COUNT, "LocalDeleted"): SensorMeta( (KEY_SMS_SMS_COUNT, "LocalDeleted"): SensorMeta(
name="SMS deleted (device)", name="SMS deleted (device)",