Ejemplo n.º 1
0
 def off(self, ip):
     if self.state == 1:
         currRuntime = plugs.send(self.ip, commands["info"])["system"]["get_sysinfo"]["children"][self.location]["on_time"]
         if plugs.send(self.ip, generateCMD("off"))["system"]["set_relay_state"]["err_code"] == 0:
             print(cTime.nowf() + " - ACTION: HeatPad Off")
             self.state = 0
             self.pastRuntime += int(currRuntime)
             return 0
         else:
             print(cTime.nowf() + " - ALERT: Failed to turn off HeatPad", file=sys.stderr)
Ejemplo n.º 2
0
    def timeReset(self):
        plugJSON = plugs.send(self.ip, commands["info"])["system"]["get_sysinfo"]["children"][self.location]
        currState = plugJSON["state"]

        if currState == 1:
            plugs.send(self.ip, generateCMD("off"))

        self.pastRuntime = 0
        self.maxOn = False

        if currState == 1:
            plugs.send(self.ip, generateCMD("on"))
Ejemplo n.º 3
0
    def timeReset(self):
        plugJSON = plugs.send(self.ip,
                              commands["info"])["system"]["get_sysinfo"]
        currState = plugJSON["relay_state"]

        if currState == 1:
            plugs.send(self.ip, commands["off"])

        self.pastRuntime = 0
        self.maxOn = False

        if currState == 1:
            plugs.send(self.ip, commands["on"])
Ejemplo n.º 4
0
 def off(self, ip):
     if self.state == 1:
         currRuntime = plugs.send(
             self.ip, commands["info"])["system"]["get_sysinfo"]["on_time"]
         if plugs.send(self.ip, commands["off"]
                       )["system"]["set_relay_state"]["err_code"] == 0:
             print(cTime.nowf() + " - ACTION: Lights Off")
             self.state = 0
             self.pastRuntime += int(currRuntime)
             return 0
         else:
             print(cTime.nowf() + " - ALERT: Failed to turn lights off",
                   file=sys.stderr)
Ejemplo n.º 5
0
 def __init__(self, ip):
     self.ip = ip
     plugJSON = plugs.send(self.ip,
                           commands["info"])["system"]["get_sysinfo"]
     self.state = plugJSON["relay_state"]
     self.pastRuntime = int(plugJSON["on_time"])
     self.maxOn = False
Ejemplo n.º 6
0
	def on(self, ip):
        if self.state == 0:
            if plugs.send(self.ip, generateCMD("on"))["system"]["set_relay_state"]["err_code"] == 0:
                print(cTime.nowf() + " - ACTION: HeatPad On")
                self.state = 1 
                return 0
            else:
                print(cTime.nowf() + " - ALERT: Failed to turn on HeatPad", file=sys.stderr)
Ejemplo n.º 7
0
 def on(self, ip):
     if self.state == 0:
         if plugs.send(self.ip, commands["on"]
                       )["system"]["set_relay_state"]["err_code"] == 0:
             print(cTime.nowf() + " - ACTION: Lights On")
             self.state = 1
             return 0
         else:
             print(cTime.nowf() + " - ALERT: Failed to turn lights on",
                   file=sys.stderr)
Ejemplo n.º 8
0
	def __init__(self, ip, plugID):
		self.ip = ip
		self.id = plugID

		plugJSON = plugs.send(self.ip, commands["info"])["system"]["get_sysinfo"]

		self.location = None
		for i in plugJSON["children"]:
			if i["id"] == plugID:
				self.location = i
				break

		if self.location == None
			print(cTime.nowf() + " - ALERT: id number " + self.id + " not found on device" + ip, file=sys.stderr)
			exit()

		self.state = plugJSON["children"][self.location]["state"]
Ejemplo n.º 9
0
 def getTimeOn(self):
     return plugs.send(self.ip, commands["info"])["system"]["get_sysinfo"]["children"][self.location]["on_time"]
Ejemplo n.º 10
0
 def updateState(self):
     self.state = plugs.send(self.ip, commands["info"])["system"]["get_sysinfo"]["children"][self.location]["state"]
     return self.state
Ejemplo n.º 11
0
 def getTimeOn(self):
     return plugs.send(self.ip,
                       commands["info"])["system"]["get_sysinfo"]["on_time"]
Ejemplo n.º 12
0
 def updateState(self):
     self.state = plugs.send(
         self.ip, commands["info"])["system"]["get_sysinfo"]["relay_state"]
     return self.state