diff --git a/README.md b/README.md index c9de58a..20e0f50 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This platform lets you bridge a Z-Way Server instance (for example, running on [RaZBerry](http://razberry.z-wave.me) hardware or with a [UZB1](http://www.z-wave.me/index.php?id=28)) to HomeKit using Homebridge. -Homebridge requires Z-Way Server version 2.0.1 or greater, and has so far only been tested against 2.0.1 (though it is expected to work with 2.1.1). +Homebridge requires Z-Way Server version 2.0.1 or greater. It is currently tested against 2.2 though it is expected to still work with 2.0.1. ## Quick Start @@ -80,7 +80,7 @@ The following additional configuration options are supported | --- | :---: | --- | | `poll_interval` | `2` | The time in seconds between polls to Z-Way Server for updates. 2 seconds is what the Z-Way web UI uses, so this should probably be sufficient for most cases. | | `battery_low_level` | `15` | For devices that report a battery percentage, this will be used to set the `BatteryLow` Characteristic to `true`. | -| `split_services` | `false` | **DEPRECATED** This setting affects how Characteristics are organized within an accessory. For instance, if set to "true", the `BatteryLevel` and `StatusLowBattery` Characteristics were put into a `BatteryService`, where the default of `false` caused them to be simply added as additional Characteristics on the main Service. This was done mainly to support the Eve app better, which made separate Services appear the same as whole different Accessories. The Eve app now groups services in the same accessory, so this will probably be changed to default to `true` and later be removed entirely. | +| `split_services` | `true` (after 0.4.0) | **DEPRECATED** This setting affects how Characteristics are organized within an accessory. If set to "true", for instance the `BatteryLevel` and `StatusLowBattery` Characteristics are put into a `BatteryService`, where `false` causes them to be simply added as additional Characteristics on the main Service. This was done mainly to support the Eve app better, which made separate Services appear the same as whole different Accessories. The Eve app now groups services in the same accessory. This has been changed to default to `true` in 0.4.0 and will later be removed entirely. | | `opt_in` | `false` | If this is set to `true`, only devices tagged with `Homebridge.Include` will be bridged. This is mainly useful for development or troubleshooting purposes, or if you really only want to include a few accessories from your Z-Way server. | # Tags diff --git a/index.js b/index.js index f876ad6..670a508 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,7 @@ function ZWayServerPlatform(log, config){ this.name_overrides = config["name_overrides"]; this.batteryLow = config["battery_low_level"] || 15; this.pollInterval = config["poll_interval"] || 2; - this.splitServices= config["split_services"] || false; + this.splitServices= config["split_services"] || true; this.lastUpdate = 0; this.cxVDevMap = {}; this.vDevStore = {}; @@ -39,9 +39,32 @@ module.exports = function(homebridge) { homebridge.registerPlatform("homebridge-zway", "ZWayServer", ZWayServerPlatform); } - +ZWayServerPlatform.getVDevTypeKeyNormalizationMap = { + "sensorBinary.general_purpose": "sensorBinary.General Purpose", + "sensorBinary.alarm_burglar": "sensorBinary", + "sensorBinary.door": "sensorBinary.Door/Window", + "sensorMultilevel.temperature": "sensorMultilevel.Temperature", + "sensorMultilevel.luminosity": "sensorMultilevel.Luminiscence", + "sensorMultilevel.humidity": "sensorMultilevel.Humidity", + "switchMultilevel.dimmer": "switchMultilevel", + "switchRGBW.switchColor_undefined": "switchRGBW", + "switchMultilevel.switchColor_soft_white": "switchMultilevel", + "switchMultilevel.switchColor_cold_white": "switchMultilevel", + "battery": "battery.Battery" +} ZWayServerPlatform.getVDevTypeKey = function(vdev){ - return vdev.deviceType + (vdev.metrics && vdev.metrics.probeTitle ? "." + vdev.metrics.probeTitle : "") + /* At present we normalize these values down from 2.2 nomenclature to 2.0 + nomenclature. At some point, this should be reversed. */ + var nmap = ZWayServerPlatform.getVDevTypeKeyNormalizationMap; + var key = vdev.deviceType; + if(vdev.metrics && vdev.metrics.probeTitle){ + key += "." + vdev.metrics.probeTitle; + } else if(vdev.probeType){ + key += "." + vdev.probeType; + } + debug("Got typeKey " + (nmap[key] || key) + " for vdev " + vdev.id); + debug({ deviceType: vdev.deviceType, probeTitle: (vdev.metrics && vdev.metrics.probeTitle), probeType: vdev.probeType }); + return nmap[key] || key; } ZWayServerPlatform.prototype = { @@ -475,7 +498,7 @@ if(!vdev) debug("ERROR: vdev passed to getVDevServices is undefined!"); map[(new Characteristic.TargetHeatingCoolingState).UUID] = ["thermostat"]; //TODO: Always a fixed result map[(new Characteristic.CurrentDoorState).UUID] = ["sensorBinary.Door/Window","sensorBinary"]; map[(new Characteristic.TargetDoorState).UUID] = ["sensorBinary.Door/Window","sensorBinary"]; //TODO: Always a fixed result - map[(new Characteristic.ContactSensorState).UUID] = ["sensorBinary"]; + map[(new Characteristic.ContactSensorState).UUID] = ["sensorBinary","sensorBinary.Door/Window"]; map[(new Characteristic.CurrentPosition).UUID] = ["sensorBinary.Door/Window","sensorBinary"]; map[(new Characteristic.TargetPosition).UUID] = ["sensorBinary.Door/Window","sensorBinary"]; map[(new Characteristic.PositionState).UUID] = ["sensorBinary.Door/Window","sensorBinary"]; @@ -486,6 +509,7 @@ if(!vdev) debug("ERROR: vdev passed to getVDevServices is undefined!"); map[(new Characteristic.CurrentAmbientLightLevel).UUID] = ["sensorMultilevel.Luminiscence"]; map[(new Characteristic.LockCurrentState).UUID] = ["doorlock"]; map[(new Characteristic.LockTargetState).UUID] = ["doorlock"]; + map[(new Characteristic.StatusTampered).UUID] = ["sensorBinary.Tamper"]; } if(cx instanceof Characteristic.Name) return vdevPreferred; diff --git a/package.json b/package.json index 1c20070..40849bc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-zway", - "version": "0.3.3", + "version": "0.4.0", "description": "homebridge-plugin for ZWay Server and RaZBerry", "main": "index.js", "scripts": {