From 4e44f52a5899b8ee956ffcaff4ea37e6aadd900d Mon Sep 17 00:00:00 2001 From: Stuart Rench Date: Wed, 8 Apr 2020 09:50:40 -0500 Subject: [PATCH] Utilizes the `CCL` command for cycle. This was done to prevent cases when, for one of many reasons, the device receives the OFF, but not the ON command. This has been resulting in outlets being left in the OFF position. --- dlipower/dlipower.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/dlipower/dlipower.py b/dlipower/dlipower.py index f0182a5..c1ce4d9 100755 --- a/dlipower/dlipower.py +++ b/dlipower/dlipower.py @@ -479,15 +479,12 @@ def on(self, outlet=0): def cycle(self, outlet=0): """ Cycle power to an outlet - False = Power off Success - True = Power off Fail - Note, does not return any status info about the power on part of - the operation by design + Note: If an outlet is powered off, it will turn it on """ - if self.off(outlet): - return True - time.sleep(self.cycletime) - self.on(outlet) + if self.status(outlet) == 'OFF': + self.on(outlet) + else: + self.geturl(url='outlet?%d=CCL' % self.determine_outlet(outlet)) return False def statuslist(self):