def connect(self, gateway):
self.gateway = gateway
if self.config['id'] is not None:
self.topic = gateway.topic + "/" + self.config['id']
else:
self.topic = gateway.topic + "/" + self.__class__.__name__
if self.config['gpio'] is not None:
self.topic = self.topic + "/" + str(self.config["gpio"])
payload = { 'connected': self.topic }
self.gateway.publish(gateway.topic, json.dumps(payload))
self.gateway.subscribe(self.topic+"/configure")
self.gateway.subscribe(self.topic+"/get")
self.gateway.subscribe(self.topic+"/set")
评论列表
文章目录