Do not force type cohercion on bool values - !!parseInt(true) = false in JavaScript, for some reason

This commit is contained in:
Fabio Manganiello 2021-03-16 20:11:49 +01:00
parent b9738d88df
commit fdd46edb6a
9 changed files with 8 additions and 28 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -195,23 +195,11 @@ export default {
}, },
async onValueChange(event, data) { async onValueChange(event, data) {
console.debug('DATA (1)')
console.debug(data)
const target = event.target ? event.target : event.event.target.parentElement const target = event.target ? event.target : event.event.target.parentElement
console.debug('TARGET')
console.debug(target)
const value = this.node.values[this.value.id_on_network] const value = this.node.values[this.value.id_on_network]
console.debug('VALUE')
console.debug(value)
if (data === undefined) if (data === undefined)
data = target.value != null ? target.value : event.value data = target.value != null ? target.value : event.value
console.debug('DATA (2)')
console.debug(data)
switch (value.type) { switch (value.type) {
case 'List': case 'List':
data = value.data_items[event.target.value] data = value.data_items[event.target.value]
@ -224,19 +212,11 @@ export default {
data = parseInt(data) data = parseInt(data)
break break
case 'Button':
case 'Bool':
data = !!parseInt(data)
break
case 'Decimal': case 'Decimal':
data = parseFloat(data) data = parseFloat(data)
break break
} }
console.debug('DATA (3)')
console.debug(data)
this.commandRunning = true this.commandRunning = true
try { try {
this.request('zwave.set_value', { this.request('zwave.set_value', {