temporary hardcoding of addresses, ready for test

This commit is contained in:
0xEmm 2024-05-21 15:47:01 +02:00
parent 8a3eb2de70
commit b665085833
4 changed files with 14 additions and 7 deletions

5
config.toml Normal file
View file

@ -0,0 +1,5 @@
[p1malina]
projektor_glavni = ""
projektor_stranski = ""
extron_audio_matrika = ""

View file

@ -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):

View file

@ -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"

View file

@ -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)