Skip to content

Commit

Permalink
Add User Selectable Option for Auto-Create V3 devices from V2
Browse files Browse the repository at this point in the history
Allows user to control whether V3 devices will be created from V2 devices on initial install.
  • Loading branch information
autolog committed Apr 2, 2019
1 parent ca64c7d commit 798562c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion Alexa-Hue Bridge.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>3.0.29</string>
<string>3.0.30</string>
<key>ServerApiVersion</key>
<string>2.0</string>
<key>IwsApiVersion</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,33 @@

<Field id="separator-3" type="separator"/>

<Field type="checkbox" id="autoCreateDevicesFromPluginVersion2" default="true" alwaysUseInDialogHeightCalc="true">
<Label>Auto Create:</Label>
</Field>
<Field id="help-3" type="label" fontColor="darkgray" fontSize="small" alignWithControl="true" alwaysUseInDialogHeightCalc="true">
<Label>^ Enable to automatically create Version 3 devices from Version 2 on initial install. See wiki plugin documentation (link in Indigo Store): Installation and setup - Migration from Version 2. Default is True.</Label>
</Field>

<Field id="separator-4" type="separator"/>

<Field type="checkbox" id="nonEchoFilter" default="false" alwaysUseInDialogHeightCalc="true">
<Label>Non-Echo Filter :</Label>
</Field>
<Field id="help-3" type="label" fontColor="darkgray" fontSize="small" alignWithControl="true" alwaysUseInDialogHeightCalc="true">
<Field id="help-4" type="label" fontColor="darkgray" fontSize="small" alignWithControl="true" alwaysUseInDialogHeightCalc="true">
<Label>^ Enable the non-Echo Filter to filter out network traffic that doesn't come from an Echo. If you enable this, YOU MUST DEFINE INDIGO ECHO DEVICES to refect the Echos you have in use, otherwise the plugin won't receive any messages from the Echos as it won't know about them. Using the filter will reduce the network load on the plugin and may help to make it run more effectively.</Label>
</Field>

<Field id="separator-4" type="separator" visibleBindingValue="true"/>
<Field id="separator-5" type="separator" visibleBindingValue="true"/>

<Field id="showDiscoveryInEventLog" type="checkbox" default="true" alwaysUseInDialogHeightCalc="true">
<Label>Log Discovery:</Label>
<Description>Log Alexa discovery requests in Event Log.</Description>
</Field>
<Field id="help-4" type="label" fontColor="darkgray" fontSize="small" alignWithControl="true" visibleBindingId="debugEnabled" visibleBindingValue="true" alwaysUseInDialogHeightCalc="true">
<Field id="help-5" type="label" fontColor="darkgray" fontSize="small" alignWithControl="true" alwaysUseInDialogHeightCalc="true">
<Label>^ If you tick this box, then the Alexa-Hue Bridge will log discovery requests from Alexa to the Event Log, showing all devices published. This can result in a lot of log entries!</Label>
</Field>

<Field id="separator-5" type="separator"/>
<Field id="separator-6" type="separator"/>

<Field type="checkbox" id="debugEnabled" default="false">
<Label>Debugging:</Label>
Expand Down
11 changes: 9 additions & 2 deletions Alexa-Hue Bridge.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ def getPrefsConfigUiValues(self):
if "showDiscoveryInEventLog" not in prefsConfigUiValues:
prefsConfigUiValues["showDiscoveryInEventLog"] = True

if "autoCreateDevicesFromPluginVersion2" not in prefsConfigUiValues:
prefsConfigUiValues["autoCreateDevicesFromPluginVersion2"] = True

return prefsConfigUiValues

def validatePrefsConfigUi(self, valuesDict):
Expand Down Expand Up @@ -198,6 +201,8 @@ def closedPrefsConfigUi(self, valuesDict, userCancelled):
self.globals['hostAddress'] = None
self.generalLogger.info(u"Plugin Host IP Address is discovered as: '{}'".format(self.globals['hostAddress']))

self.globals['autoCreateDevicesFromPluginVersion2'] = bool(valuesDict.get("autoCreateDevicesFromPluginVersion2", True))

self.globals['amazonEchoDeviceFilterActive'] = bool(valuesDict.get("nonEchoFilter", False))
if self.globals['amazonEchoDeviceFilterActive']:
self.generalLogger.info(u"non-Echo network traffic being filtered out")
Expand Down Expand Up @@ -577,8 +582,10 @@ def getDeviceConfigUiValues(self, pluginProps, typeId, ahbDevId):
if 'publishedAlexaDevices' not in self.globals['alexaHueBridge'][ahbDevId]:
self.globals['alexaHueBridge'][ahbDevId]['publishedAlexaDevices'] = {}

self.retrieveOtherPublishedDevices(ahbDevId) # List Alexa devices in other Alexa-Hue Bridges
self.retrievePublishedDevices(pluginProps, ahbDevId, False, True) # List Alexa devices in this Alexa-Hue Bridge + don't output info message + Check for V2 definitions
self.retrieveOtherPublishedDevices(ahbDevId) # List Alexa devices in other Alexa-Hue Bridges


self.retrievePublishedDevices(pluginProps, ahbDevId, False, self.globals['autoCreateDevicesFromPluginVersion2']) # List Alexa devices in this Alexa-Hue Bridge + don't output info message + Check for V2 definitions (if option set in plugin config)

# Set default values for Edit Device Settings... (ConfigUI)
pluginProps["autoStartDiscovery"] = pluginProps.get("autoStartDiscovery", True)
Expand Down

0 comments on commit 798562c

Please sign in to comment.