From f2d112ca5bd29dcf3298ee2507c19a5cbc502124 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Wed, 4 Mar 2020 10:07:15 +0100 Subject: [PATCH] feat: Show device id in device gateway values dropdown --- lib/ZwaveClient.js | 2 +- src/components/Settings.vue | 2 +- src/store/mutations.js | 43 ++++++++++++++++++------------------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/lib/ZwaveClient.js b/lib/ZwaveClient.js index 41f992568f5..fb306c0638d 100644 --- a/lib/ZwaveClient.js +++ b/lib/ZwaveClient.js @@ -419,7 +419,7 @@ function nodeReady (nodeid, nodeinfo) { // add it to know devices types (if not already present) if (!this.devices[ozwnode.device_id]) { this.devices[ozwnode.device_id] = { - name: `${ozwnode.product} (${ozwnode.manufacturer})`, + name: `[${ozwnode.device_id}] ${ozwnode.product} (${ozwnode.manufacturer})`, values: JSON.parse(JSON.stringify(ozwnode.values)) } diff --git a/src/components/Settings.vue b/src/components/Settings.vue index 491f72a3939..0579c8122ff 100644 --- a/src/components/Settings.vue +++ b/src/components/Settings.vue @@ -643,7 +643,7 @@ export default { }, deviceName (deviceID) { var device = this.devices.find(d => d.value === deviceID) - return device ? `[${deviceID}] ${device.name}` : deviceID + return device ? device.name : deviceID }, saveValue () { if (this.editedIndex > -1) { diff --git a/src/store/mutations.js b/src/store/mutations.js index b34d50deb83..390edbf2ccb 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -16,49 +16,48 @@ export const getters = { export const actions = { init (store, data) { - if(data){ - store.commit('initSettings', data.settings); - store.commit('initPorts', data.serial_ports); - store.commit('initDevices', data.devices); + if (data) { + store.commit('initSettings', data.settings) + store.commit('initPorts', data.serial_ports) + store.commit('initDevices', data.devices) } }, import (store, settings) { - store.commit('initSettings', settings); + store.commit('initSettings', settings) } } export const mutations = { - initSettings(state, conf){ - if(conf){ - state.zwave = conf.zwave || {}; - state.mqtt = conf.mqtt || {}; - state.gateway = conf.gateway || {}; + initSettings (state, conf) { + if (conf) { + state.zwave = conf.zwave || {} + state.mqtt = conf.mqtt || {} + state.gateway = conf.gateway || {} } }, - initPorts(state, ports){ - state.serial_ports = ports || []; + initPorts (state, ports) { + state.serial_ports = ports || [] }, - initDevices(state, devices) { + initDevices (state, devices) { + if (!state.gateway.values) state.gateway.values = [] - if(!state.gateway.values) state.gateway.values = []; - - if(devices){ + if (devices) { // devices is an object where key is the device ID and value contains // device informations for (var k in devices) { - var d = devices[k]; - d.value = k; + var d = devices[k] + d.value = k - var values = []; + var values = [] // device.values is an object where key is the valueID (cmdClass-instance-index) and value contains // value informations - for(var id in d.values){ - var val = d.values[id]; + for (var id in d.values) { + var val = d.values[id] values.push(val) } - d.values = values; + d.values = values state.devices.push(d) }