uci-berry-utils/test/mqttx.tst.be

38 lines
1.1 KiB
Plaintext

import mqttx as mqtt
import introspect
print(introspect(mqtt.ready),introspect(mqtt.wait))
# def mqtt_connected_cmds()
# tasmota.add_rule("Tele#DS18B20#Temperature", pub_temperature,2)
# tasmota.add_rule("mqtt#connected",/-> subscribe_cntrl() ,2)
# tasmota.cmd("Subscribe "+self.cfg.id,"/weather/set/"+self.cfg.id)
# tasmota.add_rule("Event#weather"+self.cfg.id, /-> self.mqtt_process_cmd())
# end
# def mqtt_disconnected_cmds()
# tasmota.remove_rule("Event#weather"+self.cfg.id, 2)
# end
# def subscribe_cntrl()
# print("subscribing to stoneroom via mqtt")
# mqtt.subscribe("stoneroom/cntrl/#", process_cmd)
# tasmota.remove_rule("mqtt#connected",2)
# end
# def process_cmd (topic,idx,payload,bytes)
# print('topic:', topic,idx, 'payload is:', payload, bytes)
# if payload
# var mcmd = json.load(payload)
# print (mcmd.find('relay'), mcmd.find('state'))
# var scmd = 'power'+str(mcmd.find('relay'))+' '+str(mcmd.find('state') == "OFF" ? 0 : 1)
# print(scmd)
# tasmota.cmd(scmd)
# return true
# else
# return false
# end
# end