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