@@ -880,7 +880,7 @@ void HandleAndSendButtonPress(uint button, bool state)
880880 // Prüfen ob über MQTT versendet werden muss
881881 if (mqttAktiv == true && client.connected ())
882882 {
883- client.publish ((mqttMasterTopic + " buttons" ) .c_str (), String ( " { \" " + btnAPINames[button] + " \" : " + ( state ? " true" : " false" ) + " } " ). c_str ( ), true );
883+ client.publish ((mqttMasterTopic + " buttons/button " + String (button)) .c_str (), ( state ? " true" : " false" ), true );
884884 }
885885 // Prüfen ob über Websocket versendet werden muss
886886 if (webSocket.connectedClients () > 0 )
@@ -2435,8 +2435,10 @@ boolean MQTTreconnect()
24352435 " \" pl_avail\" :\" connected\" ,"
24362436 " \" pl_not_avail\" :\" disconnected\" ,"
24372437 " \" uniq_id\" :\" #DEVICEID##SENSORID#\" ,"
2438- " \" dev_cla\" :\" timestamp\" ,"
24392438 " \" name\" :\" #SENSORNAME#\" ,"
2439+ " \" ic\" :\" mdi:gesture-tap-button\" ,"
2440+ " \" pl_on\" :\" true\" ,"
2441+ " \" pl_off\" :\" false\" ,"
24402442 " \" stat_t\" :\" #MASTERTOPIC##STATETOPIC#\" "
24412443 " }" ));
24422444 configPayloadTemplate.replace (" " , " " );
@@ -2451,13 +2453,13 @@ boolean MQTTreconnect()
24512453 if (btnEnabled[n])
24522454 {
24532455 topic = configTopicTemplate;
2454- topic.replace (F (" #COMPONENT#" ), F (" sensor " ));
2456+ topic.replace (F (" #COMPONENT#" ), F (" binary_sensor " ));
24552457 topic.replace (F (" #SENSORID#" ), String (F (" Button" )) + String (n));
24562458
24572459 payload = configPayloadTemplate;
24582460 payload.replace (F (" #SENSORID#" ), String (F (" Button" )) + String (n));
2459- payload.replace (F (" #SENSORNAME#" ), String (F ( " Button " )) + String (n ));
2460- payload.replace (F (" #STATETOPIC#" ), String (F (" button" )) + String (n));
2461+ payload.replace (F (" #SENSORNAME#" ), String (btnLogNames[n] ));
2462+ payload.replace (F (" #STATETOPIC#" ), String (F (" buttons/ button" )) + String (n));
24612463 client.publish (topic.c_str (), payload.c_str (), true );
24622464 }
24632465 }
0 commit comments