Skip to content

Commit

Permalink
tried to fix crash with empty input for sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
windkh committed Dec 5, 2024
1 parent e20ad0b commit e49db5f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

## [11.5.4] - 2024-11-23
### tried to fix crash with gen2 empty input - [#194](https://github.com/windkh/node-red-contrib-shelly/issues/194)

## [11.5.3] - 2024-11-23
### added Shelly Blu Gateways Gen3 - [#191](https://github.com/windkh/node-red-contrib-shelly/issues/191)

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-shelly",
"version": "11.5.3",
"version": "11.5.4",
"description": "Shelly nodes.",
"node-red": {
"version": ">=3.0.0",
Expand Down
19 changes: 14 additions & 5 deletions shelly/99-shelly.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ module.exports = function (RED) {

let nonceCount = 1;

// no operation function
function noop(){}

function isEmpty(obj) {
return Object.keys(obj).length === 0;
}
Expand Down Expand Up @@ -1241,6 +1238,11 @@ module.exports = function (RED) {
return route;
}

// no operation function
function inputParserEmpty1(){
}


// Returns the input parser for the device type.
function getInputParser1(deviceType){

Expand Down Expand Up @@ -1273,7 +1275,7 @@ module.exports = function (RED) {
result = inputParserRGBW1Async;
break;
default:
result = noop;
result = inputParserEmpty1;
break;
}
return result;
Expand Down Expand Up @@ -2331,6 +2333,12 @@ module.exports = function (RED) {
return requests;
}

// returns an empty array.
function inputParserEmptyArray2(msg){
let requests = [];
return requests;
}

// Returns the input parser for the device type.
function getInputParser2(deviceType){

Expand All @@ -2347,7 +2355,7 @@ module.exports = function (RED) {
result = inputParserGeneric2Array;
break;
default:
result = noop;
result = inputParserEmptyArray2;
break;
}
return result;
Expand Down Expand Up @@ -2766,6 +2774,7 @@ module.exports = function (RED) {
})();

this.on('input', async function (msg) {

let credentials = getCredentials(node, msg);
let requests = await node.inputParser(msg, node, credentials);

Expand Down

0 comments on commit e49db5f

Please sign in to comment.