mirror of
https://github.com/lehanspb/tuya-mqtt.git
synced 2025-12-18 08:13:23 +00:00
v3.03
* Fix reconnect failure in some disconnect cases * Remove duplicate republish function
This commit is contained in:
@@ -597,24 +597,17 @@ class TuyaDevice {
|
||||
|
||||
// Retry connection every 10 seconds if unable to connect
|
||||
async reconnect() {
|
||||
if (!this.device.isConnected() && !this.reconnecting) {
|
||||
if (!this.reconnecting) {
|
||||
this.reconnecting = true
|
||||
debugError('Error connecting to device id '+this.options.id+'...retry in 10 seconds.')
|
||||
await utils.sleep(10)
|
||||
if (this.connected) { return }
|
||||
this.connectDevice()
|
||||
if (!this.device.isConnected) {
|
||||
this.connectDevice()
|
||||
}
|
||||
this.reconnecting = false
|
||||
}
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
|
||||
// Republish device discovery/state data (used for Home Assistant state topic)
|
||||
async republish() {
|
||||
const status = (this.device.isConnected()) ? 'online' : 'offline'
|
||||
@@ -648,4 +641,4 @@ class TuyaDevice {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TuyaDevice
|
||||
module.exports = TuyaDevice
|
||||
|
||||
Reference in New Issue
Block a user