Skip to content

Commit

Permalink
Version 0.22.1 (Beta 22.1)
Browse files Browse the repository at this point in the history
* **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.
* **NOTE** All minor revisions can still be rolled back for Library
Changes until the next full beta version is released
* Added optimized Homebridge callback POST method to replace the
current GET method, in preparation for an updated Homebridge-Indigo2
script that will parse the data instead of calling back to the API
([Issue
#93]((#93))
* Fixed bug in configuration builder where if an error was tripped the
exception would not populate ([Issue
#94]((#94) and
[Issue
#92]((#92))
* Fixed bug in new library that would allow Homebridge to see a
duplicate camera device and would send that device to HomeKit along
with the normal camera ([Issue
#83](#83))
* [Issue
#94]((#94)
resolved
* [Issue
#92]((#92)
resolved
* [Issue
#93]((#93)
implemented
  • Loading branch information
Colorado Four Wheeler authored and Colorado Four Wheeler committed Apr 3, 2018
1 parent f079678 commit d29f6ba
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 18 deletions.
19 changes: 15 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
Release Notes
==========

Version 0.22.0 (Beta 22.0)
Version 0.22.1 (Beta 22.1)
==========
* **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.
* **NOTE** All minor revisions can still be rolled back for Library Changes until the next full beta version is released
* Added optimized Homebridge callback POST method to replace the current GET method, in preparation for an updated Homebridge-Indigo2 script that will parse the data instead of calling back to the API ([Issue #93]((https://github.com/Colorado4Wheeler/HomeKit-Bridge/issues/93))
* Fixed bug in configuration builder where if an error was tripped the exception would not populate ([Issue #94]((https://github.com/Colorado4Wheeler/HomeKit-Bridge/issues/94) and [Issue #92]((https://github.com/Colorado4Wheeler/HomeKit-Bridge/issues/92))
* Fixed bug in new library that would allow Homebridge to see a duplicate camera device and would send that device to HomeKit along with the normal camera ([Issue #83](https://github.com/Colorado4Wheeler/HomeKit-Bridge/issues/83))
* [Issue #94]((https://github.com/Colorado4Wheeler/HomeKit-Bridge/issues/94) resolved
* [Issue #92]((https://github.com/Colorado4Wheeler/HomeKit-Bridge/issues/92) resolved
* [Issue #93]((https://github.com/Colorado4Wheeler/HomeKit-Bridge/issues/93) implemented

Previous Release Notes
==========

Version 0.22.0 (Beta 22.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.
* Added error trapping around building the camera configuration in case there's an odd setup that may cause the camera build to fail it will not impact the rest of the homekit devices
* Added new action under device actions to [restart an individual server](https://github.com/Colorado4Wheeler/HomeKit-Bridge/wiki/Actions#restart-accessory-server)
Expand All @@ -16,9 +30,6 @@ Version 0.22.0 (Beta 22.0)
* Library Change: Started adding the underlying structure to test the _possibility_ of using Indigo variables as HomeKit devices
* Library Change: Cache HomeKit devices and update dynamically, improved API performance by 600%

Previous Release Notes
==========

Version 0.21.0 (Beta 21.0)
---------------
* **NOTE** This release begins the process of rewriting the entire HomeKit integration, small chunks at a time, so it's possible that this can break things. I'm trying to thoroughly test changes to make sure the end result is the same, but you have been warned.
Expand Down
2 changes: 1 addition & 1 deletion EPS HomeKit 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>0.22.0</string>
<string>0.22.1</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 @@ -89,32 +89,45 @@ def legacy_get_payload (self, obj, r, serverId):


###
def legacy_cache_device (self, r, serverId):
def legacy_cache_device (self, r, serverId, norefresh = False):
"""
Creates or refreshes the service object in cache.
Arguments:
r: JSON record to get the service object for
serverId: Indigo device Id of the server hosting this r device
norefresh: when false the attributes and payload won't refresh - built for calling back to HBI2 since it would have refreshed prior to that anyway
Returns:
payload: the cached payload
obj: the service object
"""

try:
if r["jkey"] in self.HKDEFINITIONS:
self.logger.threaddebug (u"Updating cache for '{}'".format(r["alias"]))
if not norefresh: self.logger.threaddebug (u"Updating cache for '{}'".format(r["alias"]))
if norefresh: self.logger.threaddebug (u"Retrieving cache for '{}'".format(r["alias"]))
obj = self.HKDEFINITIONS[r["jkey"]]
obj.setAttributes() # Refresh the characteristic values
if not norefresh: obj.setAttributes() # Refresh the characteristic values
else:
# Cache the service object
self.logger.threaddebug (u"Caching '{}'".format(r["alias"]))
obj = self.api.legacy_get_homekit_object (r["id"], serverId, r["hktype"])
self.HKDEFINITIONS[r["jkey"]] = obj

# Cache the API payload
payload = self.legacy_get_payload(obj, r, serverId)
self.HKCACHE[r["jkey"]] = payload
if not norefresh:
payload = self.legacy_get_payload(obj, r, serverId)
self.HKCACHE[r["jkey"]] = payload
else:
payload = self.HKCACHE[r["jkey"]]

return self.HKCACHE[r["jkey"]], obj

except Exception as e:
self.logger.error (ex.stack_trace(e))

return {}, None

###
def process_incoming_api_call (self, request, query): return self.api.process_incoming_api_call (request, query)
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def json_reply_command_devicelist (self, serverId):
deviceList = []

for r in includedDevices:
if r["hktype"] == "service_CameraRTPStreamManagement": continue
if r["jkey"] in self.factory.HKCACHE:
deviceList.append(self.factory.HKCACHE[r["jkey"]])
else:
Expand All @@ -243,6 +244,7 @@ def json_reply_command_devicelist (self, serverId):
deviceList.append(payload.legacy_populate_from_service (obj, r, serverId))

for r in includedActions:
if r["hktype"] == "service_CameraRTPStreamManagement": continue
if r["jkey"] in self.factory.HKCACHE:
deviceList.append(self.factory.HKCACHE[r["jkey"]])
else:
Expand All @@ -259,6 +261,7 @@ def json_reply_command_devicelist (self, serverId):
#deviceList.append(payload.legacy_populate_from_service (obj, r, serverId))

for r in includedVariables:
if r["hktype"] == "service_CameraRTPStreamManagement": continue
if r["jkey"] in self.factory.HKCACHE:
deviceList.append(self.factory.HKCACHE[r["jkey"]])
else:
Expand Down
Binary file not shown.
25 changes: 17 additions & 8 deletions EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ def pluginUpgraded (self, lastVersion, currentVersion):
props["SupportsStatusRequest"] = False
changed = True

# 0.22.0
if "newpackage" in self.pluginPrefs and not self.pluginPrefs["newpackage"]:
self.logger.warning ("Re-enabled plugin preference option to 'Use New Library Methods'")
self.pluginPrefs["newpackage"] = True

if changed:
self.logger.info (u"Upgrading {} for changes in this plugin release".format(dev.name))
dev.replacePluginPropsOnServer(props)
Expand Down Expand Up @@ -674,7 +679,7 @@ def onAfter_nonpluginDeviceUpdated (self, origDev, newDev):
if self.pluginPrefs.get('newpackage', True):
HomeKit.legacy_cache_device(r, serverId)

self.serverSendObjectUpdateToHomebridge (indigo.devices[serverId], r["jkey"])
self.serverSendObjectUpdateToHomebridge (indigo.devices[serverId], r["jkey"], r)

if rebuildRequired:
self.catalogServerDevices()
Expand Down Expand Up @@ -1139,14 +1144,14 @@ def buildHKAPIDetails (self, objId, serverId, jkey, characteristic = None, value
#
# Run in a thread, this will run the URL in the specified seconds
#
def timedCallbackToURL (self, serverId, devId, waitSeconds, r = None):
def timedCallbackToURL (self, serverId, devId, waitSeconds, r):
try:
if waitSeconds > 0: time.sleep(waitSeconds)

if self.pluginPrefs.get('newpackage', True):
HomeKit.legacy_cache_device(r, serverId)

self.serverSendObjectUpdateToHomebridge (indigo.devices[int(serverId)], devId)
self.serverSendObjectUpdateToHomebridge (indigo.devices[int(serverId)], devId, r)

except Exception as e:
self.logger.error (ext.getException(e))
Expand Down Expand Up @@ -2880,7 +2885,7 @@ def _serverActionRefreshDevice (self, action, r = None, server = None):
if self.pluginPrefs.get('newpackage', True):
HomeKit.legacy_cache_device(r, server.id)

self.serverSendObjectUpdateToHomebridge (server, r["jkey"])
self.serverSendObjectUpdateToHomebridge (server, r["jkey"], r)


except Exception as e:
Expand Down Expand Up @@ -4057,7 +4062,7 @@ def serverCommandTurnOff (self, dev):
#
# Send an update to Homebridge
#
def serverSendObjectUpdateToHomebridge (self, server, objId):
def serverSendObjectUpdateToHomebridge (self, server, objId, r):
try:
if not server.states["onOffState"]:
self.logger.debug (u"Homebridge update requested, but '{}' isn't running, ignoring update request".format(server.name))
Expand All @@ -4066,14 +4071,18 @@ def serverSendObjectUpdateToHomebridge (self, server, objId):
url = "http://127.0.0.1:{1}/devices/{0}".format(str(objId), server.pluginProps["listenPort"])

#data = {'isOn':1, 'brightness': 100}
data = {}
#data = {}

data, obj = HomeKit.legacy_cache_device (r, server.id, True) # Get cached values, they should have already refreshed so we send True to the norefresh argument

data_json = json.dumps(data)
payload = {'json_payload': data_json}
headers = {'content-type': 'application/json'}

self.logger.debug (u"Homebridge update requested, querying {0} on {1}".format(url, server.name))

r = requests.get(url, data=payload)
#r = requests.get(url, data=payload)
r = requests.post(url, data=data_json, headers=headers)

#indigo.server.log(unicode(r))

Expand Down Expand Up @@ -4552,7 +4561,7 @@ def buildServerConfigurationDict (self, serverId, debugMode = False):

cameras.append(camera)

except:
except Exception as e:
self.logger.error (ext.getException(e))
self.logger.warning (u"Configuration will be built despite the error")

Expand Down

0 comments on commit d29f6ba

Please sign in to comment.