Add Huawei LTE SMS storage full and unread sensors (#40021)
parent
c3b6675617
commit
e06f2a89ea
|
@ -63,6 +63,7 @@ from .const import (
|
||||||
KEY_DEVICE_INFORMATION,
|
KEY_DEVICE_INFORMATION,
|
||||||
KEY_DEVICE_SIGNAL,
|
KEY_DEVICE_SIGNAL,
|
||||||
KEY_DIALUP_MOBILE_DATASWITCH,
|
KEY_DIALUP_MOBILE_DATASWITCH,
|
||||||
|
KEY_MONITORING_CHECK_NOTIFICATIONS,
|
||||||
KEY_MONITORING_MONTH_STATISTICS,
|
KEY_MONITORING_MONTH_STATISTICS,
|
||||||
KEY_MONITORING_STATUS,
|
KEY_MONITORING_STATUS,
|
||||||
KEY_MONITORING_TRAFFIC_STATISTICS,
|
KEY_MONITORING_TRAFFIC_STATISTICS,
|
||||||
|
@ -243,6 +244,10 @@ class Router:
|
||||||
self._get_data(
|
self._get_data(
|
||||||
KEY_MONITORING_MONTH_STATISTICS, self.client.monitoring.month_statistics
|
KEY_MONITORING_MONTH_STATISTICS, self.client.monitoring.month_statistics
|
||||||
)
|
)
|
||||||
|
self._get_data(
|
||||||
|
KEY_MONITORING_CHECK_NOTIFICATIONS,
|
||||||
|
self.client.monitoring.check_notifications,
|
||||||
|
)
|
||||||
self._get_data(KEY_MONITORING_STATUS, self.client.monitoring.status)
|
self._get_data(KEY_MONITORING_STATUS, self.client.monitoring.status)
|
||||||
self._get_data(
|
self._get_data(
|
||||||
KEY_MONITORING_TRAFFIC_STATISTICS, self.client.monitoring.traffic_statistics
|
KEY_MONITORING_TRAFFIC_STATISTICS, self.client.monitoring.traffic_statistics
|
||||||
|
|
|
@ -13,7 +13,12 @@ from homeassistant.components.binary_sensor import (
|
||||||
from homeassistant.const import CONF_URL
|
from homeassistant.const import CONF_URL
|
||||||
|
|
||||||
from . import HuaweiLteBaseEntity
|
from . import HuaweiLteBaseEntity
|
||||||
from .const import DOMAIN, KEY_MONITORING_STATUS, KEY_WLAN_WIFI_FEATURE_SWITCH
|
from .const import (
|
||||||
|
DOMAIN,
|
||||||
|
KEY_MONITORING_CHECK_NOTIFICATIONS,
|
||||||
|
KEY_MONITORING_STATUS,
|
||||||
|
KEY_WLAN_WIFI_FEATURE_SWITCH,
|
||||||
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -29,6 +34,9 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
entities.append(HuaweiLteWifi24ghzStatusBinarySensor(router))
|
entities.append(HuaweiLteWifi24ghzStatusBinarySensor(router))
|
||||||
entities.append(HuaweiLteWifi5ghzStatusBinarySensor(router))
|
entities.append(HuaweiLteWifi5ghzStatusBinarySensor(router))
|
||||||
|
|
||||||
|
if router.data.get(KEY_MONITORING_CHECK_NOTIFICATIONS):
|
||||||
|
entities.append(HuaweiLteSmsStorageFullBinarySensor(router))
|
||||||
|
|
||||||
async_add_entities(entities, True)
|
async_add_entities(entities, True)
|
||||||
|
|
||||||
|
|
||||||
|
@ -194,3 +202,32 @@ class HuaweiLteWifi5ghzStatusBinarySensor(HuaweiLteBaseWifiStatusBinarySensor):
|
||||||
@property
|
@property
|
||||||
def _entity_name(self) -> str:
|
def _entity_name(self) -> str:
|
||||||
return "5GHz WiFi status"
|
return "5GHz WiFi status"
|
||||||
|
|
||||||
|
|
||||||
|
@attr.s
|
||||||
|
class HuaweiLteSmsStorageFullBinarySensor(HuaweiLteBaseBinarySensor):
|
||||||
|
"""Huawei LTE SMS storage full binary sensor."""
|
||||||
|
|
||||||
|
def __attrs_post_init__(self):
|
||||||
|
"""Initialize identifiers."""
|
||||||
|
self.key = KEY_MONITORING_CHECK_NOTIFICATIONS
|
||||||
|
self.item = "SmsStorageFull"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _entity_name(self) -> str:
|
||||||
|
return "SMS storage full"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_on(self) -> bool:
|
||||||
|
"""Return whether the binary sensor is on."""
|
||||||
|
return self._raw_state is not None and int(self._raw_state) != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def assumed_state(self) -> bool:
|
||||||
|
"""Return True if real state is assumed, not known."""
|
||||||
|
return self._raw_state is None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
"""Return WiFi status sensor icon."""
|
||||||
|
return "mdi:email-alert" if self.is_on else "mdi:email-off"
|
||||||
|
|
|
@ -27,6 +27,7 @@ KEY_DEVICE_BASIC_INFORMATION = "device_basic_information"
|
||||||
KEY_DEVICE_INFORMATION = "device_information"
|
KEY_DEVICE_INFORMATION = "device_information"
|
||||||
KEY_DEVICE_SIGNAL = "device_signal"
|
KEY_DEVICE_SIGNAL = "device_signal"
|
||||||
KEY_DIALUP_MOBILE_DATASWITCH = "dialup_mobile_dataswitch"
|
KEY_DIALUP_MOBILE_DATASWITCH = "dialup_mobile_dataswitch"
|
||||||
|
KEY_MONITORING_CHECK_NOTIFICATIONS = "monitoring_check_notifications"
|
||||||
KEY_MONITORING_MONTH_STATISTICS = "monitoring_month_statistics"
|
KEY_MONITORING_MONTH_STATISTICS = "monitoring_month_statistics"
|
||||||
KEY_MONITORING_STATUS = "monitoring_status"
|
KEY_MONITORING_STATUS = "monitoring_status"
|
||||||
KEY_MONITORING_TRAFFIC_STATISTICS = "monitoring_traffic_statistics"
|
KEY_MONITORING_TRAFFIC_STATISTICS = "monitoring_traffic_statistics"
|
||||||
|
@ -36,13 +37,18 @@ KEY_SMS_SMS_COUNT = "sms_sms_count"
|
||||||
KEY_WLAN_HOST_LIST = "wlan_host_list"
|
KEY_WLAN_HOST_LIST = "wlan_host_list"
|
||||||
KEY_WLAN_WIFI_FEATURE_SWITCH = "wlan_wifi_feature_switch"
|
KEY_WLAN_WIFI_FEATURE_SWITCH = "wlan_wifi_feature_switch"
|
||||||
|
|
||||||
BINARY_SENSOR_KEYS = {KEY_MONITORING_STATUS, KEY_WLAN_WIFI_FEATURE_SWITCH}
|
BINARY_SENSOR_KEYS = {
|
||||||
|
KEY_MONITORING_CHECK_NOTIFICATIONS,
|
||||||
|
KEY_MONITORING_STATUS,
|
||||||
|
KEY_WLAN_WIFI_FEATURE_SWITCH,
|
||||||
|
}
|
||||||
|
|
||||||
DEVICE_TRACKER_KEYS = {KEY_WLAN_HOST_LIST}
|
DEVICE_TRACKER_KEYS = {KEY_WLAN_HOST_LIST}
|
||||||
|
|
||||||
SENSOR_KEYS = {
|
SENSOR_KEYS = {
|
||||||
KEY_DEVICE_INFORMATION,
|
KEY_DEVICE_INFORMATION,
|
||||||
KEY_DEVICE_SIGNAL,
|
KEY_DEVICE_SIGNAL,
|
||||||
|
KEY_MONITORING_CHECK_NOTIFICATIONS,
|
||||||
KEY_MONITORING_MONTH_STATISTICS,
|
KEY_MONITORING_MONTH_STATISTICS,
|
||||||
KEY_MONITORING_STATUS,
|
KEY_MONITORING_STATUS,
|
||||||
KEY_MONITORING_TRAFFIC_STATISTICS,
|
KEY_MONITORING_TRAFFIC_STATISTICS,
|
||||||
|
|
|
@ -23,6 +23,7 @@ from .const import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
KEY_DEVICE_INFORMATION,
|
KEY_DEVICE_INFORMATION,
|
||||||
KEY_DEVICE_SIGNAL,
|
KEY_DEVICE_SIGNAL,
|
||||||
|
KEY_MONITORING_CHECK_NOTIFICATIONS,
|
||||||
KEY_MONITORING_MONTH_STATISTICS,
|
KEY_MONITORING_MONTH_STATISTICS,
|
||||||
KEY_MONITORING_STATUS,
|
KEY_MONITORING_STATUS,
|
||||||
KEY_MONITORING_TRAFFIC_STATISTICS,
|
KEY_MONITORING_TRAFFIC_STATISTICS,
|
||||||
|
@ -157,6 +158,15 @@ SENSOR_META = {
|
||||||
and "mdi:signal-cellular-2"
|
and "mdi:signal-cellular-2"
|
||||||
or "mdi:signal-cellular-3",
|
or "mdi:signal-cellular-3",
|
||||||
),
|
),
|
||||||
|
KEY_MONITORING_CHECK_NOTIFICATIONS: dict(
|
||||||
|
exclude=re.compile(
|
||||||
|
r"^(onlineupdatestatus|smsstoragefull)$",
|
||||||
|
re.IGNORECASE,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
(KEY_MONITORING_CHECK_NOTIFICATIONS, "UnreadMessage"): dict(
|
||||||
|
name="SMS unread", icon="mdi:email-receive"
|
||||||
|
),
|
||||||
KEY_MONITORING_MONTH_STATISTICS: dict(
|
KEY_MONITORING_MONTH_STATISTICS: dict(
|
||||||
exclude=re.compile(r"^month(duration|lastcleartime)$", re.IGNORECASE)
|
exclude=re.compile(r"^month(duration|lastcleartime)$", re.IGNORECASE)
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue