def __init__(self): Application().registerShutdown(self.onShutdown) self.live = TelldusLive(self.context) # pylint: disable=too-many-function-args self.discovered_flag = False self.mqtt_connected_flag = False self.client = mqtt.Client() self.client.on_disconnect = self.onMqttDisconnect self.client.on_connect = self.onMqttConnect self.client.on_message = self.onMqttMessage username = self.config('username') password = self.config('password') # if username setup mqtt login if username != '': self.client.username_pw_set(username, password) useConfigUrl = self.config('useConfigUrl') configUrl = 'https://live.telldus.se' if self.config( 'configUrl') == 'live' else ('http://%s' % getIpAddr()) self.hub = devs.HaHub(self.config('device_name'), self._buildTopic, configUrl if useConfigUrl else None) self._debug('Hub: %s' % json.dumps(self._getDeviceConfig(self.hub))) self.staticDevices = [ self.hub, devs.HaLiveConnection(self.hub, self.live, self._buildTopic), devs.HaIpAddr(self.hub, self._buildTopic), devs.HaCpu(self.hub, self._buildTopic), devs.HaRamFree(self.hub, self._buildTopic), devs.HaNetIORecv(self.hub, self._buildTopic), devs.HaNetIOSent(self.hub, self._buildTopic) ] self.devices = self.staticDevices + [] Application().queue(self.discoverAndConnect) Application().registerScheduledTask(self._updateTimedSensors, seconds=30)