當前位置: 首頁>>代碼示例>>Python>>正文


Python Status.set_leaving方法代碼示例

本文整理匯總了Python中status.Status.set_leaving方法的典型用法代碼示例。如果您正苦於以下問題:Python Status.set_leaving方法的具體用法?Python Status.set_leaving怎麽用?Python Status.set_leaving使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在status.Status的用法示例。


在下文中一共展示了Status.set_leaving方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Status

# 需要導入模塊: from status import Status [as 別名]
# 或者: from status.Status import set_leaving [as 別名]
for MAC_ADDRESS in phone_macs:
    logger.log(logging.DEBUG, 'Registered mac address as phone: ' + MAC_ADDRESS)

status = Status()

while True:
    try:
        time.sleep(15)

        if datetime.datetime.now().hour > wake_time:
            if check_for_mac_addresses(phone_macs):
                if status.is_away():
                    logger.log(logging.DEBUG, 'Lights powered up and set to home mode')
                    power_lights('on')
                    status.set_home()
                elif status.is_leaving():
                    logger.log(logging.DEBUG, 'Returned before full shutoff delay time, set back to home mode')
                    status.set_home()
            else:
                if status.is_home():
                    logger.log(logging.DEBUG, 'Initiated leaving protocol, countdown to shutdown started')
                    status.set_leaving()
                elif status.is_leaving() and abs((status.departure_time - datetime.datetime.now()).total_seconds()) > shutoff_delay:
                    logger.log(logging.DEBUG, 'Lights powered down and went to away mode')
                    power_lights('off')
                    status.set_away()

    except Exception as e:
        logger.error(e)
開發者ID:gregaz,項目名稱:auto_lights,代碼行數:31,代碼來源:auto_lights.py


注:本文中的status.Status.set_leaving方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。