Hey guys,
I know there are many posts to this topic but since no solution worked out for me, I thought I post my problem and hopefully someone can help me.
So I am trying to add two entities via the topics from my esp32 and group them in a device via mqtt discovery:
"homeassistant/switch/"+clientId+"/switch_1/config"
"homeassistant/switch/"+clientId+"/switch_2/config"
The payloads are:
char json[512];
size_t n = sprintf(json, "{"
"\"name\":\"Switch 1\","
"\"uniq_id\":\"switch_1\","
"\"stat_t\":\"%s\"," //sw1_state_topic
"\"cmd_t\":\"%s\"," //sw1_command_topic
"\"pl_on\":\"on\","
"\"pl_off\":\"off\","
"\"ret\":true,"
"\"dev\":{"
"\"ids\":[\"%s\"]," //clientId
"\"name\":\"%s\"," //host
"\"mdl\":\"%s\"," //host
"\"sw\":\"%s\"," //version
"\"mf\":\"lg\""
"}"
"}", sw1_state_topic, sw1_command_topic, clientId, host, host, version);
and
char json[512];
size_t n = sprintf(json, "{"
"\"name\":\"Switch 2\","
"\"uniq_id\":\"switch_2\","
"\"stat_t\":\"%s\"," //sw2_state_topic
"\"cmd_t\":\"%s\"," //sw2_command_topic
"\"pl_on\":\"on\","
"\"pl_off\":\"off\","
"\"ret\":true,"
"\"dev\":{"
"\"ids\":[\"%s\"]," //clientId
"\"name\":\"%s\"," //host
"\"mdl\":\"%s\"," //host
"\"sw\":\"%s\"," //version
"\"mf\":\"lg\""
"}"
"}", sw2_state_topic, sw2_command_topic, clientId, host, host, version);
The interesting part is that the entities are added when i leave out the “dev”-Part. But with the dev-Part nothing happens at all. Homeassistant logs dont show anything either. I am using the Homeassistant docker-container with a mosquitto-container.