From 185fe8a360d657a30b3bb81e30ac6bc67e07887c Mon Sep 17 00:00:00 2001 From: William Deren Date: Fri, 23 Feb 2024 09:48:19 +0100 Subject: [PATCH] ZWaveJS UI - Add selector when converting Zwave device to Gladys device (#2030) --- server/services/zwavejs-ui/utils/convertToGladysDevice.js | 2 ++ .../zwavejs-ui/lib/zwaveJSUI.onNewDeviceDiscover.test.js | 2 ++ .../test/services/zwavejs-ui/lib/zwaveJSUI.setValue.test.js | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/server/services/zwavejs-ui/utils/convertToGladysDevice.js b/server/services/zwavejs-ui/utils/convertToGladysDevice.js index 452ac7aae4..d3e809a161 100644 --- a/server/services/zwavejs-ui/utils/convertToGladysDevice.js +++ b/server/services/zwavejs-ui/utils/convertToGladysDevice.js @@ -40,6 +40,7 @@ const convertToGladysDevice = (serviceId, device) => { ...exposeFound, name: value.id, external_id: getDeviceFeatureId(device.id, commandClassName, endpoint, propertyName, propertyKeyName), + selector: getDeviceFeatureId(device.id, commandClassName, endpoint, propertyName, propertyKeyName), node_id: device.id, // These are custom properties only available on the object in memory (not in DB) command_class_version: commandClassVersion, @@ -55,6 +56,7 @@ const convertToGladysDevice = (serviceId, device) => { return { name: device.name, external_id: `zwavejs-ui:${device.id}`, + selector: `zwavejs-ui:${device.id}`, service_id: serviceId, should_poll: false, features, diff --git a/server/test/services/zwavejs-ui/lib/zwaveJSUI.onNewDeviceDiscover.test.js b/server/test/services/zwavejs-ui/lib/zwaveJSUI.onNewDeviceDiscover.test.js index dfe10be645..f0752b0006 100644 --- a/server/test/services/zwavejs-ui/lib/zwaveJSUI.onNewDeviceDiscover.test.js +++ b/server/test/services/zwavejs-ui/lib/zwaveJSUI.onNewDeviceDiscover.test.js @@ -34,6 +34,7 @@ describe('zwaveJSUIHandler.onNewDeviceDiscover.js', () => { { name: 'capteur-ouverture', external_id: 'zwavejs-ui:2', + selector: `zwavejs-ui:2`, service_id: 'ffa13430-df93-488a-9733-5c540e9558e0', should_poll: false, features: [ @@ -51,6 +52,7 @@ describe('zwaveJSUIHandler.onNewDeviceDiscover.js', () => { command_class_version: 5, endpoint: 0, external_id: 'zwavejs-ui:2:0:notification:access_control:door_state_simple', + selector: 'zwavejs-ui:2:0:notification:access_control:door_state_simple', node_id: 2, property_name: 'Access Control', property_key_name: 'Door state (simple)', diff --git a/server/test/services/zwavejs-ui/lib/zwaveJSUI.setValue.test.js b/server/test/services/zwavejs-ui/lib/zwaveJSUI.setValue.test.js index 79ac7ecb5a..9a40af83f2 100644 --- a/server/test/services/zwavejs-ui/lib/zwaveJSUI.setValue.test.js +++ b/server/test/services/zwavejs-ui/lib/zwaveJSUI.setValue.test.js @@ -135,6 +135,7 @@ describe('zwaveJSUIHandler.setValue', () => { { name: 'prise01-wp', external_id: 'zwavejs-ui:3', + selector: 'zwavejs-ui:3', service_id: 'ee03cc7e-8551-4774-bd47-ca7565f6665d', should_poll: false, features: [ @@ -148,6 +149,7 @@ describe('zwaveJSUIHandler.setValue', () => { has_feedback: true, name: '3-37-0-currentValue', external_id: 'zwavejs-ui:3:0:binary_switch:currentvalue', + selector: 'zwavejs-ui:3:0:binary_switch:currentvalue', node_id: 3, command_class_version: 1, command_class_name: 'Binary Switch', @@ -186,6 +188,7 @@ describe('zwaveJSUIHandler.setValue', () => { { name: 'prise01-wp', external_id: 'zwavejs-ui:3', + selector: 'zwavejs-ui:3', service_id: 'ee03cc7e-8551-4774-bd47-ca7565f6665d', should_poll: false, features: [ @@ -199,6 +202,7 @@ describe('zwaveJSUIHandler.setValue', () => { has_feedback: true, name: '3-37-0-currentValue', external_id: 'zwavejs-ui:3:0:binary_switch:currentvalue', + selector: 'zwavejs-ui:3:0:binary_switch:currentvalue', node_id: 3, command_class_version: 1, command_class_name: 'Binary Switch',