Skip to content

Commit

Permalink
4.0.0 (#9)
Browse files Browse the repository at this point in the history
* Cam Profiles & Levels, rmDirSync, Versions

* Various

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* callback object

* Update HAPRouter.js

* Update Bridge.js

* Remove Matcher

* Formatting

* Update package.json

* HTTP Auth for HTTP route

* Update CHANGELOG.md

* Change Log

* Bridge switch

* Module

* Update RouteModule.md

* Local

* Update CHANGELOG.md

* TV Icon

* Update HAPRouter.js
  • Loading branch information
marcus-j-davies authored Jun 19, 2022
1 parent eb9bfa5 commit bc30851
Show file tree
Hide file tree
Showing 44 changed files with 1,661 additions and 222 deletions.
2 changes: 1 addition & 1 deletion @marcus-j-davies/haprouter-route-console/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Icon = 'icon.png';
class ConsoleClass {
/* Constructor */
constructor(route, statusnotify) {
statusnotify(true);
statusnotify({ success: true });
}
}

Expand Down
2 changes: 1 addition & 1 deletion @marcus-j-davies/haprouter-route-console/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@marcus-j-davies/haprouter-route-console",
"description": "The stock HAP Router CONSOLE route",
"version": "3.2.1",
"version": "4.0.0",
"main": "index.js",
"author": {
"name": "Marcus Davies",
Expand Down
9 changes: 5 additions & 4 deletions @marcus-j-davies/haprouter-route-file/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class File {
/* Constructor */
constructor(route, statusnotify) {
this.Route = route;
statusnotify(true);
statusnotify({ success: true });
this.StatusNotify = statusnotify;
}
}
Expand All @@ -35,7 +35,8 @@ File.prototype.process = async function (payload) {
try {
fs.mkdirSync(Directory, { recursive: true });
} catch (err) {
this.StatusNotify(false, err.message);
this.StatusNotify({ success: false, message: err.message });

return;
}
}
Expand All @@ -47,9 +48,9 @@ File.prototype.process = async function (payload) {

try {
fs.writeFileSync(_Path, JSONs, 'utf8');
this.StatusNotify(true);
this.StatusNotify({ success: true });
} catch (err) {
this.StatusNotify(false, err.message);
this.StatusNotify({ success: false, message: err.message });
}
};

Expand Down
2 changes: 1 addition & 1 deletion @marcus-j-davies/haprouter-route-file/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@marcus-j-davies/haprouter-route-file",
"description": "The stock HAP Router FILE route",
"version": "3.2.1",
"version": "4.0.0",
"main": "index.js",
"author": {
"name": "Marcus Davies",
Expand Down
26 changes: 23 additions & 3 deletions @marcus-j-davies/haprouter-route-http/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ const Params = [
{
id: 'destinationURI',
label: 'HTTP URI'
},
{
id: 'username',
label: 'HTTP Username (optional)'
},
{
id: 'password',
label: 'HTTP Password (optional)',
type: 'password'
}
];

Expand All @@ -18,7 +27,7 @@ class HTTPRoute {
constructor(route, statusnotify) {
this.StatusNotify = statusnotify;
this.Route = route;
statusnotify(true);
statusnotify({ success: true });
}
}

Expand All @@ -36,12 +45,23 @@ HTTPRoute.prototype.process = async function (payload) {
data: payload
};

if (
this.Route.username !== undefined &&
this.Route.username.length > 0 &&
this.Route.password !== undefined &&
this.Route.password.length > 0
) {
CFG.auth = {};
CFG.auth.username = this.Route.username;
CFG.auth.password = this.Route.password;
}

try {
await axios.request(CFG);
this.StatusNotify(true);
this.StatusNotify({ success: true });
} catch (err) {
if (err) {
this.StatusNotify(false, err.message);
this.StatusNotify({ success: false, message: err.message });
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions @marcus-j-davies/haprouter-route-http/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@marcus-j-davies/haprouter-route-http",
"description": "The stock HAP Router HTTP route",
"version": "3.2.1",
"version": "4.0.0",
"main": "index.js",
"author": {
"name": "Marcus Davies",
"email": "[email protected]"
},
"license": "MIT",
"dependencies": {
"axios": "^0.24.0"
"axios": "^0.27.2"
}
}
22 changes: 13 additions & 9 deletions @marcus-j-davies/haprouter-route-mqtt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ MQTTRoute.prototype._init = function () {
this.MQTTBroker.on('error', (e) => this.mqttError(e));
this.MQTTBroker.on('close', () => this.mqttClose());
} catch (err) {
this.StatusNotify(false, err.message);
this.StatusNotify({ success: false, message: err.message });
}
};

Expand All @@ -74,32 +74,36 @@ MQTTRoute.prototype.close = function () {

MQTTRoute.prototype.mqttClose = function () {
if (this.Retries >= _MaxRetries) {
this.StatusNotify(false, 'Connection was closed. Recovery Failed.');
this.StatusNotify({
success: false,
message: 'Connection was closed. Recovery Failed.'
});
} else {
this.Retries++;
this.StatusNotify(
false,
'Connection was closed. Recovery Scheduled (' +
this.StatusNotify({
success: false,
message:
'Connection was closed. Recovery Scheduled (' +
this.Retries +
'/' +
_MaxRetries +
')'
);
});
setTimeout(() => {
this._init();
}, _RetryWaitTime);
}
};

MQTTRoute.prototype.mqttConnected = function () {
this.StatusNotify(true);
this.StatusNotify({ success: true });
};

MQTTRoute.prototype.mqttError = function (err) {
if (err) {
this.StatusNotify(false, err.message);
this.StatusNotify({ success: false, message: err.message });
} else {
this.StatusNotify(true);
this.StatusNotify({ success: true });
}
};

Expand Down
4 changes: 2 additions & 2 deletions @marcus-j-davies/haprouter-route-mqtt/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@marcus-j-davies/haprouter-route-mqtt",
"description": "The stock HAP Router MQTT route",
"version": "3.2.1",
"version": "4.0.0",
"main": "index.js",
"author": {
"name": "Marcus Davies",
"email": "[email protected]"
},
"license": "MIT",
"dependencies": {
"mqtt": "^4.3.2"
"mqtt": "^4.3.7"
}
}
2 changes: 1 addition & 1 deletion @marcus-j-davies/haprouter-route-null/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Icon = 'icon.png';
class Null {
/* Constructor */
constructor(route, statusnotify) {
statusnotify(true);
statusnotify({ success: true });
}
}

Expand Down
2 changes: 1 addition & 1 deletion @marcus-j-davies/haprouter-route-null/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@marcus-j-davies/haprouter-route-null",
"description": "The stock HAP Router NULL route",
"version": "3.2.1",
"version": "4.0.0",
"main": "index.js",
"author": {
"name": "Marcus Davies",
Expand Down
12 changes: 6 additions & 6 deletions @marcus-j-davies/haprouter-route-udp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class UDP {
this.UDPServer.on('error', (e) => this.UDPBindError(e));
this.UDPServer.bind(() => this.UDPConnected());
} catch (err) {
statusnotify(false, err.message);
statusnotify({ success: false, message: err.message });
}
}
}
Expand All @@ -47,7 +47,7 @@ UDP.prototype.process = async function (payload) {
(e) => this.UDPDone(e)
);
} catch (err) {
this.StatusNotify(false, err.message);
this.StatusNotify({ success: false, message: err.message });
}
}
};
Expand All @@ -59,19 +59,19 @@ UDP.prototype.close = function () {
};

UDP.prototype.UDPBindError = function (err) {
this.StatusNotify(false, err.message);
this.StatusNotify({ success: false, message: err.message });
};

UDP.prototype.UDPConnected = function () {
this.UDPServer.setBroadcast(true);
this.StatusNotify(true);
this.StatusNotify({ success: true });
};

UDP.prototype.UDPDone = function (err) {
if (err) {
this.StatusNotify(false, err.message);
this.StatusNotify({ success: false, message: err.message });
} else {
this.StatusNotify(true);
this.StatusNotify({ success: true });
}
};

Expand Down
2 changes: 1 addition & 1 deletion @marcus-j-davies/haprouter-route-udp/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@marcus-j-davies/haprouter-route-udp",
"description": "The stock HAP Router UDP route",
"version": "3.2.1",
"version": "4.0.0",
"main": "index.js",
"author": {
"name": "Marcus Davies",
Expand Down
22 changes: 13 additions & 9 deletions @marcus-j-davies/haprouter-route-websocket/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ WebsocketClass.prototype._init = function () {
this.Websocket.on('error', (e) => this.WSError(e));
this.Websocket.on('close', () => this.HandleWSClose());
} catch (err) {
this.StatusNotify(false, err.message);
this.StatusNotify({ success: false, message: err.message });
}
};

Expand All @@ -53,30 +53,34 @@ WebsocketClass.prototype.close = function () {

WebsocketClass.prototype.HandleWSOpen = function () {
this.Retries = 0;
this.StatusNotify(true);
this.StatusNotify({ success: true });
};

WebsocketClass.prototype.WSError = function (err) {
if (err) {
this.StatusNotify(false, err.message);
this.StatusNotify({ success: false, message: err.message });
} else {
this.StatusNotify(true);
this.StatusNotify({ success: true });
}
};

WebsocketClass.prototype.HandleWSClose = function () {
if (this.Retries >= _MaxRetries) {
this.StatusNotify(false, 'Connection was closed. Recovery Failed.');
this.StatusNotify({
success: false,
message: 'Connection was closed. Recovery Failed.'
});
} else {
this.Retries++;
this.StatusNotify(
false,
'Connection was closed. Recovery Scheduled (' +
this.StatusNotify({
success: false,
message:
'Connection was closed. Recovery Scheduled (' +
this.Retries +
'/' +
_MaxRetries +
')'
);
});
setTimeout(() => {
this._init();
}, _RetryWaitTime);
Expand Down
4 changes: 2 additions & 2 deletions @marcus-j-davies/haprouter-route-websocket/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@marcus-j-davies/haprouter-route-websocket",
"description": "The stock HAP Router WEB SOCKET route",
"version": "3.2.1",
"version": "4.0.0",
"main": "index.js",
"author": {
"name": "Marcus Davies",
"email": "[email protected]"
},
"license": "MIT",
"dependencies": {
"ws":"^8.4.0"
"ws":"^8.8.0"
}
}
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
- **4.0.0**

- **Breaking Changes**
- Min NodeJS version is now 14.14.0
- Route status callback has been updated, and now requires an object to be passed.
```javascript
{
"success": boolean,
"message": string
}
```
- **Fixes**
- Fix missing HAPRouter folder at start up.
- Fix multisensor config, affecting other instances of the same accessory type.
- Address minor security warnings

- **New Features**
- Characteristic values are now written to disc every hour, to ensure most recent values are saved, in case of unexpected termination.
- Bridge functionality can now be independently switched off.
- Television Accessory, can now have different icons.


- **3.0.2**

- **Changes**
Expand Down
Loading

0 comments on commit bc30851

Please sign in to comment.