homebridge-rtl 0.0.32 → 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/npm-version-script.js +85 -0
- package/.github/workflows/Build and Publish.yml +125 -0
- package/README.md +31 -0
- package/package.json +23 -8
- package/sensor.js +40 -33
- package/test/hbConfig/.uix-dashboard.json +1 -0
- package/test/hbConfig/.uix-secrets +1 -0
- package/test/hbConfig/auth.json +10 -0
- package/test/hbConfig/config.json +46 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This scripts queries the npm registry to pull out the latest version for a given tag.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const assert = require('node:assert')
|
|
8
|
+
const child_process = require('node:child_process')
|
|
9
|
+
const fs = require('node:fs')
|
|
10
|
+
const process = require('node:process')
|
|
11
|
+
|
|
12
|
+
const semver = require('semver')
|
|
13
|
+
|
|
14
|
+
const BRANCH_VERSION_PATTERN = /^([A-Z]+)-(\d+\.\d+\.\d+)$/i
|
|
15
|
+
|
|
16
|
+
// Load the contents of the package.json file
|
|
17
|
+
const packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf8'))
|
|
18
|
+
|
|
19
|
+
const refArgument = process.argv[2]
|
|
20
|
+
const tagArgument = process.argv[3] || 'latest'
|
|
21
|
+
|
|
22
|
+
if (refArgument == null) {
|
|
23
|
+
console.error('ref argument is missing')
|
|
24
|
+
console.error('Usage: npm-version-script.js <ref> [tag]')
|
|
25
|
+
process.exit(1)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Queries the NPM registry for the latest version for the provided tag.
|
|
30
|
+
* @param tag The tag to query for.
|
|
31
|
+
* @returns {string} Returns the version.
|
|
32
|
+
*/
|
|
33
|
+
function getTagVersionFromNpm(tag) {
|
|
34
|
+
try {
|
|
35
|
+
return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString('utf8').trim()
|
|
36
|
+
} catch (e) {
|
|
37
|
+
console.error(`Failed to query the npm registry for the latest version for tag: ${tag}`)
|
|
38
|
+
// throw e;
|
|
39
|
+
return '0.0.0'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function desiredTargetVersion(ref) {
|
|
44
|
+
// ref is a GitHub action ref string
|
|
45
|
+
if (ref.startsWith('refs/pull/')) {
|
|
46
|
+
throw new Error('The version script was executed inside a PR!')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
assert(ref.startsWith('refs/heads/'))
|
|
50
|
+
const branchName = ref.slice('refs/heads/'.length)
|
|
51
|
+
|
|
52
|
+
const results = branchName.match(BRANCH_VERSION_PATTERN)
|
|
53
|
+
if (results != null) {
|
|
54
|
+
if (results[1] !== tagArgument) {
|
|
55
|
+
console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return results[2]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
throw new Error(`Malformed branch name for ref: ${ref}. Can't derive the base version. Use a branch name like: beta-x.x.x or alpha-x.x.x`)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// derive the base version from the branch ref
|
|
65
|
+
const baseVersion = desiredTargetVersion(refArgument)
|
|
66
|
+
|
|
67
|
+
// query the npm registry for the latest version of the provided tag name
|
|
68
|
+
const latestReleasedVersion = getTagVersionFromNpm(tagArgument) // e.g. 0.7.0-beta.12
|
|
69
|
+
const latestReleaseBase = semver.inc(latestReleasedVersion, 'patch') // will produce 0.7.0 (removing the preid, needed for the equality check below)
|
|
70
|
+
|
|
71
|
+
let publishTag
|
|
72
|
+
if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta or alpha
|
|
73
|
+
publishTag = latestReleasedVersion // set the current latest beta or alpha to be incremented
|
|
74
|
+
} else {
|
|
75
|
+
publishTag = baseVersion // start of with a new beta or alpha version
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// save the package.json
|
|
79
|
+
packageJSON.version = publishTag
|
|
80
|
+
fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2))
|
|
81
|
+
|
|
82
|
+
// perform the same change to the package-lock.json
|
|
83
|
+
const packageLockJSON = JSON.parse(fs.readFileSync('package-lock.json', 'utf8'))
|
|
84
|
+
packageLockJSON.version = publishTag
|
|
85
|
+
fs.writeFileSync('package-lock.json', JSON.stringify(packageLockJSON, null, 2))
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
name:
|
|
2
|
+
'Build, Publish and Release'
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# Automatically publish beta releases on pushes, require a manual workflow action for production releases
|
|
6
|
+
#
|
|
7
|
+
# Does the following
|
|
8
|
+
# 1 - Run the documentation script against the package
|
|
9
|
+
# 2 - Create the npm package using the package.json version tag ( or for beta releases, adds a beta tag and increments as needed )
|
|
10
|
+
# 3 - Publish the npm package
|
|
11
|
+
# 4 - For releases against the latest branch, create a github release as well
|
|
12
|
+
|
|
13
|
+
on:
|
|
14
|
+
push:
|
|
15
|
+
branches: [beta-*.*.*, beta]
|
|
16
|
+
workflow_dispatch:
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
get_tags:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
# checkout repo
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
# get branch / tag name
|
|
27
|
+
- name: Get Branch / Tag Name
|
|
28
|
+
id: get_branch
|
|
29
|
+
run: |
|
|
30
|
+
export BRANCH_NAME=$(if [[ ${GITHUB_REF} =~ "refs/tags/" ]]; then echo ${GITHUB_REF/refs\/tags\//}; else echo ${GITHUB_REF/refs\/heads\//}; fi)
|
|
31
|
+
echo $BRANCH_NAME
|
|
32
|
+
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
|
|
33
|
+
|
|
34
|
+
# generate the image tag
|
|
35
|
+
- name: Get Image Tag
|
|
36
|
+
id: get_tag
|
|
37
|
+
run: |
|
|
38
|
+
export TARGET_IMAGE_TAG=$(if [ "${{ steps.get_branch.outputs.BRANCH_NAME }}" = "main" ]; then echo "main"; else echo "${{ steps.get_branch.outputs.BRANCH_NAME }}" | awk -F- '{ print $1 }'; fi)
|
|
39
|
+
echo $TARGET_IMAGE_TAG
|
|
40
|
+
echo "TARGET_IMAGE_TAG=${TARGET_IMAGE_TAG}" >> $GITHUB_OUTPUT
|
|
41
|
+
|
|
42
|
+
outputs:
|
|
43
|
+
BRANCH_NAME: ${{ steps.get_branch.outputs.BRANCH_NAME }}
|
|
44
|
+
TARGET_IMAGE_TAG: ${{ steps.get_tag.outputs.TARGET_IMAGE_TAG }}
|
|
45
|
+
|
|
46
|
+
create_documentation:
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
|
|
49
|
+
steps:
|
|
50
|
+
# checkout repo
|
|
51
|
+
- uses: actions/checkout@v4
|
|
52
|
+
with:
|
|
53
|
+
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
|
|
54
|
+
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
|
|
55
|
+
|
|
56
|
+
- uses: actions/setup-node@v4
|
|
57
|
+
with:
|
|
58
|
+
node-version: lts/*
|
|
59
|
+
|
|
60
|
+
- name: Retrieve github-markdown-toc
|
|
61
|
+
run: |
|
|
62
|
+
wget -q https://raw.githubusercontent.com/ekalinin/github-markdown-toc/master/gh-md-toc
|
|
63
|
+
chmod a+x gh-md-toc
|
|
64
|
+
|
|
65
|
+
- name: Create Table of Contents
|
|
66
|
+
run: |
|
|
67
|
+
npm run-script document --if-present
|
|
68
|
+
rm gh-md-toc
|
|
69
|
+
|
|
70
|
+
- name: Commit files
|
|
71
|
+
run: |
|
|
72
|
+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
|
73
|
+
git config --local user.name "github-actions[bot]"
|
|
74
|
+
git add * || true
|
|
75
|
+
git commit -a -m "Update TOC" || true
|
|
76
|
+
|
|
77
|
+
- name: Push changes
|
|
78
|
+
uses: ad-m/github-push-action@master
|
|
79
|
+
with:
|
|
80
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
81
|
+
branch: ${{ github.ref }}
|
|
82
|
+
|
|
83
|
+
publish_prod_release:
|
|
84
|
+
permissions:
|
|
85
|
+
id-token: write
|
|
86
|
+
needs: [get_tags, create_documentation]
|
|
87
|
+
name: Publish Release Version
|
|
88
|
+
if: ${{ needs.get_tags.outputs.BRANCH_NAME == 'main' }}
|
|
89
|
+
uses: homebridge/.github/.github/workflows/npm-publish.yml@latest
|
|
90
|
+
with:
|
|
91
|
+
install_cmd: npm ci
|
|
92
|
+
secrets:
|
|
93
|
+
npm_auth_token: ${{ secrets.NPM_TOKEN }}
|
|
94
|
+
|
|
95
|
+
publish_test_release:
|
|
96
|
+
permissions:
|
|
97
|
+
id-token: write
|
|
98
|
+
needs: [get_tags, create_documentation]
|
|
99
|
+
name: Publish Test Version - ${{ needs.get_tags.outputs.BRANCH_NAME }}
|
|
100
|
+
if: ${{ needs.get_tags.outputs.BRANCH_NAME != 'main' }}
|
|
101
|
+
uses: homebridge/.github/.github/workflows/npm-publish.yml@latest
|
|
102
|
+
with:
|
|
103
|
+
tag: ${{ needs.get_tags.outputs.TARGET_IMAGE_TAG }}
|
|
104
|
+
dynamically_adjust_version: true
|
|
105
|
+
npm_version_command: pre
|
|
106
|
+
pre_id: ${{ needs.get_tags.outputs.TARGET_IMAGE_TAG }}
|
|
107
|
+
install_cmd: npm ci
|
|
108
|
+
secrets:
|
|
109
|
+
npm_auth_token: ${{ secrets.NPM_TOKEN }}
|
|
110
|
+
|
|
111
|
+
publish_github_release:
|
|
112
|
+
needs: [publish_prod_release]
|
|
113
|
+
runs-on: ubuntu-latest
|
|
114
|
+
steps:
|
|
115
|
+
- uses: actions/checkout@v4
|
|
116
|
+
- name: Create Release
|
|
117
|
+
uses: softprops/action-gh-release@v1
|
|
118
|
+
env:
|
|
119
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
120
|
+
with:
|
|
121
|
+
tag_name: ${{ needs.publish_prod_release.outputs.NPM_VERSION }}
|
|
122
|
+
name: Release ${{ needs.publish_prod_release.outputs.NPM_VERSION }}
|
|
123
|
+
generate_release_notes: true
|
|
124
|
+
draft: false
|
|
125
|
+
prerelease: false
|
package/README.md
CHANGED
|
@@ -30,6 +30,9 @@ I have tested this on both a Mac and a RPI3
|
|
|
30
30
|
|
|
31
31
|
## Configuration
|
|
32
32
|
* `platform`: "rtl_433"
|
|
33
|
+
* `rtl433Path`: by default this is "/usr/local/bin/"; for windows, the directory rtl433 exe is located. End this with a \.
|
|
34
|
+
* `rtl433Bin`: by default this is "rtl_433"; for windows, this is the exe.
|
|
35
|
+
* `killCommand`: by default this is "pkill"; for windows, this is taskkill /IM, however, the service may not have sufficient privileges to do this. " " for no command.
|
|
33
36
|
* `name`: "Front Porch" - Name of device for display in the Home App
|
|
34
37
|
* `id`: id number of device - To find the ID of your device, run homebridge in DEBUG mode, and it will log the message received from all rtl_433 devices. See below for examples
|
|
35
38
|
* `type`: Type of sensor device. Supported sensors are `motion`, `temperature`, `humidity`, and `contact`
|
|
@@ -61,6 +64,34 @@ Example configuration:
|
|
|
61
64
|
}]
|
|
62
65
|
```
|
|
63
66
|
|
|
67
|
+
Example windows configuration:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
"platforms": [{
|
|
71
|
+
"platform": "rtl_433",
|
|
72
|
+
"rtl433Path": "c:\\temp\\",
|
|
73
|
+
"rtp433Bin": "rtl_433_64bit_static.exe",
|
|
74
|
+
"killCommand": " ",
|
|
75
|
+
"devices": [
|
|
76
|
+
{
|
|
77
|
+
"id": "1e3e8",
|
|
78
|
+
"name": "Front Porch",
|
|
79
|
+
"type": "motion"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"id": "92",
|
|
83
|
+
"name": "Outside temperature",
|
|
84
|
+
"type": "temperature"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "834551",
|
|
88
|
+
"name": "Front Door Sensor",
|
|
89
|
+
"type": "contact"
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}]
|
|
93
|
+
```
|
|
94
|
+
|
|
64
95
|
## Sample log file entries from homebridge to determine sensor ID
|
|
65
96
|
|
|
66
97
|
* Motion sensor log entries
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-rtl",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
4
|
"description": "RTL_433 based sensor for Homebridge",
|
|
5
5
|
"main": "sensor.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"watch": "nodemon"
|
|
8
9
|
},
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
11
|
-
"url": "git://github.com/
|
|
12
|
+
"url": "git+https://github.com/NorthernMan54/homebridge-rtl"
|
|
12
13
|
},
|
|
13
14
|
"keywords": [
|
|
14
15
|
"homebridge-plugin",
|
|
@@ -25,18 +26,32 @@
|
|
|
25
26
|
"url": "https://github.com/northernman54/homebridge-rtl/issues"
|
|
26
27
|
},
|
|
27
28
|
"engines": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
29
|
+
"homebridge": "^1.6.0",
|
|
30
|
+
"node": "^18.20.4 || ^20.15.1 || ^22.0.0"
|
|
30
31
|
},
|
|
31
32
|
"homepage": "https://github.com/northernman54/homebridge-rtl#readme",
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"debug": "^
|
|
34
|
-
"fakegato-history": "^0.5
|
|
34
|
+
"debug": "^4.3.7",
|
|
35
|
+
"fakegato-history": "^0.6.5",
|
|
35
36
|
"lodash": "^4.17.20",
|
|
36
37
|
"mcuiot-logger": "0.0.12",
|
|
37
|
-
"moment": "^2.18.1"
|
|
38
|
+
"moment": "^2.18.1",
|
|
39
|
+
"nodemon": "^3.1.7",
|
|
40
|
+
"semver": "^7.6.3"
|
|
38
41
|
},
|
|
39
42
|
"directories": {
|
|
40
43
|
"lib": "lib"
|
|
44
|
+
},
|
|
45
|
+
"nodemonConfig": {
|
|
46
|
+
"watch": [
|
|
47
|
+
"src"
|
|
48
|
+
],
|
|
49
|
+
"ext": "ts",
|
|
50
|
+
"ignore": [],
|
|
51
|
+
"exec": "~/npm/bin/homebridge -U ./test/hbConfig -T -D -P .",
|
|
52
|
+
"signal": "SIGTERM",
|
|
53
|
+
"env": {
|
|
54
|
+
"NODE_OPTIONS": "--trace-warnings"
|
|
55
|
+
}
|
|
41
56
|
}
|
|
42
57
|
}
|
package/sensor.js
CHANGED
|
@@ -27,7 +27,10 @@ function rtl433Plugin(log, config, api) {
|
|
|
27
27
|
this.refresh = config['refresh'] || 60; // Update every minute
|
|
28
28
|
this.options = config.options || {};
|
|
29
29
|
this.storage = config['storage'] || "fs";
|
|
30
|
-
|
|
30
|
+
//8/28/2022 JDR added this for Windows.
|
|
31
|
+
this.rtl433Path = config['rtl433Path'] || "/usr/local/bin/";
|
|
32
|
+
this.rtl433Bin = config['rtl433Bin'] || "rtl_433";
|
|
33
|
+
this.killCommand = config['killCommand'] || ("pkill " + this.rtl433Bin);// for linux/mac windows: taskkill /im "rtl_433_64bit_static.exe"
|
|
31
34
|
this.spreadsheetId = config['spreadsheetId'];
|
|
32
35
|
this.devices = config['devices'];
|
|
33
36
|
|
|
@@ -38,7 +41,7 @@ function rtl433Plugin(log, config, api) {
|
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
rtl433Plugin.prototype = {
|
|
41
|
-
accessories: function(callback) {
|
|
44
|
+
accessories: function (callback) {
|
|
42
45
|
for (var i in this.devices) {
|
|
43
46
|
this.log("Adding device", i, this.devices[i].name);
|
|
44
47
|
myAccessories.push(new Rtl433Accessory(this.devices[i], this.log, i));
|
|
@@ -54,16 +57,18 @@ function rtl433Server() {
|
|
|
54
57
|
var childProcess = require('child_process');
|
|
55
58
|
var readline = require('readline');
|
|
56
59
|
var previousMessage;
|
|
57
|
-
this.log("Spawning rtl_433");
|
|
60
|
+
this.log("Spawning rtl_433 " + this.killCommand + '; ' + this.rtl433Path + this.rtl433Bin);
|
|
58
61
|
// if you start rtl_433 outside homebride to get log: rtl_433 -v -F json -C si -M protocol > /tmp/rtl433.json
|
|
59
62
|
//var proc = childProcess.spawn('/usr/bin/truncate -s 0 /tmp/rtl433.json;/usr/bin/tail', ['-F','/tmp/rtl433.json'], {
|
|
60
|
-
|
|
63
|
+
////8/28/2022 JDR added this for Windows. fixed command line arguments. They weren't working for Windows, but should still work for others.
|
|
64
|
+
var proc = childProcess.spawn(this.killCommand + '; ' + this.rtl433Path + this.rtl433Bin, ['-d 0', '-F json', '-C si'], {
|
|
61
65
|
shell: true
|
|
62
|
-
|
|
66
|
+
});
|
|
63
67
|
readline.createInterface({
|
|
64
68
|
input: proc.stdout,
|
|
65
69
|
terminal: false
|
|
66
|
-
}).on('line', function(message) {
|
|
70
|
+
}).on('line', function (message) {
|
|
71
|
+
this.log("Message", message.toString());
|
|
67
72
|
debug("Message", message.toString());
|
|
68
73
|
|
|
69
74
|
if (message.toString().startsWith('{')) {
|
|
@@ -96,17 +101,17 @@ function rtl433Server() {
|
|
|
96
101
|
}
|
|
97
102
|
}
|
|
98
103
|
}.bind(this));
|
|
99
|
-
proc.on('close', function(code) {
|
|
104
|
+
proc.on('close', function (code) {
|
|
100
105
|
this.log.error('child close code (spawn)', code);
|
|
101
106
|
setTimeout(rtl433Server.bind(this), 10 * 1000);
|
|
102
107
|
}.bind(this));
|
|
103
|
-
proc.on('disconnect', function(code) {
|
|
108
|
+
proc.on('disconnect', function (code) {
|
|
104
109
|
this.log.error('child disconnect code (spawn)', code);
|
|
105
110
|
}.bind(this));
|
|
106
|
-
proc.on('error', function(code) {
|
|
111
|
+
proc.on('error', function (code) {
|
|
107
112
|
this.log.error('child error code (spawn)', code);
|
|
108
113
|
}.bind(this));
|
|
109
|
-
proc.on('exit', function(code) {
|
|
114
|
+
proc.on('exit', function (code) {
|
|
110
115
|
this.log.error('child exit code (spawn)', code);
|
|
111
116
|
}.bind(this));
|
|
112
117
|
}
|
|
@@ -122,7 +127,7 @@ function Rtl433Accessory(device, log, unit) {
|
|
|
122
127
|
}
|
|
123
128
|
|
|
124
129
|
Rtl433Accessory.prototype = {
|
|
125
|
-
updateStatus: function(data) {
|
|
130
|
+
updateStatus: function (data) {
|
|
126
131
|
try {
|
|
127
132
|
this.log("Updating", this.name);
|
|
128
133
|
this.lastUpdated = Date.now();
|
|
@@ -207,10 +212,10 @@ Rtl433Accessory.prototype = {
|
|
|
207
212
|
break;
|
|
208
213
|
case "motion":
|
|
209
214
|
// {"time" : "2018-09-30 19:20:26", "model" : "Skylink HA-434TL motion sensor", "motion" : "true", "id" : "1e3e8", "raw" : "be3e8"}
|
|
210
|
-
|
|
215
|
+
// {"time" : "2022-03-17 21:58:46.319049", "protocol" : 68, "model" : "Kerui-Security", "id" : 840811, "cmd" : 10, "motion" : 1, "state" : "motion" }
|
|
211
216
|
// debug("update motion this--->",this);
|
|
212
217
|
|
|
213
|
-
|
|
218
|
+
var value = (data.motion === "true" || data.motion === 1 ? true : false);
|
|
214
219
|
if (this.sensorService.getCharacteristic(Characteristic.MotionDetected).value !== value) {
|
|
215
220
|
this.sensorService.getCharacteristic(CustomCharacteristic.LastActivation)
|
|
216
221
|
.updateValue(moment().unix() - this.loggingService.getInitialTime());
|
|
@@ -224,7 +229,7 @@ Rtl433Accessory.prototype = {
|
|
|
224
229
|
|
|
225
230
|
if (value) {
|
|
226
231
|
clearTimeout(this.motionTimeout);
|
|
227
|
-
this.motionTimeout = setTimeout(function() {
|
|
232
|
+
this.motionTimeout = setTimeout(function () {
|
|
228
233
|
var value = false;
|
|
229
234
|
if (this.sensorService.getCharacteristic(Characteristic.MotionDetected).value !== value) {
|
|
230
235
|
this.sensorService.getCharacteristic(CustomCharacteristic.LastActivation)
|
|
@@ -241,22 +246,22 @@ Rtl433Accessory.prototype = {
|
|
|
241
246
|
|
|
242
247
|
break;
|
|
243
248
|
case "contact":
|
|
244
|
-
|
|
245
|
-
|
|
249
|
+
// {"time" : "2022-03-17 23:04:08.430623", "protocol" : 68, "model" : "Kerui-Security", "id" : 297536, "cmd" : 14, "opened" : 1, "state" : "open" }
|
|
250
|
+
// {"time" : "2022-03-17 23:04:19.447761", "protocol" : 68, "model" : "Kerui-Security", "id" : 297536, "cmd" : 7, "opened" : 0, "state" : "close" }
|
|
246
251
|
// debug("update door this--->",this);
|
|
247
252
|
// console.log("update door this--->",this);
|
|
248
253
|
|
|
249
254
|
this.sensorService
|
|
250
|
-
|
|
255
|
+
.setCharacteristic(Characteristic.ContactSensorState, (data.opened === 1 ? Characteristic.ContactSensorState.CONTACT_NOT_DETECTED : Characteristic.ContactSensorState.CONTACT_DETECTED));
|
|
251
256
|
|
|
252
|
-
|
|
253
|
-
|
|
257
|
+
//this.timeout = setTimeout(deviceTimeout.bind(this), this.deviceTimeout * 60 * 1000);
|
|
258
|
+
clearTimeout(this.timeout);
|
|
254
259
|
|
|
255
260
|
if (data.battery !== undefined || data.battery_ok != undefined) {
|
|
256
261
|
this.sensorService
|
|
257
|
-
|
|
262
|
+
.setCharacteristic(Characteristic.StatusLowBattery, (data.battery === "OK" || data.battery_ok === 1 ? Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL : Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW));
|
|
258
263
|
}
|
|
259
|
-
|
|
264
|
+
break;
|
|
260
265
|
|
|
261
266
|
default:
|
|
262
267
|
this.log.error("No events defined for sensor type %s", this.type);
|
|
@@ -266,7 +271,7 @@ Rtl433Accessory.prototype = {
|
|
|
266
271
|
}
|
|
267
272
|
},
|
|
268
273
|
|
|
269
|
-
getServices: function() {
|
|
274
|
+
getServices: function () {
|
|
270
275
|
this.log("getServices", this.name);
|
|
271
276
|
// Information Service
|
|
272
277
|
var informationService = new Service.AccessoryInformation();
|
|
@@ -294,7 +299,8 @@ Rtl433Accessory.prototype = {
|
|
|
294
299
|
this.sensorService.log = this.log;
|
|
295
300
|
this.loggingService = new FakeGatoHistoryService("weather", this.sensorService, {
|
|
296
301
|
storage: this.storage,
|
|
297
|
-
minutes: this.refresh * 10 / 60
|
|
302
|
+
minutes: this.refresh * 10 / 60,
|
|
303
|
+
disableRepeatLastData: true
|
|
298
304
|
});
|
|
299
305
|
if (this.alarm !== undefined) {
|
|
300
306
|
this.alarmService = new Service.ContactSensor(this.name + " Alarm");
|
|
@@ -321,7 +327,8 @@ Rtl433Accessory.prototype = {
|
|
|
321
327
|
this.sensorService.log = this.log;
|
|
322
328
|
this.loggingService = new FakeGatoHistoryService("weather", this.sensorService, {
|
|
323
329
|
storage: this.storage,
|
|
324
|
-
minutes: this.refresh * 10 / 60
|
|
330
|
+
minutes: this.refresh * 10 / 60,
|
|
331
|
+
disableRepeatLastData: true
|
|
325
332
|
});
|
|
326
333
|
if (this.alarm !== undefined) {
|
|
327
334
|
this.alarmService = new Service.ContactSensor(this.name + " Alarm");
|
|
@@ -349,17 +356,17 @@ Rtl433Accessory.prototype = {
|
|
|
349
356
|
.setCharacteristic(Characteristic.Model, "Motion Sensor");
|
|
350
357
|
break;
|
|
351
358
|
case "contact":
|
|
352
|
-
|
|
353
|
-
|
|
359
|
+
// debug("get door this--->",this);
|
|
360
|
+
// console.log("get door this--->",this);
|
|
354
361
|
|
|
355
|
-
|
|
356
|
-
|
|
362
|
+
this.sensorService = new Service.ContactSensor(this.name);
|
|
363
|
+
this.sensorService.addCharacteristic(CustomCharacteristic.LastActivation);
|
|
357
364
|
|
|
358
|
-
|
|
359
|
-
|
|
365
|
+
//this.timeoutCharacteristic = Characteristic.ContactSensorState;
|
|
366
|
+
//this.timeout = setTimeout(deviceTimeout.bind(this), this.deviceTimeout * 60 * 1000); // 5 minutes
|
|
360
367
|
|
|
361
|
-
|
|
362
|
-
|
|
368
|
+
this.sensorService.log = this.log;
|
|
369
|
+
informationService
|
|
363
370
|
.setCharacteristic(Characteristic.Model, "Contact Sensor");
|
|
364
371
|
break;
|
|
365
372
|
|
|
@@ -378,7 +385,7 @@ Rtl433Accessory.prototype = {
|
|
|
378
385
|
function deviceTimeout() {
|
|
379
386
|
this.log("Timeout", this.name);
|
|
380
387
|
|
|
381
|
-
if (this.sensorService !== undefined && this.timeoutCharacteristic !== undefined
|
|
388
|
+
if (this.sensorService !== undefined && this.timeoutCharacteristic !== undefined)
|
|
382
389
|
this.sensorService
|
|
383
390
|
.getCharacteristic(this.timeoutCharacteristic).updateValue(new Error("No response"));
|
|
384
391
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"component":"HomebridgeStatusWidgetComponent","x":0,"y":7,"cols":5,"rows":7,"mobileOrder":10,"hidePort":true,"hideOnMobile":false,"draggable":true},{"component":"ChildBridgeWidgetComponent","x":15,"y":9,"cols":5,"rows":5,"mobileOrder":35,"hideOnMobile":false,"draggable":true},{"component":"CpuWidgetComponent","x":5,"y":8,"cols":5,"rows":3,"mobileOrder":40,"hideOnMobile":false,"draggable":true},{"component":"MemoryWidgetComponent","x":5,"y":11,"cols":5,"rows":3,"mobileOrder":50,"hideOnMobile":false,"draggable":true},{"component":"NetworkWidgetComponent","x":10,"y":11,"cols":5,"rows":3,"mobileOrder":55,"hideOnMobile":false,"draggable":true},{"component":"UptimeWidgetComponent","x":10,"y":8,"cols":5,"rows":3,"mobileOrder":60,"hideOnMobile":false,"draggable":true},{"component":"SystemInfoWidgetComponent","x":15,"y":0,"cols":5,"rows":9,"mobileOrder":70,"hideOnMobile":false,"draggable":true},{"component":"HapQrcodeWidgetComponent","x":0,"y":0,"cols":5,"rows":7,"mobileOrder":100,"hideOnMobile":false,"draggable":true},{"component":"HomebridgeLogsWidgetComponent","x":5,"y":0,"cols":10,"rows":8,"mobileOrder":1000,"hideOnMobile":true,"draggable":true}]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"secretKey":"de1a0f965770285a6dec91739fc725a91d6e0cb91a4aaae8116e8f140d44edc3"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": 1,
|
|
4
|
+
"username": "test",
|
|
5
|
+
"name": "test",
|
|
6
|
+
"hashedPassword": "df121e72b850a058bd68f3d05b1f94dc985821a3885b5da38e263654f29843f98bb6d8e594f6042ff871a424602a9bff50dffa97f258bdc1dca4c79e87bac20c",
|
|
7
|
+
"salt": "64085e70da64670349f042d4c3d3cac75b20233ffeb71db68399973f60da077d",
|
|
8
|
+
"admin": true
|
|
9
|
+
}
|
|
10
|
+
]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bridge": {
|
|
3
|
+
"name": "Heisenberg",
|
|
4
|
+
"username": "AA:BB:CC:DD:EE:01",
|
|
5
|
+
"port": 51826,
|
|
6
|
+
"pin": "031-45-154"
|
|
7
|
+
},
|
|
8
|
+
"description": "HomeBridge HTTP Status Control",
|
|
9
|
+
"plugins": [
|
|
10
|
+
"homebridge-rtl",
|
|
11
|
+
"homebridge-config-ui-x"
|
|
12
|
+
],
|
|
13
|
+
"platforms": [
|
|
14
|
+
{
|
|
15
|
+
"name": "Config",
|
|
16
|
+
"port": 8581,
|
|
17
|
+
"auth": "none",
|
|
18
|
+
"theme": "auto",
|
|
19
|
+
"tempUnits": "c",
|
|
20
|
+
"lang": "auto",
|
|
21
|
+
"sudo": false,
|
|
22
|
+
"platform": "config"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"platform": "rtl_433",
|
|
26
|
+
"devices": [
|
|
27
|
+
{
|
|
28
|
+
"id": "1e3e8",
|
|
29
|
+
"name": "Front Porch",
|
|
30
|
+
"type": "motion"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "92",
|
|
34
|
+
"name": "Outside temperature",
|
|
35
|
+
"type": "temperature"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "834551",
|
|
39
|
+
"name": "Front Door Sensor",
|
|
40
|
+
"type": "contact"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"accessories": []
|
|
46
|
+
}
|