Apple HomeKit Gate exclude devices by default

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
brianaker
Posts: 55
Joined: 11 Nov 2016 16:57

Apple HomeKit Gate exclude devices by default

Post by brianaker »

Hi!

Apple HomeKit Gate is adding all devices to homebridge by default, I would like to suggest an option be added which excludes all devices by default and only adds them if they are tagged.

If you look through popular plugins for node's HomeKit, you will find that many of the devices that act as bridges have this option/work like this by default. Some, like for instance the one providing bridging for Logitech's Harmony devices, specifically only provides scenes by default. The user in this plugin has to explicitly add individual devices.

Another reason to do this is because unlicensed HomeKit bridges are limited to 150 devices. This is pretty simple to hit with a z-wave hub since each endpoint is considered an individual device. The last time I played with the Z-way homekit gate it behaved a little randomly once it reached the 150 device limit ( devices would appear/disappear ).

Thanks!

FWIW The option I am suggesting I believe should be the default behavior, this could be achieved by just auto-tagging devices during an upgrade to preserve current functionality once the user upgrades to a version of the homekit gate which excludes by default.
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Apple HomeKit Gate exclude devices by default

Post by PoltoS »

In v3.1.2 we have added options to the HomeKit Gate app to allow skipping devices. This UI is pretty easy to use. Go in the app settings and try it out.

Also note that the app is now part of standard X-Wave distro. You can delete the downloaded version from the store to always use the latest in the latest release.
doko2008
Posts: 1
Joined: 26 Sep 2021 15:01

Re: Apple HomeKit Gate exclude devices by default

Post by doko2008 »

I am using HomeKit Gate version 2.2.1, I can set the 'homekit-skip' tag for devices which should not be added to HomeKit, however all devices are published to HomeKit even when they are marked to be skipped.

Am I doing something wrong, or is this a bug?
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Apple HomeKit Gate exclude devices by default

Post by PoltoS »

We have heard such reports from customers but can not reproduce it. If you can provide us temporarily remote access via find.z-wave.me (siwth remote support enabled) we will try to locate the issue. You can send it in PM or on support@z-wave.me
hubert
Posts: 20
Joined: 25 Sep 2021 07:46

Re: Apple HomeKit Gate exclude devices by default

Post by hubert »

I also encountered the same bug after upgrading to 3.2.1 - all z-wave devices are visible in HomeKit and the homekit-skip tag seems to be ignored.

I fixed this with a custom patch to the code that requires a homekit-include tag to be present on every wanted device:

Code: Select all

/opt/z-way-server/automation/modules/HomeKitGate $ diff ~/index.js-original index.js
55c55
< 		if (vDevT.permanently_hidden || !(vDevT.visibility) || (vDevT.probeType === "alarmSensor_general_purpose") || (vDevT.probeType === "thermostat_mode") || vDevT.tags.indexOf("homekit-skip") !== -1 || (vDevT.deviceType === "thermostat" && vDevT.id.indexOf("ZWayVDev") === -1))
---
> 		if (vDevT.permanently_hidden || !(vDevT.visibility) || (vDevT.probeType === "alarmSensor_general_purpose") || (vDevT.probeType === "thermostat_mode") || vDevT.tags.indexOf("homekit-include") == -1 || (vDevT.deviceType === "thermostat" && vDevT.id.indexOf("ZWayVDev") === -1))
I think most users probably want to exclude the majority of their z-wave devices, as many switches expose a lot of sensors that are unlikely to be wanted in HomeKit.

I would suggest changing the UI so that you tick which devices to include, not what to exclude.

Happy to send you a copy of my config json if that helps track down the homekit-skip bug?
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Apple HomeKit Gate exclude devices by default

Post by PoltoS »

This sounds insane... looking in the code I would say that there is not error - you just inverted the check and inverted the tag name. Just for the sake of the truth, could you please add abothe that line:
console.logJS("HK-Skip-Debug", vDevT.tags.indexOf("homekit-skip"), vDevT.tags);
And please let us know what do you see for the device in trouble. I fear homekit-skip has some special characters or something else pretty weired.
aivs
Posts: 68
Joined: 04 Mar 2011 15:26

Re: Apple HomeKit Gate exclude devices by default

Post by aivs »

Hi!
We found a bug. Please try this diff.

Code: Select all

diff --git a/modules/HomeKitGate/index.js b/modules/HomeKitGate/index.js
index 06527ea3..75c37492 100644
--- a/modules/HomeKitGate/index.js
+++ b/modules/HomeKitGate/index.js
@@ -503,11 +503,13 @@ HomeKitGate.prototype.init = function (config) {
        function updateSkippedDevicesList() {
                // Add tag "homekit-skip" for all skipped devices from config
                self.config.skippedDevices.forEach(function(vDevId) {
+                       delete self.config.hkDevices[vDevId];
                        var vDev = self.controller.devices.get(vDevId);
                        if (vDev !== null && vDev.get("tags").indexOf("homekit-skip") === -1 ) {
                                vDev.addTag("homekit-skip");
                        }
                });
+               self.saveConfig();
 
                // Remove tag "homekit-skip" if device not in skipped list
                self.controller.devices.forEach(function(vDev) {
@@ -579,6 +581,7 @@ HomeKitGate.prototype.init = function (config) {
                // Add tag "homekit-skip" to skipped Devices list in config and remove device from Homekit
                if (vDev.get("tags").indexOf("homekit-skip") !== -1 && self.config.skippedDevices.indexOf(vDev.id) === -1) {
                        self.config.skippedDevices.push(vDev.id);
+                       delete self.config.hkDevices[vDev.id];
                        self.saveConfig();
                        self.onDeviceWipedOut(vDev.id);
                }

Code: Select all

diff --git a/classes/VirtualDevice.js b/classes/VirtualDevice.js
index 48b593c0..80197f54 100644
--- a/classes/VirtualDevice.js
+++ b/classes/VirtualDevice.js
@@ -378,8 +378,7 @@ _.extend(VirtualDevice.prototype, {
        },
        addTag: function (tag) {
                var tags = this.get('tags');
-               tags.push(tag);
-               this.set({'tags': _.uniq(tags)});
+               this.set({'tags': _.uniq(_.union(tags, [tag]))});
        },
        removeTag: function (tag) {
                var tags = this.get('tags');
Post Reply