コード例 #1
0
ファイル: accessdb.py プロジェクト: lamhaison/Raspi-WebServer
def insert_history_device_status(dev, from_status, to_status):
    """
    status device from on to off
    :param dev: device object
    :param from_status: ex: True: on
    :param to_status: False: off
    :return: True if success, False is not success
    """
    try:
        now_time = apitimer.get_now_time_without_second()
        history_status = DeviceHistory(dev=dev, time=now_time, from_status=from_status, to_status=to_status)
        history_status.save()
        return True
    except Exception as ex:
        logger.error(ex)
        return False
コード例 #2
0
ファイル: accessdb.py プロジェクト: lamhaison/Raspi-WebServer
def insert_history_device_status_using_device_key(dev_key, from_status, to_status):
    """
    status device from on to off
    :param dev: device key
    :param from_status: ex: True: on
    :param to_status: False: off
    :return: True if success, False is not success
    """
    try:
        now_time = apitimer.get_now_time_without_second()
        dev = get_device_from_pk(dev_key)
        if dev is None:
            return False

        history_status = DeviceHistory(dev=dev, time=now_time, from_status=from_status, to_status=to_status)
        history_status.save()
    except Exception as ex:
        logger.error(ex)
        return False