Exemplo n.º 1
0
def check_load_state():
    if not global_vars.mppt_data["batt"].get("v"):
        logger.warning("MPPT data not yet populated!")
        return

    try:
        human_datetime = datetime.now().strftime("%d/%m/%Y %H:%M")
        now_iso_stamp = datetime.now().replace(microsecond=0).isoformat()
        unix_time_int = int(time.time())
        warn_sms_text = ""
        if global_vars.mppt_data["load"]["state"] != system_state['last_load_state']:
            if global_vars.mppt_data["load"]["state"]:
                warn_sms_text = human_datetime + ": Load now reconnected. Battery voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V"
                logger.warning("Load now reconnected. Battery voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V. Sending alert SMS")
            else:
                warn_sms_text = human_datetime + ": Load disconnected! Battery voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V"
                logger.critical("Load disconnected! Battery voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V. Sending alert SMS")
            system_state['last_load_state_time'] = unix_time_int
            send_sms(config['bmv']['warn_sms_list'], warn_sms_text)

        if not global_vars.mppt_data["load"]["state"] and ( unix_time_int > (system_state['last_load_state_time'] + config['system']['load_warning_interval'] )):
            warn_sms_text = human_datetime + ": Load disconnected! Battery voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V"
            logger.critical("Load disconnected! Battery voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V. Sending alert SMS")
            system_state['last_load_state_time'] = unix_time_int
            send_sms(config['bmv']['warn_sms_list'], warn_sms_text)

        system_state['last_load_state'] = global_vars.mppt_data["load"]["state"]

    except Exception as e:
        logger.error("MPPT load state check failed: " + str(e))
Exemplo n.º 2
0
def accel_isr(channel):
    unix_time_int = int(time.time())
    now_iso_stamp = datetime.now().replace(microsecond=0).isoformat()

    try:
        if channel != config['sensors']['lis3dh_interrupt_pin']:
            return

        get_lis3dh_data()
        if lis3dh_data['interrupt']:
            if unix_time_int < (lis3dh_data['last_interrupt_timestamp'] + 3):
                lis3dh_data['interrupt_count'] += 1
            else:
                lis3dh_data['interrupt_count'] = 1
            lis3dh_data['interrupt_state'] = True
            lis3dh_data['last_interrupt'] = now_iso_stamp
            lis3dh_data['last_interrupt_timestamp'] = unix_time_int
            if lis3dh_data['interrupt_count'] > 5 and not lis3dh_data[
                    'motion_warn'] and config['sensors']['lis3dh_warn_enable']:
                logger.critical('5 motion events detected!')
                lis3dh_data['motion_warn'] = True
                if not system_state['maintenance_mode']:
                    human_datetime = datetime.now().strftime('%d/%m/%Y %H:%M')
                    warn_sms_text = human_datetime + ': Motion event detected!'
                    send_sms(config['sensors']['lis3dh_sms_list'],
                             warn_sms_text)
                else:
                    logger.warning(
                        "System in maintenance mode, no warning SMS sent")

    except Exception as e:
        # Error has occurred, log it
        logger.error("LIS3DH interrupt triggered but ISR failed: " + str(e))
Exemplo n.º 3
0
def send_sms_account_verification(phone, code):

    message = f'Код активации: {code}'
    try:
        if settings.ENV == PRODUCTION_ENV:
            send_sms(phone, message)
    except:
        pass
Exemplo n.º 4
0
def send_sms_account_info(phone, password, parsed_from=None, link_code=None):
    message = "Dlya bystroi prodaji my takje dobavili vashe ob'yavlenie na sait Riom.kg\n"\
                f"Login {phone}\n"\
                f"Parol: {password}\n" \
                f"https://riom.kg/new/{link_code}/ vvedite novyi parol"

    try:
        send_sms(phone, message)
    except:
        pass
Exemplo n.º 5
0
def get_tsl2561_data():
    unix_time_int = int(time.time())
    now_iso_stamp = datetime.now().replace(microsecond=0).isoformat()

    if config['sensors']['tsl2561_enable']:
        try:
            tsl2561_data['lux'] = tsl.lux()
            tsl2561_data['broad_counts'], tsl2561_data[
                'ir_counts'] = tsl._get_luminosity()
            tsl2561_data['gain'] = tsl.gain
            if not tsl2561_data['gain']:
                tsl2561_data['gain'] = 1

            if unix_time_int > (tsl2561_data['last_door_open_timestamp'] +
                                3) and tsl2561_data['door_open_count']:
                tsl2561_data['door_open'] = False
                tsl2561_data['door_open_warn'] = False
                tsl2561_data['last_door_open_count'] = tsl2561_data[
                    'door_open_count']
                tsl2561_data['door_open_count'] = 0

            if tsl2561_data['lux'] > 10:
                tsl2561_data['door_open'] = True

                if unix_time_int < (tsl2561_data['last_door_open_timestamp'] +
                                    3):
                    tsl2561_data['door_open_count'] += 1
                else:
                    tsl2561_data['door_open_count'] = 1

                tsl2561_data['last_door_open'] = now_iso_stamp
                tsl2561_data['last_door_open_timestamp'] = unix_time_int

                if tsl2561_data['door_open_count'] > 5 and not tsl2561_data[
                        'door_open_warn'] and config['sensors'][
                            'tsl2561_warn_enable']:
                    logger.critical(
                        '5 lux measurements exceed door open conditions!')
                    tsl2561_data['door_open_warn'] = True
                    if not system_state['maintenance_mode']:
                        human_datetime = datetime.now().strftime(
                            '%d/%m/%Y %H:%M')
                        warn_sms_text = human_datetime + ': Door open event detected!'
                        send_sms(config['sensors']['tsl2561_sms_list'],
                                 warn_sms_text)
                    else:
                        logger.warning(
                            "System in maintenance mode, no warning SMS sent")

        except Exception as e:
            # Error has occurred, log it
            logger.error("Failed to get data from TSL2561: " + str(e))

    else:
        logger.warn('Request to read TSL2561 data, but not enabled in config')
Exemplo n.º 6
0
def relay_reminder_timeout():
    # Get current ISO timestamp for JSON and unix timestamp for timeout
    human_datetime = datetime.now().strftime("%d/%m/%Y %H:%M")
    unix_time_int = int(time.time())
    now_iso_stamp = datetime.now().replace(microsecond=0).isoformat()
    # For every relay in the timestamp dict
    for relay_id in relay_state:
        try:
            # If reminder_on is set and the relay is on
            if config['relay'][relay_id]['reminder_on'] and relay_state[
                    relay_id]['state']:
                # Check if we've already sent a reminder
                if not relay_state[relay_id]['reminder_active']:
                    # Check if the timeout has expired
                    if (unix_time_int >=
                            relay_state[relay_id]['state_change_timestamp'] +
                            config['relay'][relay_id]['reminder_on']):
                        logger.warning("Sending SMS reminder to turn " +
                                       config['relay'][relay_id]['name'] +
                                       " off")
                        sms_text = human_datetime + ": " + config['relay'][
                            relay_id]['reminder_on_sms_text']
                        send_sms(
                            config['relay'][relay_id]['reminder_sms_list'],
                            sms_text)
                        relay_state[relay_id]['reminder_sent'] = True
                        relay_state[relay_id]['reminder_time'] = now_iso_stamp

            # If reminder_off is set and the relay is off
            if config['relay'][relay_id][
                    'reminder_off'] and not relay_state[relay_id]['state']:
                # Check if we've already sent a reminder
                if not relay_state[relay_id]['reminder_sent']:
                    # Check if the timeout has expired
                    if (unix_time_int >=
                            relay_state[relay_id]['state_change_timestamp'] +
                            config['relay'][relay_id]['reminder_off']):
                        logger.warning("Sending SMS reminder to turn " +
                                       config['relay'][relay_id]['name'] +
                                       " on")
                        sms_text = human_datetime + ": " + config['relay'][
                            relay_id]['reminder_off_sms_text']
                        send_sms(
                            config['relay'][relay_id]['reminder_sms_list'],
                            sms_text)
                        relay_state[relay_id]['reminder_sent'] = True
                        relay_state[relay_id]['reminder_time'] = now_iso_stamp

        except Exception as e:
            # Log an error if one has occurred
            logger.error("Failed to check reminder status for " +
                         config['relay'][relay_id]['name'] + "relay: " +
                         str(e))
Exemplo n.º 7
0
def phoneNumberVerification(phoneNumber):
    print("---We send code to your phoneNumber---")
    codeCollection = db["codes"]
    code = str(random.randint(10000, 99999))
    d = {"code": code}
    codeCollection.insert_one(d)
    send_sms(phoneNumber, code)
    codes = codeCollection.find({"code": code})
    inputCode = input('code:')
    for i in codes:
        if inputCode == i["code"]:
            codeCollection.remove(d)
            return True
    codeCollection.remove(d)
    return False
Exemplo n.º 8
0
def send_express_create_sms(ad_id, phone, link_code, password=None):
    if password is not None:
        message = "Vashe ob'yablenie dobavleno na sait Riom.kg\n"\
                  f"Login: {phone}\n"\
                  f"Parol: {password}\n"\
                  f"Dopolnite ego po ssylke\n"\
                  f"https://riom.kg/create_express/{ad_id}/{link_code}/"
    else:
        message = "Vashe ob'yablenie dobavleno na sait Riom.kg\n" \
                  f"Dopolnite ego po ssylke\n" \
                  f"https://riom.kg/create_express/{ad_id}/{link_code}/"
    try:
        send_sms(phone, message)
    except:
        pass
Exemplo n.º 9
0
    def antarctica_analysis(self, csv_file):
        try:
            all_db_patients = self.select_all_tasks("patients")
            with open(csv_file, encoding="utf-8-sig") as an_file:
                all_rows = csv.reader(an_file, delimiter=';')
                for one_row in all_rows:
                    #print(one_row)
                    for one_patient in all_db_patients:
                        #print(type(one_row[2]), one_row[2], type(one_patient[3]), one_patient[3])
                        if one_row[0] != 'id':
                            if one_row[2] == str(
                                    one_patient[3]
                            ):  #porównuje pesele aby dostać id
                                one_row[4] = str(
                                    datetime.strptime(one_row[4],
                                                      "%d.%m.%Y %H:%M"))
                                if one_row[5] == 'T':
                                    one_row[5] = 'True'
                                else:
                                    one_row[5] = 'False'
                                self.insert_analysis(
                                    probe_number=one_row[1],
                                    analysis_id=one_row[3],
                                    patient_id=one_patient[
                                        0],  #odnosimy się do bazy danych do tablicy patients i wyciągamy id
                                    collection_time=one_row[4],
                                    result=one_row[5])
                                if one_row[5] == "False":
                                    week_days = [
                                        "Poniedzialek", "Wtorek", "Środa",
                                        "Czwartek", "Piątek", "Sobota",
                                        "Niedziela"
                                    ]
                                    obj_datetime = datetime.strptime(
                                        one_row[6], "%d.%m.%Y %H:%M")
                                    week_number = obj_datetime.weekday()
                                    msg = f'Dzień dobry, ' \
                                          f'Zapraszamy na wizytę kontrolną w {week_days[week_number]} dokładna data ' \
                                          f'{one_row[6]} o godzinie {obj_datetime.time()}'

                                    send_sms(msg, one_row[7])

        except Exception as e:
            logger.error("Antarctica analysis failed ", exc_info=True)
Exemplo n.º 10
0
    # 读取配置项
    ACCESS_KEY_ID = config['aliyun_sms']['ACCESS_KEY_ID']
    ACCESS_KEY_SECRET = config['aliyun_sms']['ACCESS_KEY_SECRET']
    SIGN_NAME = config['sms']['SIGN_NAME']
    TEMPLATE_CODE = config['sms']['TEMPLATE_CODE']
    EXCEL_PATH = config['sms']['EXCEL_PATH']
    return {'ACCESS_KEY_ID': ACCESS_KEY_ID, 'ACCESS_KEY_SECRET': ACCESS_KEY_SECRET,
            'SIGN_NAME': SIGN_NAME, 'TEMPLATE_CODE': TEMPLATE_CODE, 'EXCEL_PATH': EXCEL_PATH
            }


def parseExcel(excel_path):
    """
    解析Excel文件,读取第一列的手机号码
    """
    excelData = pd.read_excel(excel_path)
    return excelData


if __name__ == "__main__":
    configs = initializeConfigs('config.ini')
    excelData = parseExcel(configs['EXCEL_PATH'])
    phoneList = excelData['phone']
    init_sms_sender(configs['ACCESS_KEY_ID'], configs['ACCESS_KEY_SECRET'])
    for phoneNum in phoneList:
        __business_id = uuid.uuid1()
        params = "{\"mtname\":\"姜美纹绣\",\"submittime\":\"2018-05-26 00:25\"}"
        print("sending sms to {phoneNum}".format(phoneNum=phoneNum))
        result = send_sms(__business_id, phoneNum, configs['SIGN_NAME'], configs['TEMPLATE_CODE'], params)
        print("send result of {phoneNum} is {result}".format(phoneNum=phoneNum, result=result))
Exemplo n.º 11
0
def relay_auto_timeout():
    # Get current unix timestamp
    unix_time_int = int(time.time())
    human_datetime = datetime.now().strftime("%d/%m/%Y %H:%M")
    # For every relay in the timestamp dict
    for relay_id in relay_state:
        try:
            # If auto_off is set and the relay is on
            if config['relay'][relay_id]['auto_off'] and relay_state[relay_id][
                    'state']:
                # Check if the timeout has expired
                if (unix_time_int >=
                        relay_state[relay_id]['state_change_timestamp'] +
                        config['relay'][relay_id]['auto_off']):
                    logger.warning("Auto " +
                                   config['relay'][relay_id]['name'] + " off")
                    # If we've reminded via SMS, warn via SMS AFTER we change the relay
                    if relay_state[relay_id]['reminder_sent'] and config[
                            'relay'][relay_id][
                                'reminder_on'] and not relay_state[relay_id][
                                    'auto_off_sent']:
                        set_relay_state(relay_id, False)
                        sms_text = human_datetime + ": " + config['relay'][
                            relay_id]['name'].capitalize(
                            ) + ' has now been automatically turned off'
                        send_sms(
                            config['relay'][relay_id]['reminder_sms_list'],
                            sms_text)
                        relay_state[relay_id]['auto_off_sent'] = True
                    # Otherwise, just change the state of the relay
                    else:
                        set_relay_state(relay_id, False)

            # If auto_on is set and the relay is off
            if config['relay'][relay_id][
                    'auto_on'] and not relay_state[relay_id]['state']:
                # If check if the timeout has expired
                if (unix_time_int >=
                        relay_state[relay_id]['state_change_timestamp'] +
                        config['relay'][relay_id]['auto_on']):
                    logger.warning(": Auto " +
                                   config['relay'][relay_id]['name'] + " on")
                    # If we've reminded via SMS, warn via SMS AFTER we change the relay
                    if relay_state[relay_id]['reminder_sent'] and config[
                            'relay'][relay_id][
                                'reminder_off'] and not relay_state[relay_id][
                                    'auto_on_sent']:
                        set_relay_state(relay_id, True)
                        sms_text = human_datetime + ": " + config['relay'][
                            relay_id]['name'].capitalize(
                            ) + ' has now been automatically turned on'
                        send_sms(
                            config['relay'][relay_id]['reminder_sms_list'],
                            sms_text)
                        relay_state[relay_id]['auto_on_sent'] = True
                    # Otherwise, just change the state of the relay
                    else:
                        set_relay_state(relay_id, True)

        except Exception as e:
            # Log an error if one has occurred
            logger.error("Failed to auto switch " +
                         config['relay'][relay_id]['name'] + " relay: " +
                         str(e))
Exemplo n.º 12
0
def check_river():

    try:
        resp = requests.get(config['river']['api_url'])
        # If the timestamps have changed, we have a new reading, so process it
        if resp.json()['items']['latestReading'][
                'dateTime'][:-1] != river_data['timestamp']:
            river_data['last']['timestamp'] = river_data['timestamp']
            river_data['timestamp'] = resp.json(
            )['items']['latestReading']['dateTime'][:-1]

            river_data['last']['level'] = river_data['level']
            river_data['level'] = resp.json(
            )['items']['latestReading']['value']

            if river_data['level'] > river_data['last']['level']:
                river_data['status'] = 'rising'
            elif river_data['level'] < river_data['last']['level']:
                river_data['status'] = 'falling'
            else:
                river_data['status'] = 'steady'

            human_datetime = datetime.now().strftime('%d/%m/%Y %H:%M')
            now_iso_stamp = datetime.now().replace(microsecond=0).isoformat()
            if river_data['level'] > river_data['last']['high_level']:
                river_data['last']['high_level'] = river_data['level']
                river_data['last']['high'] = river_data['timestamp']

        if config['river']['warn_enable']:
            if river_data['level'] > river_data['high_warn']:
                if not river_data['warning_active'] or (
                        river_data['warning_active'] and river_data['level'] >
                    (river_data['last']['warn_level'] + 0.1)):
                    if not river_data['warning_active']:
                        logger.critical('River level high! ' +
                                        str(river_data['level']) +
                                        'm. Sending alert SMS!')
                        warn_sms_text = human_datetime + ': River level high! ' + str(
                            river_data['level']) + 'm'
                    else:
                        logger.critical('River level rising! ' +
                                        str(river_data['level']) +
                                        'm. Sending alert SMS!')
                        warn_sms_text = human_datetime + ': River level rising! ' + str(
                            river_data['level']) + 'm'
                    send_sms(config['river']['warn_sms_list'], warn_sms_text)
                    logger.critical('Alerts sent')
                    river_data['last']['warn_level'] = river_data['level']
                    river_data['last']['high_level'] = river_data['level']
                    river_data['warning_active'] = True
                    river_data['last']['warn'] = now_iso_stamp

            if river_data['warning_active'] and river_data[
                    'level'] < river_data['high']:
                logger.warning('River returned to normal levels')
                normal_sms_text = human_datetime + ': River level returned to normal. ' + str(
                    river_data['level']) + 'm'
                send_sms(config['river']['warn_sms_list'], normal_sms_text)
                river_data['warning_active'] = False
        pass

    except Exception as e:
        logger.error('River task failed: ' + str(e))
        pass
Exemplo n.º 13
0
def check_batt_voltage():

    last_batt_warning_stage = system_state['batt_warning_stage']
    human_datetime = datetime.now().strftime("%d/%m/%Y %H:%M")
    now_iso_stamp = datetime.now().replace(microsecond=0).isoformat()
    unix_time_int = int(time.time())
    warn_sms_text = ""
    last_batt_state = system_state['batt_state']

    if not global_vars.mppt_data["batt"].get("v"):
        logger.warning("MPPT data not yet populated!")
        return

    try:
        # First, a plausibility check...
        if global_vars.mppt_data["batt"]["v"] > 1.0 :
            system_state['batt_state'] = True
            # Is the battery charging or discharging?
            if global_vars.mppt_data["batt"]["cs"] == 0:
                # cs = 0 means the battery is not being charged
                if global_vars.mppt_data["batt"]["v"] < config['system']['batt_voltage_critical']:
                    new_batt_warning_stage = 3
                elif global_vars.mppt_data["batt"]["v"] < config['system']['batt_voltage_very_low']:
                    new_batt_warning_stage = 2
                elif global_vars.mppt_data["batt"]["v"] < config['system']['batt_voltage_low']:
                    new_batt_warning_stage = 1
                else:
                    new_batt_warning_stage = 0

                # Battery warning states should 'latch' upwards when discharging
                if new_batt_warning_stage > last_batt_warning_stage:
                    system_state['batt_warning_stage'] = new_batt_warning_stage

            else:
                if global_vars.mppt_data["batt"]["v"] > config['system']['batt_voltage_overvoltage']:
                    new_batt_warning_stage = -1
                elif global_vars.mppt_data["batt"]["v"] > config['system']['batt_voltage_normal']:
                    new_batt_warning_stage = 0
                elif global_vars.mppt_data["batt"]["v"] > config['system']['batt_voltage_low']:
                    new_batt_warning_stage = 1
                elif global_vars.mppt_data["batt"]["v"] > config['system']['batt_voltage_very_low']:
                    new_batt_warning_stage = 2
                else:
                    new_batt_warning_stage = 3

                # Latch downwards when charging, or battery returns to normal
                if new_batt_warning_stage < last_batt_warning_stage or new_batt_warning_stage == 0:
                    system_state['batt_warning_stage'] = new_batt_warning_stage

            if system_state['batt_warning_stage'] > last_batt_warning_stage and system_state['batt_warning_stage'] > 0:
                if system_state['batt_warning_stage'] == 1:
                    warn_sms_text = human_datetime + ": Battery voltage low! "+str(global_vars.mppt_data["batt"]["v"])+"V"
                    logger.warning("Battery voltage low! Current voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V. Sending alert SMS")
                elif system_state['batt_warning_stage'] == 2:
                    warn_sms_text = human_datetime + ": Battery voltage very low! "+str(global_vars.mppt_data["batt"]["v"])+"V"
                    logger.warning("Battery voltage very low! Current voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V. Sending alert SMS")
                elif system_state['batt_warning_stage'] == 3:
                    warn_sms_text = human_datetime + ": Battery voltage CRITICAL! "+str(global_vars.mppt_data["batt"]["v"])+"V"
                    logger.critical("Battery voltage critical! Current voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V. Sending alert SMS")
            elif system_state['batt_warning_stage'] < last_batt_warning_stage and system_state['batt_warning_stage'] > 0:
                warn_sms_text = human_datetime + ": Battery recharging: " + str(global_vars.mppt_data["batt"]["v"]) + "V"
                logger.info("Battery recharging: " + str(global_vars.mppt_data["batt"]["v"]) + "V. Sending notification SMS")
            elif ( system_state['batt_warning_stage'] != last_batt_warning_stage ) and system_state['batt_warning_stage'] == 0:
                warn_sms_text = human_datetime + ": Battery voltage returning to normal: " + str(global_vars.mppt_data["batt"]["v"]) + "V"
                logger.info("Battery voltage returning to normal: " + str(global_vars.mppt_data["batt"]["v"]) + "V. Sending notification SMS")
            elif ( system_state['batt_warning_stage'] != last_batt_warning_stage ) and system_state['batt_warning_stage'] == -1:
                warn_sms_text = human_datetime + ": Battery in overvoltage condition! Current voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V"
                logger.warning("Battery in overvoltage condition! Current voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V. Sending alert SMS")

            if (warn_sms_text and ( unix_time_int > system_state['batt_warning_sent_time'] + config['system']['batt_warning_interval'] )) or (warn_sms_text and system_state['batt_warning_stage'] == 0):
                if ( system_state['batt_voltage_sent'] - 0.1 < global_vars.mppt_data["batt"]["v"] ) or ( system_state['batt_voltage_sent'] + 0.1 > global_vars.mppt_data["batt"]["v"] ) or system_state['batt_warning_stage'] == 0:
                    system_state['batt_voltage_sent'] = global_vars.mppt_data["batt"]["v"]
                    system_state['batt_warning_sent_time'] = unix_time_int
                    send_sms(config['bmv']['warn_sms_list'], warn_sms_text)
            global_vars.mppt_data["batt"]["state"] = system_state['batt_warning_stage']
            global_vars.mppt_data["batt"]["state_text"] = batt_warning_stage_text[system_state['batt_warning_stage']]

# Battery disconnected?
        else:
            system_state['batt_state'] = False

            if not system_state['batt_state'] and ( unix_time_int > system_state['batt_state_sent_time'] + config['system']['batt_warning_interval'] ):
                warn_sms_text = human_datetime + ": Battery disconnected! Battery voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V"
                logger.critical("Battery disconnected! Battery voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V. Sending alert SMS")

            global_vars.mppt_data["batt"]["state"] = 4
            global_vars.mppt_data["batt"]["state_text"] = batt_warning_stage_text[system_state['batt_warning_stage']]

        if system_state['batt_state'] != last_batt_state or ( warn_sms_text and not system_state['batt_state'] ):
            if system_state['batt_state']:
                warn_sms_text = human_datetime + ": Battery now reconnected. Battery voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V"
                logger.warning("Battery now reconnected. Battery voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V. Sending alert SMS")
            else:
                warn_sms_text = human_datetime + ": Battery disconnected! Battery voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V"
                logger.critical("Battery disconnected! Battery voltage: " + str(global_vars.mppt_data["batt"]["v"]) + "V. Sending alert SMS")
            system_state['batt_state_sent_time'] = unix_time_int
            send_sms(config['bmv']['warn_sms_list'], warn_sms_text)

    except Exception as e:
        logger.error("MPPT battery voltage check failed: " + str(e))
Exemplo n.º 14
0
def send_sms_account_verification(phone, code):
    message = f'Код активации: {code}'
    try:
        send_sms(phone, message)
    except:
        pass