Skip to content

Commit

Permalink
Remove dot from MQTT topic as it confuses HA
Browse files Browse the repository at this point in the history
  • Loading branch information
fredlcore committed Dec 28, 2024
1 parent d4de3b6 commit 44ef6c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
17 changes: 13 additions & 4 deletions BSB_LAN/BSB_LAN.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1176,9 +1176,9 @@ float get_next_prognr(float currentProgNr){
} else {
if(recognizeVirtualFunctionGroup(currentProgNr + 1)){
#if defined(__SAM3X8E__)
double intpart;
double intpart;
#else
float intpart;
float intpart;
#endif
modf(currentProgNr, &intpart);
nextprognr = intpart + 1;
Expand Down Expand Up @@ -1640,6 +1640,15 @@ void remove_char(char* str, char c) {
*pw = '\0';
}

void replace_char(char *str, char find, char replace) {
while (*str) { // Traverse the string until null terminator
if (*str == find) {
*str = replace; // Replace the character
}
str++;
}
}

void resetDurations() {
brenner_duration=0;
brenner_count=0;
Expand Down Expand Up @@ -3708,7 +3717,7 @@ void queryVirtualPrognr(float line, int table_line) {
}
case 4: {
size_t log_sensor = roundf(line - (float)BSP_ONEWIRE);
if (One_Wire_Pin >= 0 && numSensors) {
if (oneWire && numSensors) {
switch (((int)roundf((line - (float)BSP_ONEWIRE) * 10)) % 10) {
case 0: //print sensor ID
DeviceAddress device_address;
Expand Down Expand Up @@ -6819,7 +6828,7 @@ next_parameter:
}

{
if (One_Wire_Pin >= 0) {
if (oneWire) {
unsigned long tempTime = millis() / ONE_WIRE_REQUESTS_PERIOD;
if (tempTime != lastOneWireRequestTime) {
sensors->requestTemperatures(); //call it outside of here for more faster answers
Expand Down
1 change: 1 addition & 0 deletions BSB_LAN/include/mqtt_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ boolean mqtt_send_discovery(boolean create=true) {

appendStringBuffer(&sb_topic, "BSB-LAN/%g-%d-%d-%d/config", line, active_cmdtbl[i].dev_fam, active_cmdtbl[i].dev_var, my_dev_serial);

replace_char(MQTTTopic, '.', '-');
if (!create) {
MQTTPayload[0] = '\0'; // If remove flag is set, send empty message to instruct auto discovery to remove the entry
}
Expand Down

0 comments on commit 44ef6c0

Please sign in to comment.