mirror of
https://github.com/lehanspb/tuya-mqtt.git
synced 2025-12-18 00:10:20 +00:00
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user