Skip to content

Commit

Permalink
Fix inconsistent replacement of spaces in body name leading to unusab…
Browse files Browse the repository at this point in the history
…le MQTT bindings in HA
  • Loading branch information
lymanepp committed Feb 25, 2024
1 parent 40cd060 commit 27eec58
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions defaultConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
"username": "",
"password": "",
"selfSignedCertificate": false,
"rootTopic": "@bind=(state.equipment.model).replace(' ','-').replace('/','').toLowerCase();",
"rootTopic": "@bind=(state.equipment.model).replace(/ /g,'-').replace('/','').toLowerCase();",
"retain": true,
"qos": 0,
"changesOnly": true
Expand Down Expand Up @@ -204,7 +204,7 @@
"port": 1883,
"username": "",
"password": "",
"rootTopic": "@bind=(state.equipment.model).replace(' ','-').replace('/','').toLowerCase();Alt",
"rootTopic": "@bind=(state.equipment.model).replace(/ /,'-').replace('/','').toLowerCase();Alt",
"retain": true,
"qos": 0,
"changesOnly": true
Expand All @@ -230,7 +230,7 @@
"vars": {
"_note": "hassTopic is the topic that HASS reads for configuration and should not be changed. mqttTopic should match the topic in the MQTT binding (do not use MQTTAlt for HASS).",
"hassTopic": "homeassistant",
"mqttTopic": "@bind=(state.equipment.model).replace(' ','-').replace('/','').toLowerCase();"
"mqttTopic": "@bind=(state.equipment.model).replace(/ /g,'-').replace('/','').toLowerCase();"
}
},
"rem": {
Expand Down
4 changes: 2 additions & 2 deletions web/bindings/homeassistant.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
],
"rootTopic-DIRECTIONS": "rootTopic in config.json is ingored. Instead set the two topic variables in the vars section",
"_rootTopic": "@bind=(state.equipment.model).replace(' ','-').replace(' / ','').toLowerCase();",
"_rootTopic": "@bind=(state.equipment.model).replace(/ /g,'-').replace(' / ','').toLowerCase();",
"clientId": "@bind=`hass_njsPC_${webApp.mac().replace(/:/g, '_'}-${webApp.httpPort()}`;"
}
},
Expand Down Expand Up @@ -434,4 +434,4 @@
]
}
]
}
}
4 changes: 2 additions & 2 deletions web/services/utilities/Utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class UtilitiesRoute {
options: {
protocol: 'mqtt://', host: '', port: 1883, username: '', password: '',
selfSignedCertificate: false,
rootTopic: "pool/@bind=(state.equipment.model).replace(' ','-').replace(' / ','').toLowerCase();",
rootTopic: "pool/@bind=(state.equipment.model).replace(/ /g,'-').replace(' / ','').toLowerCase();",
retain: true, qos: 0, changesOnly: true
}
}
Expand Down Expand Up @@ -230,4 +230,4 @@ export class UtilitiesRoute {
});

}
}
}

0 comments on commit 27eec58

Please sign in to comment.