mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-08 08:55:55 +00:00
Resolved merge issues
This commit is contained in:
@ -1256,41 +1256,6 @@ void get_Relay_PWM_Count(int *relayCount, int *pwmCount){
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Sends HomeAssistant discovery MQTT messages.
|
||||
/// @param request
|
||||
/// @return
|
||||
int http_fn_ha_discovery(http_request_t *request) {
|
||||
int i;
|
||||
char topic[32];
|
||||
int relayCount=0;
|
||||
int pwmCount=0;
|
||||
|
||||
http_setup(request, httpMimeTypeText);
|
||||
get_Relay_PWM_Count(&relayCount, &pwmCount);
|
||||
|
||||
if ((relayCount == 0) && (pwmCount == 0)) {
|
||||
poststr(request, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// @brief Computes the Relay and PWM count.
|
||||
/// @param relayCount
|
||||
/// @param pwmCount
|
||||
void get_Relay_PWM_Count(int *relayCount, int *pwmCount){
|
||||
(*relayCount) = 0;
|
||||
(*pwmCount) = 0;
|
||||
|
||||
for(int i = 0; i < PLATFORM_GPIO_MAX; i++) {
|
||||
int role = PIN_GetPinRoleForPinIndex(i);
|
||||
if(role == IOR_Relay || role == IOR_Relay_n || role == IOR_LED || role == IOR_LED_n) {
|
||||
(*relayCount)++;
|
||||
}
|
||||
else if(role == IOR_PWM || role == IOR_PWM_n) {
|
||||
(*pwmCount)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Sends HomeAssistant discovery MQTT messages.
|
||||
/// @param request
|
||||
/// @return
|
||||
@ -1327,7 +1292,7 @@ int http_fn_ha_discovery(http_request_t *request) {
|
||||
|
||||
if(pwmCount > 0) {
|
||||
char tmp[64];
|
||||
const char *baseName = CFG_GetShortDeviceName();
|
||||
const char *shortDeviceName = CFG_GetShortDeviceName();
|
||||
|
||||
for(i = 0; i < CHANNEL_MAX; i++) {
|
||||
if(h_isChannelPWM(i)) {
|
||||
@ -1336,7 +1301,7 @@ int http_fn_ha_discovery(http_request_t *request) {
|
||||
cJSON_AddStringToObject(dev_info->root, "on_cmd_type", "brightness"); //on_command_type
|
||||
cJSON_AddNumberToObject(dev_info->root, "bri_scl", 99); //brightness_scale
|
||||
|
||||
sprintf(tmp,"%s/%i/set",baseName,i);
|
||||
sprintf(tmp,"%s/%i/set",shortDeviceName,i);
|
||||
cJSON_AddStringToObject(dev_info->root, "bri_cmd_t", tmp); //brightness_command_topic
|
||||
|
||||
MQTT_QueuePublish(topic, dev_info->channel, hass_build_discovery_json(dev_info), OBK_PUBLISH_FLAG_RETAIN);
|
||||
@ -1352,6 +1317,8 @@ int http_fn_ha_discovery(http_request_t *request) {
|
||||
int http_fn_ha_cfg(http_request_t *request) {
|
||||
int relayCount = 0;
|
||||
int pwmCount = 0;
|
||||
const char *shortDeviceName;
|
||||
const char *clientId;
|
||||
int i;
|
||||
char mqttAdded = 0;
|
||||
char *uniq_id;
|
||||
@ -1437,15 +1404,10 @@ int http_fn_ha_cfg(http_request_t *request) {
|
||||
}
|
||||
|
||||
poststr(request,"</textarea>");
|
||||
|
||||
poststr(request, HomeAssistantDiscoveryScript);
|
||||
poststr(request,"<br/><div><label for=\"ha_disc_topic\">Discovery topic:</label><input id=\"ha_disc_topic\" value=\"homeassistant\"><button onclick=\"send_ha_disc();\">Start Home Assistant Discovery</button> <form action=\"cfg_mqtt\" style=\"display:inline-block;\"><button type=\"submit\">Configure MQTT</button></form></div><br/>");
|
||||
|
||||
poststr(request,htmlReturnToCfg);
|
||||
HTTP_AddBuildFooter(request);
|
||||
poststr(request,htmlEnd);
|
||||
|
||||
poststr(request,htmlFooterReturnToCfgLink);
|
||||
http_html_end(request);
|
||||
poststr(request, HomeAssistantDiscoveryScript);
|
||||
poststr(request, NULL);
|
||||
return 0;
|
||||
}
|
||||
@ -1584,9 +1546,7 @@ int http_fn_cm(http_request_t *request) {
|
||||
|
||||
int http_fn_cfg(http_request_t *request) {
|
||||
http_setup(request, httpMimeTypeHTML);
|
||||
poststr(request,htmlHeader);
|
||||
HTTP_AddHeader(request);
|
||||
|
||||
http_html_start(request, "Config");
|
||||
postFormAction(request, "cfg_pins", "Configure Module");
|
||||
postFormAction(request, "cfg_generic", "Configure General");
|
||||
postFormAction(request, "cfg_startup", "Configure Startup");
|
||||
|
||||
Reference in New Issue
Block a user