Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Zehir committed Jan 29, 2022
2 parents 6cd2409 + 9512efb commit d0e5e1f
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 26 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions nodes/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -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: '{}'}
}
}
},
Expand Down
14 changes: 3 additions & 11 deletions nodes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '{}'}
}
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 12 additions & 2 deletions src/runtime/HomeKitFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand All @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions test/DevicesSample.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
9 changes: 9 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

});
});

0 comments on commit d0e5e1f

Please sign in to comment.