From d29f6ba901b0c37ff77559b818becd5bdd1a4969 Mon Sep 17 00:00:00 2001 From: Colorado Four Wheeler Date: Tue, 3 Apr 2018 08:51:56 -0600 Subject: [PATCH] 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 --- CHANGES.md | 19 ++++++++++--- .../Contents/Info.plist | 2 +- .../Server Plugin/lib/plugin/hkfactory.py | 23 ++++++++++++---- .../Server Plugin/lib/plugin/hkfactory.pyc | Bin 4655 -> 5066 bytes .../Server Plugin/lib/plugin/hkplprocessor.py | 3 +++ .../lib/plugin/hkplprocessor.pyc | Bin 10828 -> 10944 bytes .../Contents/Server Plugin/plugin.py | 25 ++++++++++++------ 7 files changed, 54 insertions(+), 18 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6680cb6..fdac862 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) @@ -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. diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Info.plist b/EPS HomeKit Bridge.indigoPlugin/Contents/Info.plist index 4230b9e..aa77248 100755 --- a/EPS HomeKit Bridge.indigoPlugin/Contents/Info.plist +++ b/EPS HomeKit Bridge.indigoPlugin/Contents/Info.plist @@ -3,7 +3,7 @@ PluginVersion - 0.22.0 + 0.22.1 ServerApiVersion 2.0 IwsApiVersion diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/plugin/hkfactory.py b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/plugin/hkfactory.py index 688dded..78dd5b9 100755 --- a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/plugin/hkfactory.py +++ b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/plugin/hkfactory.py @@ -89,20 +89,26 @@ 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"])) @@ -110,11 +116,18 @@ def legacy_cache_device (self, r, serverId): 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) diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/plugin/hkfactory.pyc b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/plugin/hkfactory.pyc index 9707405735188e910c7e53a883f964922b88e419..4b8e822be7e34f7823c1c468fddad63d37cc6eab 100644 GIT binary patch delta 796 zcmY*XL2DCH5T4oHY_gj)X|xJ^Nb>|G5t1S;UP4Y4L@y%oV5w5rWM8_Qgtv9~B_Wv5 zL!!`Q*`r5)fJo0C#DggG+#ljyoVP@&Ff;6Y^L;b3!~1miXDzG$+OVtV-#%x5qpbnJ zK6(5+DQWF3Zh>dO3gOTOF9R!p!~DnBTJC{CoGf{U{E_1K5n$HDIf94a%mD@fLldGi znClR?llS&^PJl|HZt~UMeyEa^wU#&wBc)!!+<<`rO8|Ux1>#vsLl|hZL2_wVPfhBt zfs$pxS?ZvKWY?Ru)ld@^mQ9NYBvIT9%*hDPr5$M3wkZD(IEr+g;ZXa&1}|QU1{kt! z!O({272?8#bObGDgUrLA0CN+Ts0;*<8Qfb{%NBV$Cl>c&Si7?{*h{t}*n)+O@ zzB`IJlRjszlu^(fOCB>qeb;rR-vVIt`o;w-^;+S>a-jKbfC+!+j<*++wS!pfi(IlXOgz%nB8il=zL%&PCqJU4-cBwkuxAt~XOO6Wnu$Zh0 zXSI%cKy~$!IyY3Ps=z2nb+CVTO73i2HtK{xQOBET0!zJ2aZ|4#!?JGTE!@(|nxmDl zqFvZU2TMC7ct;*9WxbH>mJZ5NO?<2l-f7ZTXD2x?eJ>X7r`_wf6|{HJ-~54p0Gmm% AEC2ui delta 416 zcmY+9y-Nc@5XIlz-gi9DQz9PZOAw5bfLN!}#zw)jFo@P zxr9VRtV=sr?i(DSjiOA11A#IBFQcI*OT};~!-~?8@!`Gw_l(AVT7%wo&~nlK0`&~g zO*&s@40)~_txZ_w?v-&@XqCt;|5Wg?Wm$kNtH!; zXkN?6FBTSfgd=Ez&e)%uWTU+5PWPe``_ diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/plugin/hkplprocessor.py b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/plugin/hkplprocessor.py index 19ff3ca..8dc4ad1 100755 --- a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/plugin/hkplprocessor.py +++ b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/plugin/hkplprocessor.py @@ -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: @@ -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: @@ -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: diff --git a/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/plugin/hkplprocessor.pyc b/EPS HomeKit Bridge.indigoPlugin/Contents/Server Plugin/lib/plugin/hkplprocessor.pyc index 6d113008daa9c57988ee19fbcbe31bd03000bd0c..9af9a739aa3cf4ffece256bc568a0bd906e4ddaf 100644 GIT binary patch delta 703 zcmb7=%}WAN6vfYdj$;~9lw^`x_BpMh2uutLYSV`hTG%FHXr@SUz-fvCrG?S5&HEdq zbxf;PMVl5Ot=qJ3)1r2^=r!~~U__hCd*_~e?~il4e7WLrJ^OvfN7rW_Gc3O_;NYAe zhI`_7C^5{g-JmR^Bts*FG=@BbIg6qK1CHuKs08E)Ink40?(@rVASKjLg+RjhKKgBv z98(n^Gty@}RQAA#II`Q(B(ayA7x7pmIU#6VjcI~Ztp7%{K>RA){*6=ry!UnAVWzL| z2kjp?@yR-}`vOU7jPyvw8vPPbl>J1iQKN(w*ng3RYn0X8u)N6mP;x^PxqDC{+GNON zjRYjC8F?SfCti;Zwl+cYq9R(WnhzPJnU8iS#-{;TF;RAOb8mY?U!PG6x~Zm@mok>A ztA&(ms9SnLH>`A2xYARi@Q2Yym=pdgE|HtK1l w$&Sz7jrkdE*p0Tz*>giFYDs#7%KLI9AWC}Mt}3VW1|%7c)&Kwi delta 650 zcmb7>ze@sP7{|ZQd*@xA9Y&OTq@K|a&mnB9hOD8n7AFK+T7ufKhQcq%{e2VT^gizUSJV7Tva1mr;)O z%f5b%@ioLV0j6Mg;%f~9`Ag0sc(Lf@#nN?`4N(UyyEKw6`Clw@55{Hb4p>AlmJd&s z7X7~EfW^=L&5~+S-V{;wqp0+L!sJgvljwvYmoINXtOih0VBOoB`tqy{a{^7?IyC*r z847^Ps-1}}+Bf=CAkJlWs~5JNj{Zg~8JeY0~8Ws=&i}< 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)) @@ -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: @@ -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)) @@ -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)) @@ -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")