diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..ac85c44 --- /dev/null +++ b/config.toml @@ -0,0 +1,5 @@ +[p1malina] +projektor_glavni = "" +projektor_stranski = "" +extron_audio_matrika = "" + diff --git a/extron_audio_matrix/extron_audio_matrix_telnet_control.py b/extron_audio_matrix/extron_audio_matrix_telnet_control.py index 396d139..52a8180 100644 --- a/extron_audio_matrix/extron_audio_matrix_telnet_control.py +++ b/extron_audio_matrix/extron_audio_matrix_telnet_control.py @@ -7,15 +7,16 @@ from extron_audio_matrix_telnet_interpreter import * async def extron_audio_telnet_status(client, reader): - while True: #TODO TODO TODO + while True: output = await reader.readuntil(b']') - raw_response: str = output.decode().strip() # strip not necessary? needed for local netcat testing though - print("Received: " + raw_response + " from Barco") + # EAMValue(action, io_type, line_id, value) + raw_response: str = output.decode().strip() + print("Received: " + raw_response + " from Extron") parsed = eam_telnet_code_to_field(raw_response) if parsed == None: continue # TODO alert for errors - print(f"Updating topic [{parsed[0]}] with value [{parsed[1]}]") - await client.publish(f"p1/projectors/main/status/{parsed[0]}", payload=parsed[1]) + #print(f"Updating topic [{parsed[0]}] with value [{parsed[1]}]") + await client.publish(f"p1/audio_matrix/status/test", payload='test') async def extron_audio_telnet_control(client, writer): diff --git a/extron_audio_matrix/extron_audio_matrix_telnet_interpreter.py b/extron_audio_matrix/extron_audio_matrix_telnet_interpreter.py index 0a009b3..a6406e9 100644 --- a/extron_audio_matrix/extron_audio_matrix_telnet_interpreter.py +++ b/extron_audio_matrix/extron_audio_matrix_telnet_interpreter.py @@ -33,6 +33,7 @@ class EAMValue: def field_to_eam_telnet_code(field: EAMValue) -> str: _io = str(field.io + field.id) + # cursed conversion to extron speak, this is how it was in the documentation _val = str(int(float(field.val) * 10) + 2048) if field.act == ActionType.Gain else \ (1 if field.val == "ON" else 0) return f"\e{field.act}{_io}*{_val}AU\r\n" diff --git a/tse_serial/tse_serial_controler.py b/tse_serial/tse_serial_controler.py index 63c721e..eda7e7f 100644 --- a/tse_serial/tse_serial_controler.py +++ b/tse_serial/tse_serial_controler.py @@ -30,7 +30,7 @@ async def task_command2serial(controlClient: aiomqtt.Client): async with controlClient.messages() as msgs: async for mesg in msgs: mesg: aiomqtt.Message - if mesg.topic.matches('p1/tseRelays/+/command'): + if mesg.topic.matches('p1/tse_box/+/ukaz'): msgTopic = mesg.topic.value cmnd = mesg.payload.decode() print("Received: [" + msgTopic + "] payload: [" + cmnd + "]") @@ -42,7 +42,7 @@ async def task_command2serial(controlClient: aiomqtt.Client): await aser.write_async(bytes(setRelay + '\r\n', "ascii")) publishTopic = f"p1/tseRelays/{relState.relay_id}/status" - publishPayload = "ON" if relState.state else "OFF" + publishPayload = "1" if relState.state else "0" print("Also publishing topic [" + publishTopic + "] with status [" + publishPayload + "]") await controlClient.publish(publishTopic, payload=publishPayload)