Dingtian IOT Relay Generic MQTT Things

Hi, I need a little help creating “things” for this module. I can read the status but not control it. the command in home assistant looks like this:

  - platform: mqtt
    name: "lan relay 1"
    state_topic: "/dingtian/relay1916/out/relay1"
    command_topic: "/dingtian/relay1916/in/control"
    payload_on: '{"type":"ON/OFF","idx":"1","status":"ON","time":"0","pass":"0"}'
    payload_off: '{"type":"ON/OFF","idx":"1","status":"OFF","time":"0","pass":"0"}'
    state_on: '{"idx":"1","status":"ON"}'
    state_off: '{"idx":"1","status":"OFF"}'

in Openhab like this:

Type switch : Din01r2  [ stateTopic="/dingtian/relay1916/out/relay2" , transformationPattern="JSONPATH:$.status", commandTopic="/dingtian/relay1916/in/control", on="ON", off="OFF"]

For the module to react, I have to send the following message:

control = {"type":"ON/OFF","idx":"1","status":"ON","time":"0","pass":"0"}

Thanks for your help

I found a solution

Type switch : Din01r1  [ stateTopic="/dingtian/relay1916/out/relay1" , transformationPattern="JSONPATH:$.status", commandTopic="/dingtian/relay1916/in/control", on="{\"type\":\"ON/OFF\",\"idx\":\"1\",\"status\":\"ON\",\"time\":\"0\",\"pass\":\"0\"}", off="{\"type\":\"ON/OFF\",\"idx\":\"1\",\"status\":\"OFF\",\"time\":\"0\",\"pass\":\"0\"}"] //Relay1
1 Like