Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
LifxTest workflow fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Tervala authored and Justin Tervala committed May 25, 2017
1 parent 94ce740 commit 2aa225c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
10 changes: 7 additions & 3 deletions apps/Lifx/main.py
Expand Up @@ -3,7 +3,7 @@
import requests
import json
logger = logging.getLogger(__name__)

import time

class Main(App):
"""
Expand Down Expand Up @@ -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={}):
Expand All @@ -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={}):
Expand All @@ -75,14 +77,15 @@ 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={}):
"""
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
Expand All @@ -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)
21 changes: 20 additions & 1 deletion data/workflows/LifxTest.workflow
Expand Up @@ -25,11 +25,29 @@
<color format="str">red</color>
<period format="int">1</period>
<peak format="int">5</peak>
<persist format="str">false</persist>
<from_color format="str">blue</from_color>
<cycles format="int">5</cycles>
</input>
<next step="2"/>
</step>
<step id="3">
<id>3</id>
<app>Lifx</app>
<action>pulse_effect</action>
<device>LIFX 12cf1f</device>
<position>
<x>406.540089357</x>
<y>333.60458204</y>
</position>
<input>
<power_on format="str">true</power_on>
<color format="str">red</color>
<period format="int">1</period>
<persist format="str">true</persist>
<from_color format="str">blue</from_color>
<cycles format="int">10</cycles>
</input>
<next step="2"/>
</step>
<step id="2">
<id>2</id>
Expand All @@ -43,6 +61,7 @@
<input>
<duration format="int">2</duration>
</input>
<next step="3"/>
</step>
</steps>
</workflow>
Expand Down

0 comments on commit 2aa225c

Please sign in to comment.