Beispiel #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)
Beispiel #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"))
Beispiel #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"])
Beispiel #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)
Beispiel #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
Beispiel #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)
Beispiel #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)
Beispiel #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"]
Beispiel #9
0
 def getTimeOn(self):
     return plugs.send(self.ip, commands["info"])["system"]["get_sysinfo"]["children"][self.location]["on_time"]
Beispiel #10
0
 def updateState(self):
     self.state = plugs.send(self.ip, commands["info"])["system"]["get_sysinfo"]["children"][self.location]["state"]
     return self.state
Beispiel #11
0
 def getTimeOn(self):
     return plugs.send(self.ip,
                       commands["info"])["system"]["get_sysinfo"]["on_time"]
Beispiel #12
0
 def updateState(self):
     self.state = plugs.send(
         self.ip, commands["info"])["system"]["get_sysinfo"]["relay_state"]
     return self.state