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)
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)
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)
def start_flame(): try: cmds.pl_switch( HEATER_PROTOCOL, HEATER_DID, "on", HEATER_API, HEATER_USERNAME, HEATER_PASSWORD) except Exception: return False return True
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)
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)
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)
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)
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)
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)
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)
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)