diff options
Diffstat (limited to 'include/py/homekit/modem')
-rw-r--r-- | include/py/homekit/modem/e3372.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/include/py/homekit/modem/e3372.py b/include/py/homekit/modem/e3372.py index f68db5a..8164b88 100644 --- a/include/py/homekit/modem/e3372.py +++ b/include/py/homekit/modem/e3372.py @@ -1,6 +1,7 @@ import requests import xml.etree.ElementTree as ElementTree +from datetime import datetime from ..util import Addr from enum import Enum from ..http import HTTPMethod @@ -21,14 +22,14 @@ class Error(Enum): ERROR_WRONG_TOKEN = 125001 ERROR_WRONG_SESSION = 125002 ERROR_WRONG_SESSION_TOKEN = 125003 - - + + class WifiStatus(Enum): WIFI_CONNECTING = '900' WIFI_CONNECTED = '901' WIFI_DISCONNECTED = '902' WIFI_DISCONNECTING = '903' - + class Cradle(Enum): CRADLE_CONNECTING = '900' @@ -38,8 +39,8 @@ class Cradle(Enum): CRADLE_CONNECTFAILED = '904' CRADLE_CONNECTSTATUSNULL = '905' CRANDLE_CONNECTSTATUSERRO = '906' - - + + class MacroEVDOLevel(Enum): MACRO_EVDO_LEVEL_ZERO = '0' MACRO_EVDO_LEVEL_ONE = '1' @@ -47,8 +48,8 @@ class MacroEVDOLevel(Enum): MACRO_EVDO_LEVEL_THREE = '3' MACRO_EVDO_LEVEL_FOUR = '4' MACRO_EVDO_LEVEL_FIVE = '5' - - + + class MacroNetWorkType(Enum): MACRO_NET_WORK_TYPE_NOSERVICE = 0 MACRO_NET_WORK_TYPE_GSM = 1 @@ -127,7 +128,7 @@ class E3372: _get_raw_data: bool _headers: dict[str, str] _authorized: bool - + def __init__(self, addr: Addr, need_auth: bool = True, @@ -174,7 +175,7 @@ class E3372: def sms_count(self): self.auth() return self.request('sms/sms-count') - + def sms_send(self, phone: str, text: str): self.auth() return self.request('sms/send-sms', HTTPMethod.POST, { @@ -204,6 +205,7 @@ class E3372: messages = [] for message_elem in root.find('Messages').findall('Message'): message_dict = {child.tag: child.text for child in message_elem} + message_dict['UnixTime'] = int(datetime.strptime(message_dict['Date'], '%Y-%m-%d %H:%M:%S').timestamp()) messages.append(message_dict) return messages |