From 2aa225ca87faf9e74c79ca7bdb78c672a175a277 Mon Sep 17 00:00:00 2001 From: Justin Tervala Date: Thu, 25 May 2017 16:58:23 -0400 Subject: [PATCH] LifxTest workflow fixed --- apps/Lifx/main.py | 10 +++++++--- data/workflows/LifxTest.workflow | 21 ++++++++++++++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/apps/Lifx/main.py b/apps/Lifx/main.py index a4df58fa0..07a531cda 100644 --- a/apps/Lifx/main.py +++ b/apps/Lifx/main.py @@ -3,7 +3,7 @@ import requests import json logger = logging.getLogger(__name__) - +import time class Main(App): """ @@ -42,6 +42,7 @@ def set_state(self, args={}): "duration": args['duration'](), "infrared": args['infrared']()/1000.} response = requests.put(self.__api_url('all/state'.format(self.name)), data=payload, headers=self.headers) + time.sleep(int(args['duration']())) return json.loads(response.text) def toggle_power(self, args={}): @@ -51,6 +52,7 @@ def toggle_power(self, args={}): """ payload = {"duration": args['duration']()} response = requests.post(self.__api_url('all/toggle'.format(self.name)), data=payload, headers=self.headers) + time.sleep(int(args['duration']())) return json.loads(response.text) def breathe_effect(self, args={}): @@ -75,6 +77,7 @@ def breathe_effect(self, args={}): response = requests.post(self.__api_url('all/effects/breathe'), data=payload, headers=self.headers) + time.sleep(int(args['period']())*int(args['cycles']())) return json.loads(response.text) def pulse_effect(self, args={}): @@ -82,7 +85,7 @@ def pulse_effect(self, args={}): Quickly flashes between two colors color: color to use for the breathe effect from_color: color to start the breathe effect from - period: Time in seconds between cycles + period: Time in milliseconds between cycles cycles: Number of times to repeat the effect persist: If false set teh light back to its previous value when effect ends. Else leave at last effect power_on: If true, turn on the light if not already on @@ -93,7 +96,8 @@ def pulse_effect(self, args={}): "cycles": args['cycles'](), "persist": args['persist'](), "power_on": args['power_on']()} - response = requests.post(self.__api_url('all/effects/pulse'.format(self.name)), + response = requests.post(self.__api_url('all/effects/pulse'), data=payload, headers=self.headers) + time.sleep(int(args['period']()) * int(args['cycles']())) return json.loads(response.text) diff --git a/data/workflows/LifxTest.workflow b/data/workflows/LifxTest.workflow index 37d5fb912..a0456d14c 100644 --- a/data/workflows/LifxTest.workflow +++ b/data/workflows/LifxTest.workflow @@ -25,11 +25,29 @@ red 1 5 + false + blue + 5 + + + + + 3 + Lifx + pulse_effect + LIFX 12cf1f + + 406.540089357 + 333.60458204 + + + true + red + 1 true blue 10 - 2 @@ -43,6 +61,7 @@ 2 +