Skip to content

Commit

Permalink
Adding support for presets
Browse files Browse the repository at this point in the history
  • Loading branch information
jh71283 committed May 25, 2018
1 parent d64dcca commit a916396
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 14 deletions.
2 changes: 1 addition & 1 deletion FluxLED.indigoPlugin/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>PluginVersion</key>
<string>0.0.3</string>
<string>0.0.4</string>
<key>ServerApiVersion</key>
<string>2.0.0</string>
<key>IwsApiVersion</key>
Expand Down
49 changes: 47 additions & 2 deletions FluxLED.indigoPlugin/Contents/Server Plugin/Actions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<CallbackMethod>setRGB</CallbackMethod>
<ConfigUI>

<Field id="rgbColor" type="colorpicker" defaultValue="=">
<Field id="rgbColor" type="Colorpicker" defaultValue="=">
<Label>Color:</Label>
<CallbackMethod>rgbColorPickerUpdated</CallbackMethod>
</Field>
<Field id="labelRgbColor" type="label" alignWithControl="true" fontSize="small" fontColor="darkgray">
<Label>Click to pick a color.</Label>
<Label>Click to pick a Color.</Label>
</Field>
<Field id="red" type="textfield" defaultValue="255">
<Label>Red:</Label>
Expand Down Expand Up @@ -44,4 +44,49 @@
</Field>
</ConfigUI>
</Action>
<Action id="setPreset" deviceFilter="self" uiPath="DeviceActions">
<Name>Use Preset Pattern</Name>
<CallbackMethod>setPreset</CallbackMethod>
<ConfigUI>

<Field id="preset" type="menu" defaultValue="0x25">
<Label>Color:</Label>
<List>
<Option value="0x25">Seven Color Cross Fade</Option>
<Option value="0x26">Red Gradual Change</Option>
<Option value="0x27">Green Gradual Change</Option>
<Option value="0x28">Blue Gradual Change</Option>
<Option value="0x29">Yellow Gradual Change</Option>
<Option value="0x2a">Cyan Gradual Change</Option>
<Option value="0x2b">Purple Gradual Change</Option>
<Option value="0x2c">White Gradual Change</Option>
<Option value="0x2d">Red Green Cross Fade</Option>
<Option value="0x2e">Red Blue Cross Fade</Option>
<Option value="0x2f">Green Blue Cross Fade</Option>
<Option value="0x30">Seven Color Strobe Flash</Option>
<Option value="0x31">Red Strobe Flash</Option>
<Option value="0x32">Green Strobe Flash</Option>
<Option value="0x33">Blue Strobe Flash</Option>
<Option value="0x34">Yellow Strobe Flash</Option>
<Option value="0x35">Cyan Strobe Flash</Option>
<Option value="0x36">Purple Strobe Flash</Option>
<Option value="0x37">White Strobe Flash</Option>
<Option value="0x38">Seven Color Jumping</Option>


</List>
</Field>
<Field id="labelRgbColor" type="label" alignWithControl="true" fontSize="small" fontColor="darkgray">
<Label>Pick a preset</Label>
</Field>
<Field id="speed" type="textfield" defaultValue="50">
<Label>Speed:</Label>
<CallbackMethod>rgbColorFieldUpdated</CallbackMethod>
</Field>
<Field id="labelSpeed" type="label" alignWithControl="true" fontSize="small" fontColor="darkgray">
<Label>(0 - 100)</Label>
</Field>

</ConfigUI>
</Action>
</Actions>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Init file for Flux LED"""
from .__main__ import PresetPattern, LedTimer, WifiLedBulb, BulbScanner, utils
from .__main__ import PresetPattern, WifiLedBulb, BulbScanner, utils

__all__ = ['PresetPattern', 'LedTimer', 'WifiLedBulb', 'BulbScanner', 'utils']
__all__ = ['PresetPattern', 'WifiLedBulb', 'BulbScanner', 'utils']
Binary file not shown.
10 changes: 4 additions & 6 deletions FluxLED.indigoPlugin/Contents/Server Plugin/flux_led/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def toBytes(self):
def __str__(self):
txt = ""
if not self.active:
return "Unset"
return "Unset"

if self.turn_on:
txt += "[ON ]"
Expand Down Expand Up @@ -613,7 +613,6 @@ def _determine_query_len(self, retry = 2):
self._use_csum = True
if rx == None and retry > 0:
self._determine_query_len(max(retry -1,0))



def query_state(self, retry=2, led_type = None):
Expand All @@ -628,6 +627,7 @@ def query_state(self, retry=2, led_type = None):
led_type = 'LEDENET_ORIGINAL'

try:
self.connect()
self._send_msg(msg)
rx = self._read_msg(self._query_len)
except socket.error:
Expand All @@ -644,7 +644,6 @@ def query_state(self, retry=2, led_type = None):
return rx



def update_state(self, retry=2 ):
rx = self.query_state(retry)
if rx is None or len(rx) < self._query_len:
Expand Down Expand Up @@ -718,7 +717,6 @@ def update_state(self, retry=2 ):
if mode == "unknown":
if retry < 1:
return
self.connect()
self.update_state(max(retry-1, 0))
return
power_state = rx[2]
Expand Down Expand Up @@ -1602,7 +1600,7 @@ def parseArgs():
default=None, nargs=3,
help="Set custom pattern mode. " +
"TYPE should be jump, gradual, or strobe. SPEED is percent. " +
"COLORLIST is a should be a space-separated list of color names, web hex values, or comma-separated RGB triples")
"COLORLIST is a space-separated list of color names, web hex values, or comma-separated RGB triples")
parser.add_option_group(mode_group)

parser.add_option("-i", "--info",
Expand Down Expand Up @@ -1828,4 +1826,4 @@ def main():


if __name__ == '__main__':
main()
main()
Binary file modified FluxLED.indigoPlugin/Contents/Server Plugin/flux_led/__main__.pyc
Binary file not shown.
26 changes: 23 additions & 3 deletions FluxLED.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

import indigo

import os
import sys
import signal
Expand Down Expand Up @@ -65,6 +63,7 @@ def updateStatus(self, device):
bulb = WifiLedBulb(device.address)
keyValueList.append({'key':"online", 'value':True})
currentRGBW = bulb.getRgbw()

device.pluginProps["supportsWhite"] = bulb.rgbwcapable
device.pluginProps["supportsWhiteTemperature"] = False
#self.debugLog(str(currentRGBW))
Expand Down Expand Up @@ -168,9 +167,28 @@ def setRGB(self, action, device):
green = action.props.get('green', 0)
blue = action.props.get('blue', 0)
bulb = WifiLedBulb(device.address)
bulb.refreshState()
bulb.mode = 'color'
bulb.pattern_code = 0x61


if red+green+blue >0:
bulb.turnOn()
bulb.setRgb(red, green, blue)

# Set Preset Action
########################################
def setPreset(self, action, device):
self.debugLog(u"setPreset: device: " + device.name + ", action:\n" + unicode(action))

preset = int(action.props.get('preset', 0),0)
speed = int(action.props.get('speed', 0),0)

bulb = WifiLedBulb(device.address)
bulb.refreshState()

bulb.setPresetPattern(preset, speed)
bulb.turnOn()

# Dimmer/Relay Control Actions
########################################
def actionControlDimmerRelay(self, action, device):
Expand Down Expand Up @@ -286,6 +304,8 @@ def actionControlDimmerRelay(self, action, device):


self.debugLog(u"Setting RGBW: " + str(redLevel) + "|" + str(greenLevel) + "|" + str(blueLevel) + "|" + str(whiteLevel) )

bulb.mode = 'color'
bulb.setRgbw(redLevel, greenLevel, blueLevel, whiteLevel)#, True,currentBrightness)


Expand Down

0 comments on commit a916396

Please sign in to comment.