"""
Name: mqtt_publisher_hanover
Title:
Author: Cooper
Date: 10/02/2025

Desc: Originally the Help Albert please script, this is now a part of the toolkit

"""
import paho.mqtt.client as mqtt
import json
import time

brokerAddress = input("Broker IP: ")
topic = "infohub/dpi/sign/request/#/json"

client = mqtt.Client()
client.connect(brokerAddress)

clear_sign = {
    "protocolData": {
        "hanover_hcp": {
            "command": "C",
            "message": ""
        }
    }
}

test_sign = {
    "protocolData": {
        "hanover_hcp": {
            "command": "3",
            "message": ""
        }
    }
}

test_sign_ext = {
    "protocolData": {
        "hanover_hcp": {
            "command": "3",
            "message": "1"
        }
    }
}

hello_world = {
    "protocolData": {
        "hanover_hcp": {
            "command": "0",
            "message": r"{\mode0\pt20{Hello}\rep1}{\mode0\pt20{World}\rep1}"
        }
    }
}

hello_world_col = {
    "protocolData": {
        "hanover_hcp": {
            "command": "0",
            "message": r"{\mode1{\*\mrn\fg48\bg0\sc0\st0\fc65280\bc0\it0\ic0\oc0\ot0\osp0}\hs1\mss0\rw40{123}\fs\fit2{Hello World}}"
        }
    }
}

red_msg = {
    "protocolData": {
        "hanover_hcp": {
            "command": "0",
            "message": r"{\mode0\fit2{\*\mrn\fg3\bg3\sc0\st0\fc255\bc255\it0\ic0\oc0\ot0\osp0}{\inv}}"
        }
    }
}

green_msg = {
    "protocolData": {
        "hanover_hcp": {
            "command": "0",
            "message": r"{\mode0\fit2{\*\mrn\fg48\bg48\sc0\st0\fc65280\bc65280\it0\ic0\oc0\ot0\osp0}{\inv}}"
        }
    }
}

blue_msg = {
    "protocolData": {
        "hanover_hcp": {
            "command": "0",
            "message": r"{\mode0\fit2{\*\mrn\fg12\bg12\sc0\st0\fc16711680\bc16711680\it0\ic0\oc0\ot0\osp0}{\inv}}"
        }
    }
}


def send_data(data):
    jsonmsg = json.dumps(data)
    for sign in range(7):
        client.publish(topic.replace("#", str(sign)), jsonmsg)

    time.sleep(1)


while 1:
    print("Pick from the following:\n1: Clear\n2,2ext: Test\n3: Mono text\n4: Colour text\nr,g,b: Colour fill")
    choice = input("> ")

    if choice == "1":
        send_data(clear_sign)
    elif choice == "2":
        send_data(test_sign)
    elif choice == "2ext":
        send_data(test_sign_ext)
    elif choice == "3":
        send_data(hello_world)
    elif choice == "4":
        send_data(hello_world_col)
    elif choice == "r":
        send_data(red_msg)
    elif choice == "g":
        send_data(green_msg)
    elif choice == "b":
        send_data(blue_msg)
    else:
        pass


if __name__ == "__main__":
    pass