Skip to content

Commit

Permalink
Merge pull request #202 from NRCHKB/dependencies
Browse files Browse the repository at this point in the history
1.0.0-dev.7
  • Loading branch information
Shaquu authored Jan 23, 2020
2 parents 5f5b5d2 + 1ed4aef commit b390951
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- After Service selection in node configuration Category will be automatically set to default for Service
- Interface Name for Camera Service configuration
- Support for new TV Remote services
- Now first output is for onChange, second for onSet and third for camera snapshot. [#200](https://github.com/NRCHKB/node-red-contrib-homekit-bridged/issues/200)

### Changed

Expand Down
8 changes: 7 additions & 1 deletion homekit.html
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,14 @@ <h3 id="toc_4">Bridge</h3>
outputs: 2,
outputLabels: function(index) {
if (index === 0) {
return 'default'
return 'onChange'
}

if (index === 1) {
return 'onSet'
}

if (index === 2) {
return 'camera snapshot'
}

Expand Down Expand Up @@ -578,8 +582,10 @@ <h3 id="toc_4">Bridge</h3>
.change(function() {
if (this.value === 'CameraControl') {
cameraConfiguration.fadeIn('fast')
node.outputs = 3
} else {
cameraConfiguration.fadeOut('fast')
node.outputs = 2
}
})
.change()
Expand Down
2 changes: 1 addition & 1 deletion lib/cameraSource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Camera.prototype.handleSnapshotRequest = function(request, callback) {
'Sending camera snapshot buffer to output...' +
JSON.stringify(msg)
)
this.cameraNode.send([null, msg])
this.cameraNode.send([null, null, msg])
}

callback(undefined, imageBuffer)
Expand Down
36 changes: 27 additions & 9 deletions lib/utils/ServiceUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ module.exports = function(node) {
}
}

// eslint-disable-next-line no-unused-vars
const onCharacteristicSet = function(newValue, callback, context) {
callback(node.accessory.reachable === true ? null : 'no response')
}

const onCharacteristicChange = function({ oldValue, newValue, context }) {
const onValueChange = function(outputNumber, {oldValue, newValue, context}) {
const topic = node.topic ? node.topic : node.topic_in
const msg = { payload: {}, hap: {}, name: node.name, topic: topic }
const key = this.displayName.replace(/ /g, '').replace(/\./g, '_')
Expand Down Expand Up @@ -48,10 +43,33 @@ module.exports = function(node) {
debug(node.name + ' received ' + key + ': ' + newValue)

if (context || node.bridgeNode.allowMessagePassthrough) {
node.send(msg)
if (outputNumber === 0) {
node.send(msg)
} else if (outputNumber === 1) {
node.send([null, msg])
}
}
}

// eslint-disable-next-line no-unused-vars
const onCharacteristicSet = function(newValue, callback, context) {
callback(node.accessory.reachable === true ? null : 'no response')

onValueChange.call(this, 1, {
undefined,
newValue,
context
})
}

const onCharacteristicChange = function({ oldValue, newValue, context }) {
onValueChange.call(this, 0, {
oldValue,
newValue,
context
})
}

const onInput = function(msg) {
if (msg.hasOwnProperty('payload')) {
// payload must be an object
Expand Down Expand Up @@ -106,13 +124,13 @@ module.exports = function(node) {
node.accessory.updateReachability(true)

if (context !== null) {
characteristic.updateValue(
characteristic.setValue(
msg.payload[key],
undefined,
context
)
} else {
characteristic.updateValue(msg.payload[key])
characteristic.setValue(msg.payload[key])
}
}
})
Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-homekit-bridged",
"version": "1.0.0-dev.6",
"version": "1.0.0-dev.7",
"description": "Node-RED nodes to simulate Apple HomeKit devices.",
"main": "homekit.js",
"scripts": {
Expand Down Expand Up @@ -39,7 +39,7 @@
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-prettier": "^3.1.2",
"husky": "^4.2.0",
"husky": "^4.2.1",
"mocha": "^7.0.0",
"node-red": "^1.0.3",
"node-red-node-test-helper": "^0.2.3",
Expand Down Expand Up @@ -96,11 +96,14 @@
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && yarn lint",
"pre-push": "yarn lint"
"pre-commit": "lint-staged && yarn lint",
"pre-push": "yarn lint"
},
"lint-staged": {
"*.js": ["eslint --fix", "git add"]
"*.js": [
"eslint --fix",
"git add"
]
}
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1778,10 +1778,10 @@ [email protected]:
agent-base "^4.3.0"
debug "^3.1.0"

husky@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/husky/-/husky-4.2.0.tgz#257dc349b1b2c7608351b6fe4cded003c5235819"
integrity sha512-UcEAvGAZVDyzYSxiguMBEbfxqYkVk/HD2UPTKlgDbVW3QB9/Dm3TNDrGwswkrcDfBTRzRIldiTZAyMU6DP9/PA==
husky@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/husky/-/husky-4.2.1.tgz#b09f1bd9129e6c323cc515dc17081d0615e2d7c1"
integrity sha512-Qa0lRreeIf4Tl92sSs42ER6qc3hzoyQPPorzOrFWfPEVbdi6LuvJEqWKPk905fOWIR76iBpp7ECZNIwk+a8xuQ==
dependencies:
chalk "^3.0.0"
ci-info "^2.0.0"
Expand Down

0 comments on commit b390951

Please sign in to comment.