From 7cc32ee4fd65f42740d5a2236eb42af2250f4945 Mon Sep 17 00:00:00 2001 From: moritzmhmk Date: Sun, 9 May 2021 11:34:00 +0200 Subject: [PATCH 01/14] add waterLevel as optional characteristic of leakSensor --- index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.js b/index.js index 5e776a0..a2c0bff 100644 --- a/index.js +++ b/index.js @@ -1991,6 +1991,12 @@ function makeThing( log, accessoryConfig, api ) { }, undefined, config.resetStateAfterms ); } + // Characteristic.WaterLevel + function characteristic_WaterLevel( service ) { + let options = { minValue: 0, maxValue: 100 } + integerCharacteristic( service, 'waterLevel', Characteristic.WaterLevel, config.topics.setWaterLevel, config.topics.getWaterLevel, options); + } + // Characteristic.TargetPosition function characteristic_TargetPosition( service ) { integerCharacteristic( service, 'targetPosition', Characteristic.TargetPosition, config.topics.setTargetPosition, config.topics.getTargetPosition ); @@ -2945,6 +2951,9 @@ function makeThing( log, accessoryConfig, api ) { } else if( configType == "leakSensor" ) { service = new Service.LeakSensor( name, subtype ); characteristic_LeakDetected( service ); + if( config.topics.setWaterLevel || config.topics.getWaterLevel ) { + characteristic_WaterLevel( service ); + } addSensorOptionalCharacteristics( service ); } else if( configType == "microphone" ) { service = new Service.Microphone( name, subtype ); From 7ba866cf05b5bc8a01d0cb7ccd47846f66a6de86 Mon Sep 17 00:00:00 2001 From: 2610 Date: Fri, 28 May 2021 00:21:23 +0100 Subject: [PATCH 02/14] Update index.js Addition of MaximumWindSpeed & Dewpoint to Weather --- index.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/index.js b/index.js index 5e776a0..952a1e9 100644 --- a/index.js +++ b/index.js @@ -1687,6 +1687,18 @@ function makeThing( log, accessoryConfig, api ) { floatCharacteristic( service, 'windSpeed', Eve.Characteristics.WindSpeed, null, config.topics.getWindSpeed, 0 ); } + // Characteristic.maxWind (Eve-only) + function characteristic_MaximumWindSpeed( service ) { + service.addOptionalCharacteristic( Eve.Characteristics.MaximumWindSpeed ); // to avoid warnings + floatCharacteristic( service, 'maxWind', Eve.Characteristics.MaximumWindSpeed, null, config.topics.getmaxWind, 0 ); + } + + // Characteristic.Dewpoint(Eve-only) + function characteristic_DewPoint( service ) { + service.addOptionalCharacteristic( Eve.Characteristics.DewPoint ); // to avoid warnings + floatCharacteristic( service, 'DewPoint', Eve.Characteristics.DewPoint, null, config.topics.getDewPoint, 0 ); + } + // Characteristic.ContactSensorState function characteristic_ContactSensorState( service ) { booleanCharacteristic( service, 'contactSensorState', Characteristic.ContactSensorState, @@ -2813,6 +2825,14 @@ function makeThing( log, accessoryConfig, api ) { if( config.topics.getWindSpeed ) { characteristic_WindSpeed( weatherSvc ); addWeatherSvc = true; + } + if( config.topics.getmaxWind ) { + characteristic_MaximumWindSpeed( weatherSvc ); + addWeatherSvc = true; + } + if( config.topics.getDewPoint ) { + characteristic_DewPoint( weatherSvc ); + addWeatherSvc = true; } if( addWeatherSvc ) { services.push( weatherSvc ); From aea39ca8e8bc9536b0276145996a57f46002285d Mon Sep 17 00:00:00 2001 From: 2610 Date: Fri, 28 May 2021 00:26:00 +0100 Subject: [PATCH 03/14] Update config.schema.json Addition to Dewpoint and Maxwindspeed --- config.schema.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config.schema.json b/config.schema.json index 8549b8a..08c52ae 100644 --- a/config.schema.json +++ b/config.schema.json @@ -531,6 +531,20 @@ "condition": { "functionBody": "return ['weatherStation'].includes(model.type);" } + }, + "getmaxWind": { + "type": "string", + "description": "Topic used to notify mqttthing of 'wind speed [km/h]' (optional, Eve-only)", + "condition": { + "functionBody": "return ['weatherStation'].includes(model.type);" + } + }, + "getDewPoint": { + "type": "string", + "description": "Topic used to notify mqttthing of 'DewPoint' (optional, Eve-only)", + "condition": { + "functionBody": "return ['weatherStation'].includes(model.type);" + } }, "getActive": { "type": "string", From daee0b82099e1744523d28a419b29d7d55c15f3e Mon Sep 17 00:00:00 2001 From: 2610 Date: Fri, 28 May 2021 00:28:21 +0100 Subject: [PATCH 04/14] Update Codecs.md Addition of Dewpoint max wind speed --- docs/Codecs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Codecs.md b/docs/Codecs.md index 9caee7f..34da757 100644 --- a/docs/Codecs.md +++ b/docs/Codecs.md @@ -251,7 +251,7 @@ This section lists the properties available for each accessory type. All accesso ### Weather Station -`currentTemperature`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery`, `currentRelativeHumidity`, `airPressure`, `weatherCondition`, `rain1h`, `rain24h`, `uvIndex`, `visibility`, `windDirection`, `windSpeed` +`currentTemperature`, `statusActive`, `statusFault`, `statusTampered`, `statusLowBattery`, `currentRelativeHumidity`, `airPressure`, `weatherCondition`, `rain1h`, `rain24h`, `uvIndex`, `visibility`, `windDirection`, `windSpeed`, `maxwindSpeed`, `Dewpoint` ### Window From 50744802e5a84b42ca60e2955aec7a69db6bef88 Mon Sep 17 00:00:00 2001 From: Brian White Date: Wed, 7 Jul 2021 14:18:52 -0400 Subject: [PATCH 05/14] Update Configuration.md fix typo from "within the configured configuration period" to "within the configured confirmation period" --- docs/Configuration.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index 6bd0b12..b69a779 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -224,7 +224,7 @@ Avoid the use of "/" in characteristics of the Information Service (e.g. serial ### Confirmation -Some accessories support confirmation for some of their 'set' topics. When enabled by configuring `confirmationPeriodms`, the accessory *must* echo anything sent to appropriate `setX` subject(s) to the corresponding `getX` subject(s). Where homebridge-mqttthing doesn't see a confirmation within the configured configuration period (specified in milliseconds), it will publish the set message again. Messages will be republished up to 3 times by default, but this can be changed by also specifying `retryLimit`. +Some accessories support confirmation for some of their 'set' topics. When enabled by configuring `confirmationPeriodms`, the accessory *must* echo anything sent to appropriate `setX` subject(s) to the corresponding `getX` subject(s). Where homebridge-mqttthing doesn't see a confirmation within the configured confirmation period (specified in milliseconds), it will publish the set message again. Messages will be republished up to 3 times by default, but this can be changed by also specifying `retryLimit`. Accessories supporting message confirmation list the topics supporting message confirmation below. @@ -305,4 +305,4 @@ Any settings which apply to all services may be defined within the custom-type a Custom accessories are only intended for use with simple services, not with accessories like 'weather station' which already combine multiple services. -Custom accessories cannot be configured through Config UI X. \ No newline at end of file +Custom accessories cannot be configured through Config UI X. From a12a432513f89c4e9f5121f3f2648ddafdf0ce7e Mon Sep 17 00:00:00 2001 From: Antonio Yip Date: Thu, 26 Aug 2021 22:30:05 +0800 Subject: [PATCH 06/14] using jsonpath --- index.js | 25 ++++- package-lock.json | 277 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 1 + 3 files changed, 299 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 32dd249..e392f25 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,7 @@ var homebridgeLib = require( 'homebridge-lib' ); var fakegatoHistory = require( 'fakegato-history' ); var fs = require( "fs" ); var path = require( "path" ); +var jp = require( "jsonpath" ); var mqttlib = require( './libs/mqttlib' ); const EventEmitter = require( 'events' ); @@ -46,8 +47,28 @@ function makeThing( log, accessoryConfig, api ) { } // MQTT Subscribe - function mqttSubscribe( topic, property, handler ) { - mqttlib.subscribe( ctx, topic, property, handler ); + function mqttSubscribe( topicWithJsonpath, property, handler ) { + let jsonpathIndex = topicWithJsonpath.indexOf('$'); + let topic = jsonpathIndex > 0 ? topicWithJsonpath.substring(0, jsonpathIndex) : topicWithJsonpath + let query = topicWithJsonpath.substring(jsonpathIndex); + + mqttlib.subscribe( ctx, topic, property, function( topic, message ) { + log.debug(topic, String(message)); + + if (jsonpathIndex > 0 && query.length > 0) { + try { + let json = JSON.parse(message); + let values = jp.query(json, query); + log.debug(topic, query, values); + handler(topic, values.shift()); + } catch(error) { + log.error(topic, "error:", error, "message:", message); + handler(topic, message); + } + } else { + handler(topic, message); + } + }); } // MQTT Publish diff --git a/package-lock.json b/package-lock.json index ee6b564..189ba30 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,17 @@ { "name": "homebridge-mqttthing", - "version": "1.1.28", + "version": "1.1.30", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "1.1.28", + "name": "homebridge-mqttthing", + "version": "1.1.30", "license": "Apache-2.0", "dependencies": { "fakegato-history": "^0.6.1", "homebridge-lib": "~5.1.4", + "jsonpath": "^1.1.1", "mqtt": "^4.2.6" }, "engines": { @@ -338,6 +340,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" + }, "node_modules/define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", @@ -450,6 +457,67 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/escodegen": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", + "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", + "dependencies": { + "esprima": "^4.0.1", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1" + }, + "bin": { + "escodegen": "bin/escodegen.js", + "esgenerate": "bin/esgenerate.js" + }, + "engines": { + "node": ">=4.0" + }, + "optionalDependencies": { + "source-map": "~0.6.1" + } + }, + "node_modules/escodegen/node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/esprima": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz", + "integrity": "sha1-dqD9Zvz+FU/SkmZ9wmQBl1CxZXs=", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -476,6 +544,11 @@ "node": ">=4.3.2" } }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + }, "node_modules/fast-text-encoding": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.3.tgz", @@ -1062,6 +1135,16 @@ "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=" }, + "node_modules/jsonpath": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.1.1.tgz", + "integrity": "sha512-l6Cg7jRpixfbgoWgkrl77dgEj8RPvND0wMH6TwQmi9Qs4TFfS9u5cUFnbeKTwj5ga5Y3BTGGNI28k117LJ009w==", + "dependencies": { + "esprima": "1.2.2", + "static-eval": "2.0.2", + "underscore": "1.12.1" + } + }, "node_modules/jwa": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz", @@ -1089,6 +1172,18 @@ "node": ">=0.10.0" } }, + "node_modules/levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dependencies": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -1303,6 +1398,22 @@ "wrappy": "1" } }, + "node_modules/optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "dependencies": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/ordered-read-streams": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz", @@ -1324,6 +1435,14 @@ "node": ">=0.10.0" } }, + "node_modules/prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -1466,6 +1585,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "optional": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/split2": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", @@ -1487,6 +1615,14 @@ "node": ">= 6" } }, + "node_modules/static-eval": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz", + "integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==", + "dependencies": { + "escodegen": "^1.8.1" + } + }, "node_modules/stream-shift": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", @@ -1575,6 +1711,17 @@ "node": ">=0.10.0" } }, + "node_modules/type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dependencies": { + "prelude-ls": "~1.1.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", @@ -1602,6 +1749,11 @@ "node": ">=0.10.0" } }, + "node_modules/underscore": { + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz", + "integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==" + }, "node_modules/unique-stream": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.3.1.tgz", @@ -1678,6 +1830,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -1961,6 +2121,11 @@ "which-typed-array": "^1.1.2" } }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" + }, "define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", @@ -2052,6 +2217,40 @@ "is-symbol": "^1.0.2" } }, + "escodegen": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", + "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", + "requires": { + "esprima": "^4.0.1", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.6.1" + }, + "dependencies": { + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + } + } + }, + "esprima": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz", + "integrity": "sha1-dqD9Zvz+FU/SkmZ9wmQBl1CxZXs=" + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==" + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" + }, "event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -2071,6 +2270,11 @@ "googleapis": ">39.1.0" } }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=" + }, "fast-text-encoding": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.3.tgz", @@ -2475,6 +2679,16 @@ "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=" }, + "jsonpath": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.1.1.tgz", + "integrity": "sha512-l6Cg7jRpixfbgoWgkrl77dgEj8RPvND0wMH6TwQmi9Qs4TFfS9u5cUFnbeKTwj5ga5Y3BTGGNI28k117LJ009w==", + "requires": { + "esprima": "1.2.2", + "static-eval": "2.0.2", + "underscore": "1.12.1" + } + }, "jwa": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz", @@ -2499,6 +2713,15 @@ "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=" }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -2657,6 +2880,19 @@ "wrappy": "1" } }, + "optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + } + }, "ordered-read-streams": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz", @@ -2675,6 +2911,11 @@ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=" + }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -2786,6 +3027,12 @@ "object-inspect": "^1.9.0" } }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "optional": true + }, "split2": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/split2/-/split2-3.2.2.tgz", @@ -2806,6 +3053,14 @@ } } }, + "static-eval": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz", + "integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==", + "requires": { + "escodegen": "^1.8.1" + } + }, "stream-shift": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz", @@ -2884,6 +3139,14 @@ "is-negated-glob": "^1.0.0" } }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "requires": { + "prelude-ls": "~1.1.2" + } + }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", @@ -2905,6 +3168,11 @@ "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=" }, + "underscore": { + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz", + "integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==" + }, "unique-stream": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.3.1.tgz", @@ -2966,6 +3234,11 @@ "is-typed-array": "^1.1.3" } }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==" + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index 20e9dfb..3808e94 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "dependencies": { "fakegato-history": "^0.6.1", "homebridge-lib": "~5.1.4", + "jsonpath": "^1.1.1", "mqtt": "^4.2.6" } } From 016960468d169ba7f846f4da3ddf502214808c0c Mon Sep 17 00:00:00 2001 From: Donavan Becker Date: Fri, 8 Oct 2021 11:02:35 -0500 Subject: [PATCH 07/14] Require node.js 14 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 29d4f72..495f628 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "start": "homebridge -P . -U test" }, "engines": { - "node": ">4.0.0", - "homebridge": ">=0.2.0" + "homebridge": "^1.3.5", + "node": "^14.18.0 || ^16.10.0" }, "repository": { "type": "git", From b048d7023c0af35ccb92e350133730e36473fb30 Mon Sep 17 00:00:00 2001 From: David Miller Date: Sun, 17 Oct 2021 22:09:11 +0100 Subject: [PATCH 08/14] Improve compatibility with older Node.js versions --- docs/ReleaseNotes.md | 3 +++ index.js | 2 +- package.json | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index b6238ea..3ddc3bb 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -5,6 +5,9 @@ # Homebridge MQTT-Thing: Release Notes +### Version 1.1.32 ++ Improve compatibility with older Node.js versions + ### Version 1.1.31 + Improve null handling (multicharacteristic) (thanks, Jakub Samek) + Added optimizePublishing option diff --git a/index.js b/index.js index 32dd249..751fcc9 100644 --- a/index.js +++ b/index.js @@ -1279,7 +1279,7 @@ function makeThing( log, accessoryConfig, api ) { // MQTT set (Homekit get) if( getTopic ) { mqttSubscribe( getTopic, property, function( topic, message ) { - let data = message?.toString() ?? ''; + let data = message ? message.toString() : ''; let newState = mqttToHomekit[ data ]; if( newState !== undefined && ( eventOnly || state[ property ] != newState ) ) { if( config.logMqtt ) { diff --git a/package.json b/package.json index 29d4f72..7bbc754 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-mqttthing", - "version": "1.1.31", + "version": "1.1.32", "description": "Homebridge plugin supporting various services over MQTT", "main": "index.js", "scripts": { From 1274be091694b0ea0cc7ead3d6ebfe6bfb06734d Mon Sep 17 00:00:00 2001 From: Thomas Vandahl Date: Fri, 29 Oct 2021 10:01:37 +0200 Subject: [PATCH 09/14] Update index.js Fix error message: [homebridge-mqttthing] This plugin generated a warning from the characteristic 'Set Duration': characteristic was supplied illegal value: number 30 exceeded minimum of 1200. See https://git.io/JtMGR for more info. --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 751fcc9..c91987b 100644 --- a/index.js +++ b/index.js @@ -2431,11 +2431,11 @@ function makeThing( log, accessoryConfig, api ) { } if( !topic_setDuration ) { /* no topic specified, but propery is still created internally */ - addCharacteristic( service, property_setDuration, Characteristic.SetDuration, 30, function() { + addCharacteristic( service, property_setDuration, Characteristic.SetDuration, 1200, function() { log.debug( 'set "' + property_setDuration + '" to ' + state[ property_setDuration ] + 's.' ); } ); } else { - integerCharacteristic( service, property_setDuration, Characteristic.SetDuration, topic_setDuration, topic_getDuration, { initialValue: 30 } ); + integerCharacteristic( service, property_setDuration, Characteristic.SetDuration, topic_setDuration, topic_getDuration, { initialValue: 1200 } ); } // minimum/maximum duration if( config.minDuration !== undefined || config.maxDuration !== undefined ) { From f0a9abbb3e2918197bda936106aef542d103dfa6 Mon Sep 17 00:00:00 2001 From: David Miller Date: Mon, 22 Nov 2021 00:36:02 +0000 Subject: [PATCH 10/14] Load codec at start of MQTT init equivalent to https://github.com/arachnetech/homebridge-mqttthing/pull/421 --- libs/mqttlib.js | 92 ++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/libs/mqttlib.js b/libs/mqttlib.js index 326f568..3796888 100644 --- a/libs/mqttlib.js +++ b/libs/mqttlib.js @@ -58,6 +58,52 @@ var mqttlib = new function() { let logmqtt = config.logMqtt; var clientId = 'mqttthing_' + config.name.replace(/[^\x20-\x7F]/g, "") + '_' + Math.random().toString(16).substr(2, 8); + // Load any codec + if( config.codec ) { + let codecPath = makeCodecPath( config.codec, ctx.homebridgePath ); + if( fs.existsSync( codecPath ) ) { + // load codec + log( 'Loading codec from ' + codecPath ); + let codecMod = require( codecPath ); + if( typeof codecMod.init === "function" ) { + + // direct publishing + let directPub = function( topic, message ) { + optimizedPublish( topic, message, ctx ); + }; + + // notification by property + let notifyByProp = function( property, message ) { + let handlers = propDispatch[ property ]; + if( handlers ) { + for( let i = 0; i < handlers.length; i++ ) { + handlers[ i ]( '_prop-' + property, message ); + } + } + }; + + // initialise codec + let codec = ctx.codec = codecMod.init( { log, config, publish: directPub, notify: notifyByProp } ); + if( codec ) { + // encode/decode must be functions + if( typeof codec.encode !== "function" ) { + log.warn( 'No codec encode() function' ); + codec.encode = null; + } + if( typeof codec.decode !== "function" ) { + log.warn( 'No codec decode() function' ); + codec.decode = null; + } + } + } else { + // no initialisation function + log.error( 'ERROR: No codec initialisation function returned from ' + codecPath ); + } + } else { + log.error( 'ERROR: Codec file [' + codecPath + '] does not exist' ); + } + } + // start with any configured options object var options = config.mqttOptions || {}; @@ -143,52 +189,6 @@ var mqttlib = new function() { } }); - // Load any codec - if( config.codec ) { - let codecPath = makeCodecPath( config.codec, ctx.homebridgePath ); - if( fs.existsSync( codecPath ) ) { - // load codec - log( 'Loading codec from ' + codecPath ); - let codecMod = require( codecPath ); - if( typeof codecMod.init === "function" ) { - - // direct publishing - let directPub = function( topic, message ) { - optimizedPublish( topic, message, ctx ); - }; - - // notification by property - let notifyByProp = function( property, message ) { - let handlers = propDispatch[ property ]; - if( handlers ) { - for( let i = 0; i < handlers.length; i++ ) { - handlers[ i ]( '_prop-' + property, message ); - } - } - }; - - // initialise codec - let codec = ctx.codec = codecMod.init( { log, config, publish: directPub, notify: notifyByProp } ); - if( codec ) { - // encode/decode must be functions - if( typeof codec.encode !== "function" ) { - log.warn( 'No codec encode() function' ); - codec.encode = null; - } - if( typeof codec.decode !== "function" ) { - log.warn( 'No codec decode() function' ); - codec.decode = null; - } - } - } else { - // no initialisation function - log.error( 'ERROR: No codec initialisation function returned from ' + codecPath ); - } - } else { - log.error( 'ERROR: Codec file [' + codecPath + '] does not exist' ); - } - } - ctx.mqttClient = mqttClient; return mqttClient; }; From 23aa9c822698f74eea7c38f81a65004414af899e Mon Sep 17 00:00:00 2001 From: David Miller Date: Fri, 26 Nov 2021 21:22:12 +0000 Subject: [PATCH 11/14] show apply function decoding --- libs/mqttlib.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/mqttlib.js b/libs/mqttlib.js index 326f568..621dee2 100644 --- a/libs/mqttlib.js +++ b/libs/mqttlib.js @@ -250,6 +250,9 @@ var mqttlib = new function() { let decoded; try { decoded = applyFn( message, getApplyState( ctx, property ) ); + if( config.logMqtt ) { + log( 'apply() function decoded message to [' + decoded + ']' ); + } } catch( ex ) { log( 'Decode function apply( message) { ' + extendedTopic.apply + ' } failed for topic ' + topic + ' with message ' + message + ' - ' + ex ); } From 1e907bdc95339e9c2bdcbbac06c763dafaf6dcfe Mon Sep 17 00:00:00 2001 From: David Miller Date: Fri, 26 Nov 2021 22:08:31 +0000 Subject: [PATCH 12/14] testing --- .gitignore | 1 + ...e-backup-CA7CA334AA6B.1622945645237.tar.gz | Bin 7145 -> 0 bytes test2/config.json | 21 +++++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) delete mode 100644 test2/backups/instance-backups/homebridge-backup-CA7CA334AA6B.1622945645237.tar.gz diff --git a/.gitignore b/.gitignore index 91fce81..15f9d27 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ test2/.uix-secrets test2/auth.json test2/config.json.* test2/persist/ControllerStorage.*.json +test2/backups/* diff --git a/test2/backups/instance-backups/homebridge-backup-CA7CA334AA6B.1622945645237.tar.gz b/test2/backups/instance-backups/homebridge-backup-CA7CA334AA6B.1622945645237.tar.gz deleted file mode 100644 index c300ecf63f8079ce3f11f14799bec9e55e3e3efe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7145 zcmYM1by!s2*SBdH=|Mn1dK^MJhHj9dL2@YRasX+ORC4GBMLt0 zf8Y0d=Z`(>++;#O(K`Pp~tTh-lC&P2vO7+^^>yyXOKD6h3a> z8Ai2>teeA9c7$I{UH6#(`s`Jt80Gv~PS3%6I5J@ec#{1th0xw%T;F%N_w>NskRafB z^sB3|n2T~HsE>s@**vZ8}H-1!{xr6kXfD5lGwK(XhhDq{n(OZ@oJG7H~fBMSg zZ}jokdgJg;HDvOwiX>g+6=gi7AS(?YAE>(fTp0iQ%9^u^Lo>WuwP3Et+MOBft2kn0 zx(X%C^^TA2wHN+mQ+2fjirlf(f`$zEQV&%JSuQwk->cRkMLC^+X17Ad`id!sT=kyD zzBu1APf~l)!;ww_GmWYaP~8a{Q!L5h_m|q-Y|A;{`ytQq$Tv=ohq%xFEJcytnwYDE zLrnRxwOq|kje)6X)An9k*yed>^weIT#TyPqU&umdOG^vQAb$tBuA{ABf8os2=@6K1 zbbfC!dqdLwnDHNj#o?V?^sH1N7?+?9r#N+Z(Nit0Ikk(%);~M+2tm;5xFG{qskBLD zC>&b!l9^LWkjJ!E)8nw6SL4AnWjmU>4o7>HZ52fmU3Ee<-$-v) zs9sH;rg!rLtc+UltpfGPE_Vu)F3#zD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2NL6?9SeUm2Z^= zzG&Z>Sz`@`I%(sfWJePSqK;!^MBt!$WDd$Jady(7!T%xQuN7 Date: Fri, 26 Nov 2021 22:17:11 +0000 Subject: [PATCH 13/14] Revert Node.js compatibilty change requiring Node.js 14 now --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 5068c38..5f99ffe 100644 --- a/index.js +++ b/index.js @@ -1300,7 +1300,7 @@ function makeThing( log, accessoryConfig, api ) { // MQTT set (Homekit get) if( getTopic ) { mqttSubscribe( getTopic, property, function( topic, message ) { - let data = message ? message.toString() : ''; + let data = message?.toString() ?? ''; let newState = mqttToHomekit[ data ]; if( newState !== undefined && ( eventOnly || state[ property ] != newState ) ) { if( config.logMqtt ) { From 4ddc8804c60e0ef194195c8f9d5388664be48ea9 Mon Sep 17 00:00:00 2001 From: David Miller Date: Fri, 26 Nov 2021 22:36:34 +0000 Subject: [PATCH 14/14] Release notes for 1.1.33 --- README.md | 2 ++ docs/ReleaseNotes.md | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 77cffcb..aae852a 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ ## Compatibility with previous versions +**From version 1.1.33, MQTT-Thing requires Node.js 14 or later.** + **From version 1.1.x, raw JavaScript values for Boolean properties are passed to MQTT apply functions.** This may change published message formats, e.g. when apply functions are used to build JSON strings. For full details of changes please see the [Release notes](docs/ReleaseNotes.md). diff --git a/docs/ReleaseNotes.md b/docs/ReleaseNotes.md index 3ddc3bb..0c32256 100644 --- a/docs/ReleaseNotes.md +++ b/docs/ReleaseNotes.md @@ -5,6 +5,16 @@ # Homebridge MQTT-Thing: Release Notes +### Version 1.1.33 ++ Revert change in 1.1.32. MQTT-Thing now requires Node.js 14 or later. ++ Engines updated to require Homebridge 1.3.5 and Node.js 14 (thanks, Donavan Becker) ++ Fixed typo in documentation (thanks, Brian White) ++ Fixed duration characteristic validation error message (thanks, Thomas Vandahl) ++ Moved codec loading earlier to allow codecs to manipulate the configuration (thanks, Martin) ++ Added water level characteristic to leak sensor (thanks, Moritz) ++ Added max wind and dewpoint characteristics to weather station (thanks, 2610) ++ Added jsonpath support (thanks, Antonio Yip) + ### Version 1.1.32 + Improve compatibility with older Node.js versions