Skip to content

Commit

Permalink
Fixed nrchkb complaining about validValues #52 (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaquu authored Jul 10, 2021
1 parent bc4c865 commit f2a5076
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.6]

### Fixed

- nrchkb complaining about validValues #52

## [1.3.5]

### Fixed
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-homekit-bridged",
"version": "1.3.5",
"version": "1.3.6",
"description": "Node-RED nodes to simulate Apple HomeKit devices.",
"main": "build/nodes/nrchkb.js",
"scripts": {
Expand Down
18 changes: 16 additions & 2 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,27 @@ module.exports = function (RED: NodeAPI) {
return
}

const validatedProps = props
if (validatedProps.validValues?.length === 0) {
validatedProps.validValues = undefined
}
if (
!validatedProps.validValueRanges?.[0] ||
!validatedProps.validValueRanges?.[1]
) {
validatedProps.validValueRanges = undefined
}
if (validatedProps.adminOnlyAccess?.length === 0) {
validatedProps.adminOnlyAccess = undefined
}

class CustomCharacteristic extends Characteristic {
static readonly UUID: string = UUID!

constructor() {
super(name!, CustomCharacteristic.UUID, {
...props,
perms: props.perms ?? [
...validatedProps,
perms: validatedProps.perms ?? [
Perms.PAIRED_READ,
Perms.PAIRED_WRITE,
Perms.NOTIFY,
Expand Down

0 comments on commit f2a5076

Please sign in to comment.