diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..7a0c05d --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,71 @@ + + + + +### Expected Behavior + + + +### Current Behavior + + + +### Steps to Reproduce (for bugs) + + +### Versions + +- **Plugin**: `YourVersion` + +### Configuration + +```json + +``` + +### Homebridge Log / Command Output + +``` + +``` + +### Device Simulation Report + +``` + +``` diff --git a/CHANGES.md b/CHANGES.md index 6e9179d..51c1d09 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,14 +1,28 @@ Release Notes ========== -Version 0.23.1 (Beta 23.1) +Version 1.0.0 RC 1 (Release Candidate 1) ========== -* Fixed bug in SenseMe support where fans and lights were not populating their HomeKit characteristics -* Updated Homebridge-Indigo2 to 0.2.4 +* Final fixes for SenseMe fan/light support ([Issue #97](https://github.com/Colorado4Wheeler/HomeKit-Bridge/issues/97)) +* Adjusted acceptable value range on Heat and Cooling set points to allow for wider changes ([Issue #97](https://github.com/Colorado4Wheeler/HomeKit-Bridge/issues/97)) +* Added automatic server restart if the Homebridge debug option is changed +* Removed Simulated Device Dump from plugin actions (still remains in device actions) in Advanced Plugin Actions menu since the recent changes have rendered that somewhat inoperable +* Removed 'use new library' option from plugin config until needed again +* Removed 'performance options' from plugin menu as it is no longer needed +* Removed 'development testing' from plugin menu in preparation for release +* Changed Homebridge debug checkbox in the server advanced options to a combobox that will allow the user to debug Homebridge-Indigo, Homebridge server, neither or both to allow for a full comprehensive debug if there are issues that require seeing what Homebridge is doing +* Changed server device re-caching to only happen when the included devices or actions are changed in a server rather than on any properly or attribute change +* [Issue #99](https://github.com/Colorado4Wheeler/HomeKit-Bridge/issues/99) resolved +* [Issue #97](https://github.com/Colorado4Wheeler/HomeKit-Bridge/issues/97) resolved Previous Release Notes ========== +Version 0.23.1 (Beta 23.1) +--------------- +* Fixed bug in SenseMe support where fans and lights were not populating their HomeKit characteristics +* Updated Homebridge-Indigo2 to 0.2.4 + Version 0.23.0 (Beta 23.0) --------------- * **NOTE** As stated earlier, the entire HomeKit engine is being optimized and rewritten for various reasons. There is a new plugin configuration option that allows you to revert to the previous method if the new method is causing problem, but this is on a release-by-release basis, meaning that only changes in **this** release will roll back to using the old methods, the next release will not be able to roll back anything from this release. The functions impacted will be noted in the release notes as 'Library Change'. Please report any issues that are caused by the new library that are resolved by returning to the old methods. Each revision will re-enable this option automatically if it gets turned off. diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Info.plist b/EPS HomeKit Bridge.indigoPlugin/Contents/Info.plist index bb9da5c..9358b80 100755 --- a/EPS HomeKit Bridge.indigoPlugin/Contents/Info.plist +++ b/EPS HomeKit Bridge.indigoPlugin/Contents/Info.plist @@ -3,7 +3,7 @@ PluginVersion - 0.23.1 + 1.0.0-rc1 ServerApiVersion 2.0 IwsApiVersion diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/Devices.xml b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/Devices.xml index 61422af..a270e80 100755 --- a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/Devices.xml +++ b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/Devices.xml @@ -49,10 +49,16 @@ - - - Enable Homebridge debugging - + + + + + + + + + formFieldChanged + diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/MenuItems.xml b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/MenuItems.xml index b95cb1a..030f988 100755 --- a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/MenuItems.xml +++ b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/MenuItems.xml @@ -112,82 +112,6 @@ - - - - Performance Options - Save - performanceOptions - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Show Support Information @@ -199,11 +123,6 @@ Using this method is nit-picking performance since polling is almost equally as version_check - - Development Testing - devTest - - @@ -271,7 +190,6 @@ Using this method is nit-picking performance since polling is almost equally as - diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/PluginConfig.xml b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/PluginConfig.xml index 3ab5857..56ee599 100755 --- a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/PluginConfig.xml +++ b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/PluginConfig.xml @@ -63,7 +63,7 @@ - + diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/bin/hb/homebridge/runhomebridge b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/bin/hb/homebridge/runhomebridge index 2098505..b78905a 100755 --- a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/bin/hb/homebridge/runhomebridge +++ b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/bin/hb/homebridge/runhomebridge @@ -23,4 +23,8 @@ if [ -f "$LOG.2" ]; then /bin/mv -f "$LOG.2" "$LOG.3"; fi if [ -f "$LOG.1" ]; then /bin/mv -f "$LOG.1" "$LOG.2"; fi if [ -f "$LOG" ]; then /bin/mv -f "$LOG" "$LOG.1"; fi +if [ -f "$CDIR/homebridge.debug" ]; then + . "$CDIR/homebridge.debug" +fi + exec "$DIR/homebridge" -D -U "$CDIR" -P "$CDIR" > "$LOG" 2>&1 diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/bin/hb/homebridge/runhomebridge.001 b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/bin/hb/homebridge/runhomebridge.001 new file mode 100755 index 0000000..2098505 --- /dev/null +++ b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/bin/hb/homebridge/runhomebridge.001 @@ -0,0 +1,26 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +export PATH="$DIR:/usr/bin:/bin:/usr/sbin:/sbin" +export NODE_PATH="$( "$DIR/npm" -g root )" + +NAME="$1" + +if [[ "$NAME" == /* ]]; then + CDIR="$NAME" +else + CDIR="$DIR/$NAME" +fi + +LOG="$CDIR/homebridge.log" + +if [ -f "$LOG.6" ]; then /bin/mv -f "$LOG.6" "$LOG.7"; fi +if [ -f "$LOG.5" ]; then /bin/mv -f "$LOG.5" "$LOG.6"; fi +if [ -f "$LOG.4" ]; then /bin/mv -f "$LOG.4" "$LOG.5"; fi +if [ -f "$LOG.3" ]; then /bin/mv -f "$LOG.3" "$LOG.4"; fi +if [ -f "$LOG.2" ]; then /bin/mv -f "$LOG.2" "$LOG.3"; fi +if [ -f "$LOG.1" ]; then /bin/mv -f "$LOG.1" "$LOG.2"; fi +if [ -f "$LOG" ]; then /bin/mv -f "$LOG" "$LOG.1"; fi + +exec "$DIR/homebridge" -D -U "$CDIR" -P "$CDIR" > "$LOG" 2>&1 diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/homekit.py b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/homekit.py index 5547843..9290ed4 100755 --- a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/homekit.py +++ b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/homekit.py @@ -1573,9 +1573,11 @@ def setAttributeValue (self, attribute, value): if attribute == "Brightness": self.Brightness.minValue = 0 self.Brightness.maxValue = 16 + self.Brightness.changeMinMax = True if attribute == "RotationSpeed": self.RotationSpeed.minValue = 0 self.RotationSpeed.maxValue = 7 + self.RotationSpeed.changeMinMax = True # Do temperature conversion on the value if attribute in ["CurrentTemperature", "TargetTemperature", "HeatingThresholdTemperature", "CoolingThresholdTemperature"]: @@ -2229,7 +2231,7 @@ def special_SenseMeFanSpeed (self, classes, sourceDict, getter, characteristic, self.characterDict[characteristic] = getattr (self, characteristic).value valuesDict = {'speed': "=value="} - self.actions.append (HomeKitAction(characteristic, "between", 0, "homekit.runPluginAction", [indigo.devices[self.objId].pluginId, None, ["fanSpeed", self.objId, valuesDict]], 7, {self.objId: "state_speed"})) + self.actions.append (HomeKitAction(characteristic, "between", 0, "homekit.runPluginAction", [indigo.devices[self.objId].pluginId, "=value=", ["fanSpeed", self.objId, valuesDict]], 7, {self.objId: "state_speed"})) except Exception as e: self.logger.error (ext.getException(e) + "\nFor object id {} alias '{}'".format(str(self.objId), self.alias.value)) @@ -2258,12 +2260,14 @@ def special_SenseMeLightLevel (self, classes, sourceDict, getter, characteristic try: if self.serverId == 0: return + obj = indigo.devices[self.objId] + value = int(obj.states["brightness"]) self.setAttributeValue (characteristic, value) self.characterDict[characteristic] = getattr (self, characteristic).value valuesDict = {'lightLevel': "=value="} - self.actions.append (HomeKitAction(characteristic, "between", 0, "homekit.runPluginAction", [indigo.devices[self.objId].pluginId, None, ["fanLightBrightness", self.objId, valuesDict]], 16, {self.objId: "state_brightness"})) + self.actions.append (HomeKitAction(characteristic, "between", 0, "homekit.runPluginAction", [indigo.devices[self.objId].pluginId, "=value=", ["fanLightBrightness", self.objId, valuesDict]], 16, {self.objId: "state_brightness"})) except Exception as e: self.logger.error (ext.getException(e) + "\nFor object id {} alias '{}'".format(str(self.objId), self.alias.value)) @@ -2545,7 +2549,7 @@ def run (self, value, objId, waitForComplete = True): for c in cmd: func = getattr(func, c) - + if len(args) > 0: retval = func(*args) else: @@ -2708,8 +2712,9 @@ def runPluginAction (self, pluginId, value, arguments): args.append(value) else: args.append(a) - - self.logger.threaddebug (u"Running plugin action on {} with {}".format(pluginId, unicode(args))) + + #self.logger.warning (u"Value passed is {}".format(value)) + self.logger.debug (u"Running plugin action on {} with {}".format(pluginId, unicode(args))) result = plugin.executeAction(*args, waitUntilDone=True) self.logger.threaddebug (u"Plugin action return value: " + unicode(result)) else: @@ -4128,13 +4133,13 @@ def __init__(self): class characteristic_CoolingThresholdTemperature: def __init__(self): self.value = 0.0 - self.maxValue = 35 + self.maxValue = 38 self.minValue = 10 self.minStep = 0.1 self.readonly = False self.notify = True - self.changeMinMax = False + self.changeMinMax = True # ============================================================================== # CURRENT AMBIENT LIGHT LEVEL @@ -4384,13 +4389,13 @@ def __init__(self): class characteristic_HeatingThresholdTemperature: def __init__(self): self.value = 0.0 - self.maxValue = 25 + self.maxValue = 38 self.minValue = 0 self.minStep = 0.1 self.readonly = False self.notify = True - self.changeMinMax = False + self.changeMinMax = True # ============================================================================== # HOLD POSITION diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/plugin.py b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/plugin.py index 1dca993..80f650f 100755 --- a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/plugin.py +++ b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/plugin.py @@ -363,10 +363,13 @@ def pluginUpgraded (self, lastVersion, currentVersion): # 0.23.0 if not "hbDebug" in props: - props["hbDebug"] = False + props["hbDebug"] = "none" changed = True - + # 0.24.0 + if "hbDebug" in props and unicode(props["hbDebug"]) == "True": + props["hbDebug"] = "hbi2" + changed = True if changed: @@ -688,7 +691,7 @@ def onAfter_nonpluginDeviceUpdated (self, origDev, newDev): HomeKit.send_refresh_to_homebridge(r["jkey"]) if rebuildRequired: - self.catalogServerDevices() + self.catalogServerDevices(0, False) # Since we just cached we don't need to do it again except Exception as e: self.logger.error (ext.getException(e)) @@ -1589,20 +1592,20 @@ def getNextAvailablePort (self, startPort, devId = 0, suppressLogging = False): # # Catalog the devices for each server into our globals # - def catalogServerDevices (self, serverId = 0): + def catalogServerDevices (self, serverId = 0, cache = True): try: self.SERVERS = [] self.SERVER_ID = {} - self.logger.info("Caching all HomeKit Bridge devices...") + if cache: self.logger.info("Caching all HomeKit Bridge devices...") if serverId == 0: for dev in indigo.devices.iter(self.pluginId + ".Server"): - self._catalogServerDevices (dev, dev.id) + self._catalogServerDevices (dev, dev.id, cache) else: dev = indigo.devices[serverId] - self._catalogServerDevices (dev, dev.id) + self._catalogServerDevices (dev, dev.id, cache) #indigo.server.log(unicode(self.SERVER_ALIAS)) #indigo.server.log(unicode(self.SERVER_ID)) @@ -1613,7 +1616,7 @@ def catalogServerDevices (self, serverId = 0): # # Callback for catalog server devices # - def _catalogServerDevices (self, dev, serverId): + def _catalogServerDevices (self, dev, serverId, cache): try: valuesDict = self.serverCheckForJSONKeys (dev.pluginProps) includedDevices = json.loads(valuesDict["includedDevices"]) @@ -1622,7 +1625,7 @@ def _catalogServerDevices (self, dev, serverId): self.SERVERS.append(dev.id) for d in includedDevices: - HomeKit.legacy_cache_device(d, serverId) + if cache: HomeKit.legacy_cache_device(d, serverId) self.SERVER_ALIAS[d["alias"]] = dev.id @@ -1637,7 +1640,7 @@ def _catalogServerDevices (self, dev, serverId): for d in includedActions: HomeKit.legacy_cache_device(d, serverId) - self.SERVER_ALIAS[d["alias"]] = dev.id + if cache: self.SERVER_ALIAS[d["alias"]] = dev.id if d["id"] not in self.SERVER_ID: self.SERVER_ID[d["id"]] = [dev.id] @@ -3775,7 +3778,7 @@ def serverFormConfigValidation (self, valuesDict, typeId, devId): # Re-catalog the server just to be safe #self._catalogServerDevices (server) - self.catalogServerDevices () + #self.catalogServerDevices () # taken out temporarily to see if it causes a problem # No matter what happens, if we are hiding objects for this session only then remove that cache now if "hiddenIds" in valuesDict: @@ -3824,22 +3827,25 @@ def serverPropChanged (self, origDev, newDev, changedProps): self.logger.threaddebug (u"Server property change: " + unicode(changedProps)) # States that will prompt us to save and restart the server - watchStates = ["port", "listenPort", "includedDevices", "includedActions", "accessoryNamePrefix", "pin", "username", "modelValue", "firmwareValue"] + watchStates = ["hbDebug", "port", "listenPort", "includedDevices", "includedActions", "accessoryNamePrefix", "pin", "username", "modelValue", "firmwareValue"] needsRestart = False + needsRecache = False for w in watchStates: if w in changedProps: if w not in origDev.states or w not in newDev.states: needsRestart = True + if w == "includedDevices" or w == "includedActions": needsRecache = True break if origDev.states[w] != newDev.states[w]: needsRestart = True + if w == "includedDevices" or w == "includedActions": needsRecache = True break if needsRestart: # Rebuild indexes - self.catalogServerDevices() + self.catalogServerDevices(0, needsRecache) # Save the configuration self.saveConfigurationToDisk (newDev) @@ -3879,7 +3885,7 @@ def serverAttribChanged (self, origDev, newDev, changedProps): if needsRestart: # Rebuild indexes - self.catalogServerDevices() + self.catalogServerDevices(0, False) # No need to recache for a name change # Save the configuration self.saveConfigurationToDisk (newDev) @@ -4210,6 +4216,18 @@ def saveConfigurationToDisk (self, server): if os.path.exists (startpath): with open(startpath + "/config.json", 'w') as file_: file_.write (jsonData) + + # Added in HBI2 0.2.5, if debugging is on then also add a file so Homebridge can be debugged too + if "hbDebug" in server.pluginProps and (server.pluginProps["hbDebug"] == "hb" or server.pluginProps["hbDebug"] == "both"): + self.logger.warning (u"Turning on full Homebridge debugging for {}".format(server.name)) + with open(startpath + "/homebridge.debug", 'w') as file_: + file_.write ("export DEBUG=*") + + else: + if os.path.isfile(startpath + "/homebridge.debug"): + self.logger.info (u"Turning off Homebridge debugging for {}".format(server.name)) + os.remove(startpath + "/homebridge.debug") + except Exception as e: self.logger.error (ext.getException(e)) @@ -4317,7 +4335,10 @@ def buildServerConfigurationDict (self, serverId, debugMode = False): #hb["password"] = self.pluginPrefs["password"] hb["listenPort"] = server.pluginProps["listenPort"] hb["serverId"] = serverId - if "hbDebug" in server.pluginProps: hb["debug"] = server.pluginProps["hbDebug"] + if "hbDebug" in server.pluginProps and (server.pluginProps["hbDebug"] == "hbi2" or server.pluginProps["hbDebug"] == "both"): + hb["debug"] = True + else: + hb["debug"] = False platforms.append (hb)