diff --git a/CHANGELOG.md b/CHANGELOG.md index c63948d..34dec60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,20 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] :construction: +## [2.3.2] - 2022-01-29 ![Relative date](https://img.shields.io/date/1643459917?label=) + +### Added + +- Added HomeKit attribute Position State for windows cover. @Zehir + +### Changed + +- Removed invalid HomeKit attributes ContactSensorState and On for windows cover. @Zehir + +### Fixed + +- Fix loading of default values for api node. @Zehir + ## [2.3.1] - 2022-01-10 ![Relative date](https://img.shields.io/date/1642253886?label=) ### Fixed diff --git a/nodes/api.html b/nodes/api.html index e7af9b1..dd8dbfe 100644 --- a/nodes/api.html +++ b/nodes/api.html @@ -59,15 +59,9 @@ }, specific: { value: { - method: { - value: {type: 'GET'} - }, - endpoint: { - value: {type: 'str', value: '/'} - }, - payload: { - value: {type: 'json', value: '{}'} - } + method: {type: 'GET'}, + endpoint: {type: 'str', value: '/'}, + payload: {type: 'json', value: '{}'} } } }, diff --git a/nodes/api.js b/nodes/api.js index eb0fd53..5aff8e6 100644 --- a/nodes/api.js +++ b/nodes/api.js @@ -9,17 +9,9 @@ module.exports = function (RED) { name: "", topic: "", specific: { - value: { - method: { - value: {type: 'GET'} - }, - endpoint: { - value: {type: 'str', value: '/'} - }, - payload: { - value: {type: 'json', value: '{}'} - } - } + method: {type: 'GET'}, + endpoint: {type: 'str', value: '/'}, + payload: {type: 'json', value: '{}'} } }; diff --git a/package.json b/package.json index 4645622..4bdcf63 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-deconz", - "version": "2.3.1", + "version": "2.3.2", "description": "deCONZ connectivity nodes for node-red", "keywords": [ "deconz", diff --git a/src/runtime/HomeKitFormatter.js b/src/runtime/HomeKitFormatter.js index 6e49ea7..b3739ba 100644 --- a/src/runtime/HomeKitFormatter.js +++ b/src/runtime/HomeKitFormatter.js @@ -134,7 +134,6 @@ const HomeKitFormat = (() => { .services('Stateless Programmable Switch') .needAttribute('ServiceLabelIndex') .needEventMeta('state.buttonevent') - //.needDeviceMeta({type:['Window covering controller', 'Window covering device']}) .to((rawEvent, deviceMeta) => { switch (dotProp.get(rawEvent, 'state.buttonevent') % 1000) { case 1 : // Hold Down @@ -179,6 +178,9 @@ const HomeKitFormat = (() => { .services('Motion Sensor'); HKF.ContactSensorState = new Attribute() .services('Contact Sensor') + .needDeviceMeta((deviceMeta) => { + return !['Window covering controller', 'Window covering device'].includes(deviceMeta.type); + }) .needEventMeta((rawEvent, deviceMeta) => dotProp.has(rawEvent, 'state.open') || dotProp.has(rawEvent, 'state.vibration') @@ -331,7 +333,10 @@ const HomeKitFormat = (() => { //#endregion //#region Lights HKF.On = directMap(['to', 'from'], 'state.on') - .services(['Lightbulb', 'Outlet']); + .services(['Lightbulb', 'Outlet']) + .needDeviceMeta((deviceMeta) => { + return !['Window covering controller', 'Window covering device'].includes(deviceMeta.type); + }); HKF.Brightness = new Attribute() .services('Lightbulb') .needEventMeta('state.bri') @@ -390,6 +395,7 @@ const HomeKitFormat = (() => { HKF.TargetPosition = HKF.CurrentPosition; HKF.CurrentHorizontalTiltAngle = new Attribute() .services('Window Covering') + .needDeviceMeta({type: ['Window covering controller', 'Window covering device']}) .needEventMeta('state.tilt') .to((rawEvent, deviceMeta) => Utils.convertRange(dotProp.get(rawEvent, 'state.tilt'), [0, 100], [-90, 90], true, true) @@ -399,6 +405,10 @@ const HomeKitFormat = (() => { HKF.TargetHorizontalTiltAngle = HKF.CurrentHorizontalTiltAngle; HKF.CurrentVerticalTiltAngle = HKF.CurrentHorizontalTiltAngle; HKF.TargetVerticalTiltAngle = HKF.CurrentHorizontalTiltAngle; + HKF.PositionState = new Attribute() + .services('Window Covering') + .needDeviceMeta({type: ['Window covering controller', 'Window covering device']}) + .to((rawEvent, deviceMeta) => 2); // Stopped //#endregion //#region Battery HKF.BatteryLevel = directMap(['to'], 'config.battery') diff --git a/test/DevicesSample.js b/test/DevicesSample.js index 11c1c27..f89b867 100644 --- a/test/DevicesSample.js +++ b/test/DevicesSample.js @@ -176,9 +176,9 @@ module.exports = { "modelid": "Windows cover", "name": "Light 3", "state": { - "bri": 0, - "lift": 0, - "on": false, + "bri": 178, // (deprecated by "lift") + "lift": 70, // mean 70% closed + "on": false, // (deprecated by "open") "open": true, "reachable": true, }, diff --git a/test/test.js b/test/test.js index 3506623..cca180a 100644 --- a/test/test.js +++ b/test/test.js @@ -3277,5 +3277,14 @@ describe('Device List', function () { should(homeKitResult).have.property('ServiceLabelIndex', 2); }); + it('Windows Cover', function () { + let result = deviceList.getDeviceByUniqueID('22:88:44:11:66:22:88:99-01'); + let homeKitResult = (new HomeKitFormatter.fromDeconz()).parse({state: result.state}, result); + should(homeKitResult).have.property('PositionState', 2); + should(homeKitResult).have.property('CurrentPosition', 30); + should(homeKitResult).have.property('TargetPosition', 30); + should(Object.keys(homeKitResult)).have.length(3); + }); + }); });