Python3 compatiblity, input mode

master
informatic 2019-04-20 14:05:10 +02:00
parent c422065cdb
commit 65431de9c3
2 changed files with 11 additions and 2 deletions

View File

@ -44,7 +44,12 @@ class VortexConnection(object):
data = True
while data:
data = self.socket.recv(4096).decode('utf-8')
try:
data = self.socket.recv(512).decode()
except:
time.sleep(0.1)
self.logger.warning('Recv failed')
continue
buf += data
while buf.find('\r') != -1:

View File

@ -22,7 +22,8 @@ class VortexSpejsIOTClient(mqtt.Client):
def on_connect(self, client, userdata, flags, rc):
self.subscribe(self.topic_prefix + '+/+/set')
self.logger.info('Connected')
self.device_id = self.vortex.discover().keys()[0]
self.device_id = list(self.vortex.discover().keys())[0]
self.vortex[self.device_id].call_single('BLAUTO0')
def run(self):
self.loop_start()
@ -53,12 +54,15 @@ class VortexSpejsIOTClient(mqtt.Client):
self.logger.info('mqtt -> %r %r', topic, msg.payload)
node, attrib, _ = topic.split('/')
msg.payload = msg.payload.decode('utf-8')
if node in config.INPUTS:
if attrib == 'gain':
self.multi_call('GAINI', config.INPUTS[node], msg.payload)
elif attrib == 'mute':
self.multi_call('MUTEI', config.INPUTS[node], '1' if msg.payload == 'true' else '0')
elif attrib == 'mode':
self.multi_call('MIC', config.INPUTS[node], '1' if msg.payload == 'mic' else '0')
elif node in config.OUTPUTS:
if attrib == 'gain':
self.multi_call('GAINO', config.OUTPUTS[node], msg.payload)