Skip to content

Commit

Permalink
feat: Show device id in device gateway values dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Mar 4, 2020
1 parent 30f5b35 commit f2d112c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
43 changes: 21 additions & 22 deletions src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit f2d112c

Please sign in to comment.