Revert "Dev (#60)"

This reverts commit 44a5c6adbf.
This commit is contained in:
tsightler
2020-12-23 20:18:39 -05:00
parent 44a5c6adbf
commit b29b98911a
9 changed files with 56 additions and 156 deletions

View File

@@ -17,7 +17,7 @@ class TuyaDevice {
id: this.config.id,
key: this.config.key
}
if (this.config.name) { this.options.name = this.config.name.toLowerCase().replace(/\s|\+|#|\//g,'_') }
if (this.config.name) { this.options.name = this.config.name.toLowerCase().replace(/ /g,'_') }
if (this.config.ip) {
this.options.ip = this.config.ip
if (this.config.version) {
@@ -249,10 +249,10 @@ class TuyaDevice {
// Perform any required math transforms before returing command value
switch (deviceTopic.type) {
case 'int':
value = (deviceTopic.stateMath) ? parseInt(Math.round(evaluate(value+deviceTopic.stateMath))) : parseInt(value)
value = (deviceTopic.stateMath) ? parseInt(Math.round(evaluate(value+deviceTopic.stateMath))) : value = parseInt(value)
break;
case 'float':
value = (deviceTopic.stateMath) ? parseFloat(evaluate(value+deviceTopic.stateMath)) : parseFloat(value)
value = (deviceTopic.stateMath) ? parseFloat(evaluate(value+deviceTopic.stateMath)) : value = parseFloat(value)
break;
}
@@ -601,14 +601,6 @@ class TuyaDevice {
if (this.connected) { return }
this.connectDevice()
}
// Republish device discovery/state data (used for Home Assistant state topic)
async republish() {
const status = (this.device.isConnected()) ? 'online' : 'offline'
this.publishMqtt(this.baseTopic+'status', status)
await utils.sleep(1)
this.init()
}
// Simple function to monitor heartbeats to determine if
monitorHeartbeat() {