From 6e897b4da3c3fb12e7d5d0dd7c486aa8de992750 Mon Sep 17 00:00:00 2001 From: Andrey Popov Date: Sat, 30 Jul 2022 09:30:47 +0300 Subject: [PATCH] z2m-out Lock support --- nodes/out.html | 3 ++- nodes/out.js | 15 +++++++++++++++ package.json | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/nodes/out.html b/nodes/out.html index 0b0008f..43a7e7a 100644 --- a/nodes/out.html +++ b/nodes/out.html @@ -257,7 +257,8 @@ {'value':'color_temp', 'label':'Color Temperature (50..400)'}, {'value':'color_temp_move', 'label':'Color Temperature Move (50..400|stop)'}, {'value':'color_temp_step', 'label':'Color Temperature Step (50..400)'}, - {'value':'position', 'label':'Position'}, + {'value':'position', 'label':'Position (0..100)'}, + {'value':'lock', 'label':'Lock (lock|unlock|on|off|toggle)'}, {'value':'alert', 'label':'Alert'} ] }, diff --git a/nodes/out.js b/nodes/out.js index aba212d..c3e5224 100644 --- a/nodes/out.js +++ b/nodes/out.js @@ -111,6 +111,21 @@ module.exports = function(RED) { payload = parseInt(payload); break; + case 'lock': + command = 'state'; + if (payload === 'toggle') { + if ('state' in device.current_values && device.current_values.state === 'lock') { + payload = 'unlock'; + } else { + payload = 'lock'; + } + } else if (payload === 'lock' || payload == 1 || payload === true) { + payload = 'lock'; + } else if (payload === 'unlock' || payload == 0 || payload === false) { + payload = 'unlock'; + } + break; + case 'color': payload = {"color":payload}; break; diff --git a/package.json b/package.json index 22985b2..0a2a136 100755 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ }, "name": "node-red-contrib-zigbee2mqtt", "description": "Zigbee2mqtt connectivity nodes for node-red", - "version": "2.5.2", + "version": "2.6.0", "dependencies": { "eventsource": "^2.0.2", "mqtt": "^4.3.7",