Skip to content

Commit

Permalink
fixed state output
Browse files Browse the repository at this point in the history
  • Loading branch information
andreypopov committed Jul 27, 2022
1 parent 79988d6 commit 36f9136
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 20 additions & 6 deletions nodes/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,26 @@ module.exports = function(RED) {
}

let useProperty = null;
if (node.config.state && node.config.state !== '0' && payload_all && node.config.state in payload_all) {
payload = text = payload_all[node.config.state];
useProperty = node.config.state;
} else if (item.homekit && node.config.state && node.config.state.split("homekit_").join('') in item.homekit) {
payload = item.homekit[node.config.state.split("homekit_").join('')];
useProperty = node.config.state.split("homekit_").join('');
if (node.config.state && node.config.state !== '0' && payload_all) {
// console.log(item.current_values);
if (node.config.state in payload_all) {
payload = text = payload_all[node.config.state];
useProperty = node.config.state;
} else {
//state was not found in payload (button case)
//payload: { last_seen: '2022-07-27T15:25:22+03:00', linkquality: 36 }
//payload: { action: 'single', last_seen: '2022-07-27T15:25:22+03:00', linkquality: 36 }
// console.log('=======skip');
return;
}
} else if (item.homekit && node.config.state) {
if (node.config.state.split("homekit_").join('') in item.homekit) {
payload = item.homekit[node.config.state.split("homekit_").join('')];
useProperty = node.config.state.split("homekit_").join('');
} else {
//state was not found in payload
return;
}
} else {
payload = payload_all;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"name": "node-red-contrib-zigbee2mqtt",
"description": "Zigbee2mqtt connectivity nodes for node-red",
"version": "2.4.2",
"version": "2.5.0",
"dependencies": {
"eventsource": "^2.0.2",
"mqtt": "^4.3.7",
Expand Down

0 comments on commit 36f9136

Please sign in to comment.