mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-09 04:35:57 +00:00
Consistent clientId, shortDeviceName vars
This commit is contained in:
@ -527,7 +527,7 @@ int http_fn_cfg_mqtt(http_request_t *request) {
|
||||
i = CFG_GetMQTTPort();
|
||||
hprintf128(request, "%i", i);
|
||||
poststr(request,"\"><br><br>\
|
||||
<label for=\"port\">Client:</label><br>\
|
||||
<label for=\"port\">Client ID:</label><br>\
|
||||
<input type=\"text\" id=\"client\" name=\"client\" value=\"");
|
||||
|
||||
poststr(request,CFG_GetMQTTClientId());
|
||||
@ -818,7 +818,7 @@ int http_fn_cfg_name(http_request_t *request) {
|
||||
poststr(request,htmlHeader);
|
||||
HTTP_AddHeader(request);
|
||||
|
||||
poststr(request,"<h2> Change device names for display. </h2> Remember that short name is used by MQTT.<br>");
|
||||
poststr(request,"<h2> Change device names for display. </h2>");
|
||||
if(http_getArg(request->url,"shortName",tmpA,sizeof(tmpA))) {
|
||||
CFG_SetShortDeviceName(tmpA);
|
||||
}
|
||||
@ -1265,20 +1265,20 @@ void build_hass_unique_id(char *outBuffer, char *type, int index){
|
||||
int http_fn_cfg_ha(http_request_t *request) {
|
||||
int relayCount = 0;
|
||||
int pwmCount = 0;
|
||||
const char *baseName;
|
||||
const char *topicName;
|
||||
const char *shortDeviceName;
|
||||
const char *clientId;
|
||||
int i;
|
||||
char mqttAdded = 0;
|
||||
char unique_id[128]; //64 for longDeviceName, 10 for type,3 for index .. 128 would be sufficient
|
||||
|
||||
baseName = CFG_GetShortDeviceName();
|
||||
topicName = CFG_GetMQTTClientId();
|
||||
shortDeviceName = CFG_GetShortDeviceName();
|
||||
clientId = CFG_GetMQTTClientId();
|
||||
|
||||
http_setup(request, httpMimeTypeHTML);
|
||||
poststr(request,htmlHeader);
|
||||
HTTP_AddHeader(request);
|
||||
poststr(request,"<h4>Home Assistant Cfg</h4>");
|
||||
hprintf128(request,"<h4>Note that your short device name is: %s</h4>",baseName);
|
||||
hprintf128(request,"<h4>Note that your short device name is: %s</h4>",shortDeviceName);
|
||||
poststr(request,"<h4>Paste this to configuration yaml</h4>");
|
||||
poststr(request,"<h5>Make sure that you have \"switch:\" keyword only once! Home Assistant doesn't like dup keywords.</h5>");
|
||||
poststr(request,"<h5>You can also use \"switch MyDeviceName:\" to avoid keyword duplication!</h5>");
|
||||
@ -1312,15 +1312,15 @@ int http_fn_cfg_ha(http_request_t *request) {
|
||||
|
||||
build_hass_unique_id(unique_id,"relay",i);
|
||||
hprintf128(request," - unique_id: \"%s\"\n",unique_id);
|
||||
hprintf128(request," name: \"%s %i\"\n",baseName,i);
|
||||
hprintf128(request," state_topic: \"%s/%i/get\"\n",topicName,i);
|
||||
hprintf128(request," command_topic: \"%s/%i/set\"\n",topicName,i);
|
||||
hprintf128(request," name: \"%s %i\"\n",shortDeviceName,i);
|
||||
hprintf128(request," state_topic: \"%s/%i/get\"\n",clientId,i);
|
||||
hprintf128(request," command_topic: \"%s/%i/set\"\n",clientId,i);
|
||||
poststr(request, " qos: 1\n");
|
||||
poststr(request, " payload_on: 1\n");
|
||||
poststr(request, " payload_off: 0\n");
|
||||
poststr(request, " retain: true\n");
|
||||
hprintf128(request," availability:\n");
|
||||
hprintf128(request," - topic: \"%s/connected\"\n",topicName);
|
||||
hprintf128(request," - topic: \"%s/connected\"\n",clientId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1340,10 +1340,10 @@ int http_fn_cfg_ha(http_request_t *request) {
|
||||
|
||||
build_hass_unique_id(unique_id,"light",i);
|
||||
hprintf128(request," - unique_id: \"%s\"\n",unique_id);
|
||||
hprintf128(request," name: \"%s %i\"\n",baseName,i);
|
||||
hprintf128(request," state_topic: \"%s/%i/get\"\n",topicName,i);
|
||||
hprintf128(request," command_topic: \"%s/%i/set\"\n",topicName,i);
|
||||
hprintf128(request," brightness_command_topic: \"%s/%i/set\"\n",topicName,i);
|
||||
hprintf128(request," name: \"%s %i\"\n",shortDeviceName,i);
|
||||
hprintf128(request," state_topic: \"%s/%i/get\"\n",clientId,i);
|
||||
hprintf128(request," command_topic: \"%s/%i/set\"\n",clientId,i);
|
||||
hprintf128(request," brightness_command_topic: \"%s/%i/set\"\n",clientId,i);
|
||||
poststr(request, " on_command_type: \"brightness\"\n");
|
||||
poststr(request, " brightness_scale: 99\n");
|
||||
poststr(request, " qos: 1\n");
|
||||
@ -1352,7 +1352,7 @@ int http_fn_cfg_ha(http_request_t *request) {
|
||||
poststr(request, " retain: true\n");
|
||||
poststr(request, " optimistic: true\n");
|
||||
hprintf128(request," availability:\n");
|
||||
hprintf128(request," - topic: \"%s/connected\"\n",topicName);
|
||||
hprintf128(request," - topic: \"%s/connected\"\n",clientId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1455,15 +1455,15 @@ int http_tasmota_json_status_SNS(http_request_t *request) {
|
||||
int http_tasmota_json_status_generic(http_request_t *request) {
|
||||
const char *deviceName;
|
||||
const char *friendlyName;
|
||||
const char *topic;
|
||||
const char *clientId;
|
||||
|
||||
deviceName = CFG_GetShortDeviceName();
|
||||
friendlyName = CFG_GetDeviceName();
|
||||
topic = CFG_GetMQTTClientId();
|
||||
clientId = CFG_GetMQTTClientId();
|
||||
|
||||
hprintf128(request,"{\"Status\":{\"Module\":0,\"DeviceName\":\"%s\"",deviceName);
|
||||
hprintf128(request,",\"FriendlyName\":[\"%s\"]",friendlyName);
|
||||
hprintf128(request,",\"Topic\":\"%s\",\"ButtonTopic\":\"0\"",topic);
|
||||
hprintf128(request,",\"Topic\":\"%s\",\"ButtonTopic\":\"0\"",clientId);
|
||||
hprintf128(request,",\"Power\":1,\"PowerOnState\":3,\"LedState\":1");
|
||||
hprintf128(request,",\"LedMask\":\"FFFF\",\"SaveData\":1,\"SaveState\":1");
|
||||
hprintf128(request,",\"SwitchTopic\":\"0\",\"SwitchMode\":[0,0,0,0,0,0,0,0]");
|
||||
|
||||
Reference in New Issue
Block a user