SOLVED - Creating MQTT Publish for MQTT Discovery with JSON (Dingitan MQTT I/O Card)

Hi,

I am wishing to publish to the broker, such that HA MQTT Discovery picks up the device.

So far I have success for a binary_sensor and switch, but I would like to improve the switch as it has enhanced function shown here by use of the “control”

Which switches the relay on for 5 sec then auto off.

So for a simple on/off the following works inserted as YAML in a script via Lovelace

service: mqtt.publish
data:
  topic: homeassistant/switch/Lower_Garage_IO/Output_1/config
  payload: >-
    {
    "name": "DingtianIO_Output1",
    "state_topic": "/dingtian/relay3213/out/r1",
    "command_topic" : "/dingtian/relay3213/in/r1",
    "unique_id": "digitian3213_r1",
    "payload_on" : "ON",
    "payload_off" : "OFF",
    "device": {      
      "identifiers": [ "dingtian3213" ],   
      "manufacturer": "Dingtian",
      "model": "RelayCard", 
      "name": "Dingitan Relay Card"   
      }
    }

But I can not for the life of me figure out how to make it work. This is one of the many failed attempts

service: mqtt.publish
data:
  topic: homeassistant/switch/Lower_Garage_IO/Output_1/config
  payload: >-
    {
    "name": "DingtianIO_Output1",
    "state_topic": "/dingtian/relay3213/out/r1",
    "state_on: "ON",
    "state_off: "OFF",
    "command_topic" : "/dingtian/relay3213/in/control",
    "unique_id": "digitian3213_r1",
    "payload_on" : {"type":"DELAY","idx":"1","status":"ON","time":"5","pass":"0"},
    "device": {      
      "identifiers": [ "dingtian3213" ],   
      "manufacturer": "Dingtian",
      "model": "RelayCard", 
      "name": "Dingitan Relay Card"   
      }
    }

Thankyou
James

service: mqtt.publish
data:
  topic: homeassistant/switch/Lower_Garage_IO/Output_1/config
  payload: >-
    {
    "name": "DingtianIO_Output1",
    "state_topic": "/dingtian/relay3213/out/r1",
    "state_on" : "ON",
    "state_off" : "OFF",
    "command_topic" : "/dingtian/relay3213/in/control",
    "payload_on": "{ \"type\":\"DELAY\",\"status\":\"ON\",\"idx\":\"1\",\"time\":\"5\",\"pass\":\"0\" }",
    "payload_off": "{ \"type\":\"DELAY\",\"status\":\"OFF\",\"idx\":\"1\",\"time\":\"5\",\"pass\":\"0\" }",
    "unique_id": "digitian3213_r1",
    "device": {      
      "identifiers": [ "dingtian3213_2" ],   
      "manufacturer": "Dingtian",
      "model": "RelayCard", 
      "name": "Dingitan Relay Card"   
      }
    }