示例#1
0
def stop_flame():
    try:

        ctxt = Context.objects.get()
        if not ctxt.flame:
            logger.debug("Not stopping flame, because its already stopped")
            return
        try:
            anotate_gradient_end()
        except Exception as eee:
            logger.error("Cannot anotate gradient end, error: %s" % eee)
            pass

        pl_switch(
            settings.HEATER_PROTOCOL,
            settings.HEATER_DID,
            "off",
            settings.HEATER_API,
            settings.HEATER_USERNAME,
            settings.HEATER_PASSWORD)

        ctxt.flame = False
        ctxt.save()

        logger.debug("Flame stopped")
        log_flame_stats(False)
        #print "%s flame stopped" % strftime("%d.%m.%Y %H:%M:%S", localtime())
    except Exception as et:
        logger.error(et)
示例#2
0
def start_flame():

    try:
        ctxt = Context.objects.get()
        if ctxt.flame:
            logger.debug("Not starting flame, because its already started")
            return
        try:
            anotate_gradient_start()
        except Exception as eee:
            logger.error("Cannot anotate gradient start, error: %s" % eee)
            pass

        pl_switch(
            settings.HEATER_PROTOCOL,
            settings.HEATER_DID,
            "on",
            settings.HEATER_API,
            settings.HEATER_USERNAME,
            settings.HEATER_PASSWORD)

        ctxt.flame = True
        ctxt.save()

        logger.debug("Flame started")
        log_flame_stats(True)
    except Exception as et:
        logger.error(et)
示例#3
0
def pl_switch(request, protocol, did, value):

    c = get_object_or_404(Control, protocol=protocol, did=did)

    try:
        cmds.pl_switch(protocol, did, value, settings.HA_SERVER,
                       settings.HA_USERNAME, settings.HA_PASSWORD)
        return HttpResponse("OK")
    except Exception, err:
        return HttpResponseServerError(err)
示例#4
0
def start_flame():
    try:
        cmds.pl_switch(
            HEATER_PROTOCOL,
            HEATER_DID,
            "on",
            HEATER_API,
            HEATER_USERNAME,
            HEATER_PASSWORD)
    except Exception:
        return False
    return True
示例#5
0
def salon_off(mo=None):
    try:
        pl_switch(
            "X10",
            settings.SALON_DID,
            "off",
            settings.HEATER_API,
            settings.HEATER_USERNAME,
            settings.HEATER_PASSWORD)
        logger.debug("Salon bajado")
    except Exception as ex:
        logger.error(ex)
示例#6
0
def pasillo_off(mo=None):
    try:
        pl_switch(
            settings.HEATER_PROTOCOL,
            settings.PASILLO_DID,
            "off",
            settings.HEATER_API,
            settings.HEATER_USERNAME,
            settings.HEATER_PASSWORD)
        logger.debug("Pasillo bajado")
    except Exception as ex:
        logger.error(ex)
示例#7
0
def luz_pasillo_on(mo=None):
    try:
        pl_switch(
            "X10",
            settings.LUZ_PASILLO_DID,
            "on",
            settings.HEATER_API,
            settings.HEATER_USERNAME,
            settings.HEATER_PASSWORD)
        logger.debug("Luz del pasillo encendida")
    except Exception as ex:
        logger.error(ex)
示例#8
0
def luz_descansillo_on(mo=None):
    try:
        pl_switch(
            settings.LUZ_DESCANSILLO_PROTOCOL,
            settings.LUZ_DESCANSILLO_DID,
            "on",
            settings.HEATER_API,
            settings.HEATER_USERNAME,
            settings.HEATER_PASSWORD)
        logger.debug("Luz del descansillo encendida")
    except Exception as ex:
        logger.error(ex)
示例#9
0
def cuarto_este_on(mo=None):
    try:
        pl_switch(
            "X10",
            settings.CUARTO_ESTE_DID,
            "on",
            settings.HEATER_API,
            settings.HEATER_USERNAME,
            settings.HEATER_PASSWORD)
        logger.debug("Cuarto este subido")
    except Exception as ex:
        logger.error(ex)
示例#10
0
def pasillo_on(mo=None):
    try:
        pl_switch(
            "X10",
            settings.PASILLO_DID,
            "on",
            settings.HEATER_API,
            settings.HEATER_USERNAME,
            settings.HEATER_PASSWORD)
        logger.debug("Pasillo subido")
    except Exception as ex:
        logger.error(ex)
示例#11
0
def cuarto_oeste_off(mo=None):

    try:
        pl_switch(
            "X10",
            settings.CUARTO_OESTE_DID,
            "off",
            settings.HEATER_API,
            settings.HEATER_USERNAME,
            settings.HEATER_PASSWORD)
        logger.debug("Cuarto oeste bajado")
    except Exception as ex:
        logger.error(ex)
示例#12
0
def pl_switch(request, protocol, did, value):

    c = get_object_or_404(Control, protocol=protocol, did=did)

    try:
        cmds.pl_switch(
            protocol,
            did,
            value,
            settings.HA_SERVER,
            settings.HA_USERNAME,
            settings.HA_PASSWORD)
        return HttpResponse("OK")
    except Exception, err:
        return HttpResponseServerError(err)