This snipped allows you to forward sms messages from huawei 3g/lte modem to your telegram messenger
first install the pip package:
HTML Code:
pip3 install huawei-lte-api
Code:
# -*- coding: utf-8 -*-

import argparse

import requests




from  huawei_lte_api.Client import Client

from  huawei_lte_api.Connection import Connection




parser = argparse.ArgumentParser()

parser.add_argument('--new', action='store_true', default=False)

parser.add_argument('--read', action='store_true', default=False)

parser.add_argument('--telegram', action='store_true', default=False)

parsed = parser.parse_args()

#print('Result:',  vars(parsed))

def is_unread(mess):

    if mess['Smstat'] == 0 or mess['Smstat'] == '0':

        return True

    return False




def telegram(message):

   token = 'TELEGRAM_BOT_TOKEN'

   chat_id = 'THE_CHAT_ID_OF_A_BOTCHAT'

   url = 'https://api.telegram.org/bot' + token + '/sendMessage'

   myobj = {'chat_id': chat_id, 'text': message}




   response = requests.post(url, json = myobj)

   if response.ok:

       return True

   return False




# with Connection('http://192.168.8.1/') as connection: For limited access, I have valid credentials no need for limited access

with Connection('http://admin:YOUR_PASSWORD@192.168.8.1/') as connection:

    client = Client(connection) # This just simplifies access to separate API groups, you can use device = Device(connection) if you want

    sms_list = client.sms.get_sms_list(unread_preferred = True)

    for mess in sms_list['Messages']['Message']:

        if parsed.new and not is_unread(mess):

            continue

        for key, value in mess.items():

            print(f"{key}: {value}")

        print("")




        if parsed.telegram and not telegram(mess['Content']):

            continue




        if parsed.read and is_unread(mess):

            #client.sms.send_sms(phone_numbers=['NUMBER'], message=mess['Content']) #you can forward a sms to another number

            client.sms.set_read(mess['Index'])
​
usage:
Code:
python3 read_sms.py --telegram --new --read
option --new to forward only new (unread) messages
option --telegram to forward to telegram
option --read to set the new message status from unread to read