Example #1
0
 def Adjust(self, state):
     with (self.m_lock):
         self.m_currentCompare = self.m_currentCompare + state
         if (SSRC.PWM.LIMIT_MIN > self.m_currentCompare):
             self.m_currentCompare = SSRC.PWM.LIMIT_MIN
         if (SSRC.PWM.LIMIT_MAX < self.m_currentCompare):
             self.m_currentCompare = SSRC.PWM.LIMIT_MAX
     self.m_threadCondition.acquire()
     self.m_threadCondition.notify()
     self.m_threadCondition.release()
     kasaObj = Proxy(("PYRO:{}@{}:{}").format(KASA.DAEMON.PYRO_OBJECT_ID,
                                              KASA.DAEMON.PYRO_HOST,
                                              KASA.DAEMON.PYRO_PORT))
     kasaObj.TurnPlugOn()
Example #2
0
                    help='Set log destination (file), default: \'' + logfile +
                    '\'')

options = parser.parse_args()

SetupLog(options.log_level, options.log_destination)
if (0 < len(vars(options))):
    if (options.turn_on and options.turn_off):
        print("Cannot turn on and off at the same time")
        sys.exit(1)
    kasaObj = Proxy(
        ("PYRO:{}@{}:{}").format(KASA.DAEMON.PYRO_OBJECT_ID,
                                 KASA.DAEMON.PYRO_HOST, KASA.DAEMON.PYRO_PORT))
    try:
        if (options.turn_on):
            kasaObj.TurnPlugOn()
        if (options.turn_off):
            kasaObj.TurnPlugOff()
        if (options.status):
            if (kasaObj.GetActive()):
                print("on")
            else:
                print("off")
        if (options.shutdown):
            kasaObj.Exit()
    except:
        logging.error(
            "Exception while attempting to contact Kasa - may be a temporary issue"
        )
    finally:
        # Failure to communicate can cause an exception