26 lines
506 B
Plaintext
26 lines
506 B
Plaintext
var mqttx = module("mqttx")
|
|
|
|
def mqtt_wait(con,dis)
|
|
if dis dis() end
|
|
mqttx.connected = false
|
|
tasmota.remove_rule("mqtt#disconnected",2)
|
|
tasmota.add_rule("mqtt#connected", /-> mqttx.ready(con,dis),2)
|
|
end
|
|
|
|
def mqtt_ready(con,dis)
|
|
mqttx.connected=true
|
|
if con con() end
|
|
tasmota.remove_rule("mqtt#connected",2)
|
|
tasmota.add_rule("mqtt#disconnected", /-> mqttx.wait(con,dis),2)
|
|
end
|
|
|
|
mqttx.connected = false
|
|
mqttx.wait = mqtt_wait
|
|
mqttx.ready = mqtt_ready
|
|
|
|
print(tasmota.millis())
|
|
|
|
return mqttx
|
|
|
|
|