huawei-modem-python-api-client
huawei-modem-python-api-client copied to clipboard
Receiving SMS in Russian
Hi. I'm trying to get an sms
import huaweisms.api.user import huaweisms.api.sms ctx = huaweisms.api.user.quick_login("admin", "password") print(ctx) smss = huaweisms.api.sms.get_sms(ctx, box_type=1, qty=1, unread_preferred=True) print(smss)
The SMS comes and I see unknown characters in the "Content" field
<ApiCtx modem_host=192.168.8.1> {'type': 'response', 'response': {'Count': '1', 'Messages': {'Message': [{'Smstat': '0', 'Index': '40021', 'Phone': '+79992314505', 'Content': 'Ð\x9fÑ\x80ивеÑ\x82', 'Date': '2022-03-11 14:18:04', 'Sca': '', 'SaveType': '0', 'Priority': '0', 'SmsType': '1'}]}}}
Trying to understand what you are trying to do here.
Are you reading the SMS INBOX for INCOMING SMS on your MODEM?
I am already seeing what the API gets you. But, what's the EXACT MESSAGE you get (in Russian characters)?
I am successfully receiving the SMS. In the "Content" field, I see it, but not in the correct encoding. For example, 'Content': 'Ð\x9fÑ\x80ивеÑ\x82' = "Привет"
Will look into that later today. Thanks for letting me know.
On Sat, Mar 12, 2022 at 14:00 therealrollexx @.***> wrote:
I am successfully receiving the SMS. In the "Content" field, I see it, but not in the correct encoding. For example, 'Content': 'Ð\x9fÑ\x80ивеÑ\x82' = "Привет"
— Reply to this email directly, view it on GitHub https://github.com/pablo/huawei-modem-python-api-client/issues/38#issuecomment-1065919201, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIUGHHKUSZW4E4MCHSYK7LU7TETLANCNFSM5QRZVQTQ . You are receiving this because you commented.Message ID: @.***>
Thank you :)
I am successfully receiving the SMS. In the "Content" field, I see it, but not in the correct encoding. For example, 'Content': 'Ð\x9fÑ\x80ивеÑ\x82' = "Привет"
For Russian try this:
content = 'Ð\x9fÑ\x80ивеÑ\x82'
content_russian = content.encode('latin-1').decode('utf-8')
print(content_russian)
How can you get the content extracted from the smss (from the example)?
Convert messages to Russian language:
import huaweisms.api.user
import huaweisms.api.wlan
import huaweisms.api.sms
import json
ctx = huaweisms.api.user.quick_login("admin", "bagranchopass", modem_host='10.8.95.1')
sms_list_dict = huaweisms.api.sms.get_sms(ctx, qty=7, unread_preferred=False)
list1 = sms_list_dict.get("response").get("Messages").get("Message")
mylist = list()
i = 0
for value in list1:
content = value.get("Content")
content_russian = content.encode('latin-1').decode('utf-8')
sms_list_dict.get("response").get("Messages").get("Message")[i].update({'Content': content_russian})
i = i + 1
print(sms_list_dict)