mirror of
https://github.com/lehanspb/tuya-mqtt.git
synced 2025-12-18 08:13:23 +00:00
Update 3.0.1 (#61)
* Script to merge device additions and changes into devices.conf (#49) * Add republish on reconnect * Filter additional invalid characters '+','#','/' from topic line (replace with '_') * Minor bugfixes for parse values * Include script for merging new devices into existing config * Update dependency Co-authored-by: tsightler <tsightler@gmail.com> Co-authored-by: Doug Krahmer <doug.git@remhark.com>
This commit is contained in:
@@ -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(/ /g,'_') }
|
||||
if (this.config.name) { this.options.name = this.config.name.toLowerCase().replace(/\s|\+|#|\//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))) : value = parseInt(value)
|
||||
value = (deviceTopic.stateMath) ? parseInt(Math.round(evaluate(value+deviceTopic.stateMath))) : parseInt(value)
|
||||
break;
|
||||
case 'float':
|
||||
value = (deviceTopic.stateMath) ? parseFloat(evaluate(value+deviceTopic.stateMath)) : value = parseFloat(value)
|
||||
value = (deviceTopic.stateMath) ? parseFloat(evaluate(value+deviceTopic.stateMath)) : parseFloat(value)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -601,6 +601,14 @@ 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