在Web后台增加电源指示灯的开关,修改耗电量统计的定时器逻辑

This commit is contained in:
nhkefus
2025-03-11 10:48:14 +08:00
parent 52580ea751
commit 7af99b3109
7 changed files with 1175 additions and 1076 deletions

View File

@@ -52,7 +52,7 @@
static bool is_http_init;
static bool is_handlers_registered;
const struct httpd_wsgi_call g_app_handlers[];
char power_info_json[1552] = { 0 };
char power_info_json[1552] = {0};
char up_time[16] = "00:00:00";
/*
@@ -90,8 +90,7 @@ void GetPraFromUrl(char* url, char* pra, char* val)
}
*/
static int HttpGetIndexPage(httpd_request_t *req)
{
static int HttpGetIndexPage(httpd_request_t *req) {
OSStatus err = kNoErr;
err = httpd_send_all_header(req, HTTP_RES_200, sizeof(web_index_html), HTTP_CONTENT_HTML_ZIP);
@@ -100,44 +99,37 @@ static int HttpGetIndexPage(httpd_request_t *req)
err = httpd_send_body(req->sock, web_index_html, sizeof(web_index_html));
require_noerr_action(err, exit, http_log("ERROR: Unable to send http index body."));
exit:
exit:
return err;
}
static int HttpGetDemoPage(httpd_request_t *req)
{
static int HttpGetDemoPage(httpd_request_t *req) {
OSStatus err = kNoErr;
err = httpd_send_all_header(req, HTTP_RES_200, sizeof(web_index_html), HTTP_CONTENT_HTML_ZIP);
require_noerr_action(err, exit, http_log("ERROR: Unable to send http demo headers."));
err = httpd_send_body(req->sock, web_index_html, sizeof(web_index_html));
require_noerr_action(err, exit, http_log("ERROR: Unable to send http demo body."));
exit:
exit:
return err;
}
static int HttpGetAssets(httpd_request_t *req)
{
static int HttpGetAssets(httpd_request_t *req) {
OSStatus err = kNoErr;
char* file_name = strstr(req->filename, "/assets/");
if (!file_name)
{
http_log("HttpGetAssets url[%s] err", req->filename);
char *file_name = strstr(req->filename, "/assets/");
if (!file_name) { http_log("HttpGetAssets url[%s] err", req->filename);
return err;
}
//http_log("HttpGetAssets url[%s] file_name[%s]", req->filename, file_name);
int total_sz = 0;
const unsigned char* file_data = NULL;
const char* content_type = HTTP_CONTENT_JS_ZIP;
if (strcmp(file_name + 8, "js_pack.js") == 0)
{
const unsigned char *file_data = NULL;
const char *content_type = HTTP_CONTENT_JS_ZIP;
if (strcmp(file_name + 8, "js_pack.js") == 0) {
total_sz = sizeof(js_pack);
file_data = js_pack;
}
else if (strcmp(file_name + 8, "css_pack.css") == 0)
{
} else if (strcmp(file_name + 8, "css_pack.css") == 0) {
total_sz = sizeof(css_pack);
file_data = css_pack;
content_type = HTTP_CONTENT_CSS_ZIP;
@@ -151,29 +143,29 @@ static int HttpGetAssets(httpd_request_t *req)
err = httpd_send_body(req->sock, file_data, total_sz);
require_noerr_action(err, exit, http_log("ERROR: Unable to send http assets body."));
exit:
exit:
return err;
}
static int HttpGetTc1Status(httpd_request_t *req)
{
char* sockets = GetSocketStatus();
char* tc1_status = malloc(512);
static int HttpGetTc1Status(httpd_request_t *req) {
char *sockets = GetSocketStatus();
char *tc1_status = malloc(512);
sprintf(tc1_status, TC1_STATUS_JSON, sockets, ip_status.mode,
sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key,
user_config->ap_name, user_config->ap_key, MQTT_SERVER, MQTT_SERVER_PORT, MQTT_SERVER_USR, MQTT_SERVER_PWD,
VERSION, ip_status.ip, ip_status.mask, ip_status.gateway,user_config->mqtt_report_freq, 0L);
sys_config->micoSystemConfig.ssid, sys_config->micoSystemConfig.user_key,
user_config->ap_name, user_config->ap_key, MQTT_SERVER, MQTT_SERVER_PORT,
MQTT_SERVER_USR, MQTT_SERVER_PWD,
VERSION, ip_status.ip, ip_status.mask, ip_status.gateway, user_config->mqtt_report_freq,
user_config->power_led_enabled, 0L);
OSStatus err = kNoErr;
send_http(tc1_status, strlen(tc1_status), exit, &err);
exit:
exit:
if (tc1_status) free(tc1_status);
return err;
}
static int HttpSetSocketStatus(httpd_request_t *req)
{
static int HttpSetSocketStatus(httpd_request_t *req) {
OSStatus err = kNoErr;
int buf_size = 512;
@@ -186,13 +178,12 @@ static int HttpSetSocketStatus(httpd_request_t *req)
send_http("OK", 2, exit, &err);
exit:
exit:
if (buf) free(buf);
return err;
}
static int HttpGetPowerInfo(httpd_request_t *req)
{
static int HttpGetPowerInfo(httpd_request_t *req) {
OSStatus err = kNoErr;
char buf[16];
err = httpd_get_data(req, buf, 16);
@@ -211,25 +202,24 @@ static int HttpGetPowerInfo(httpd_request_t *req)
int s = past % 60;
sprintf(up_time, "%d - %02d:%02d:%02d", d, h, m, s);
char* powers = GetPowerRecord(idx);
char* sockets = GetSocketStatus();
sprintf(power_info_json, POWER_INFO_JSON, sockets, power_record.idx, PW_NUM, p_count, powers, up_time);
char *powers = GetPowerRecord(idx);
char *sockets = GetSocketStatus();
sprintf(power_info_json, POWER_INFO_JSON, sockets, power_record.idx, PW_NUM, p_count, powers,
up_time,user_config->power_led_enabled);
send_http(power_info_json, strlen(power_info_json), exit, &err);
exit:
exit:
return err;
}
static int HttpGetWifiConfig(httpd_request_t *req)
{
static int HttpGetWifiConfig(httpd_request_t *req) {
OSStatus err = kNoErr;
char* status = "test";
char *status = "test";
send_http(status, strlen(status), exit, &err);
exit:
exit:
return err;
}
static int HttpSetWifiConfig(httpd_request_t *req)
{
static int HttpSetWifiConfig(httpd_request_t *req) {
OSStatus err = kNoErr;
int buf_size = 97;
@@ -242,65 +232,55 @@ static int HttpSetWifiConfig(httpd_request_t *req)
require_noerr(err, exit);
sscanf(buf, "%d %s %s", &mode, wifi_ssid, wifi_key);
if (mode == 1)
{
if (mode == 1) {
WifiConnect(wifi_ssid, wifi_key);
}
else
{
} else {
ApConfig(wifi_ssid, wifi_key);
}
send_http("OK", 2, exit, &err);
exit:
exit:
if (buf) free(buf);
if (wifi_ssid) free(wifi_ssid);
if (wifi_key) free(wifi_key);
return err;
}
static int HttpGetWifiScan(httpd_request_t *req)
{
static int HttpGetWifiScan(httpd_request_t *req) {
OSStatus err = kNoErr;
if (scaned)
{
if (scaned) {
scaned = false;
send_http(wifi_ret, strlen(wifi_ret), exit, &err);
free(wifi_ret);
}
else
{
} else {
send_http("NO", 2, exit, &err);
}
exit:
exit:
return err;
}
static int HttpSetWifiScan(httpd_request_t *req)
{
static int HttpSetWifiScan(httpd_request_t *req) {
micoWlanStartScanAdv();
OSStatus err = kNoErr;
send_http("OK", 2, exit, &err);
exit:
exit:
return err;
}
static int HttpSetRebootSystem(httpd_request_t *req)
{
static int HttpSetRebootSystem(httpd_request_t *req) {
OSStatus err = kNoErr;
send_http("OK", 2, exit, &err);
MicoSystemReboot();
exit:
exit:
return err;
}
static int HttpSetMqttConfig(httpd_request_t *req)
{
static int HttpSetMqttConfig(httpd_request_t *req) {
OSStatus err = kNoErr;
int buf_size = 97;
@@ -314,14 +294,13 @@ static int HttpSetMqttConfig(httpd_request_t *req)
send_http("OK", 2, exit, &err);
exit:
exit:
if (buf) free(buf);
return err;
}
static int HttpSetMqttReportFreq(httpd_request_t *req)
{
static int HttpSetMqttReportFreq(httpd_request_t *req) {
OSStatus err = kNoErr;
int buf_size = 97;
@@ -335,13 +314,12 @@ static int HttpSetMqttReportFreq(httpd_request_t *req)
send_http("OK", 2, exit, &err);
exit:
exit:
if (buf) free(buf);
return err;
}
static int HttpGetMqttReportFreq(httpd_request_t *req)
{
static int HttpGetMqttReportFreq(httpd_request_t *req) {
OSStatus err = kNoErr;
int buf_size = 97;
char *freq = malloc(buf_size);
@@ -349,103 +327,127 @@ static int HttpGetMqttReportFreq(httpd_request_t *req)
send_http(freq, strlen(freq), exit, &err);
exit:
exit:
return err;
}
static int HttpGetLog(httpd_request_t *req)
{
static int HttpGetLog(httpd_request_t *req) {
OSStatus err = kNoErr;
char* logs = GetLogRecord();
char *logs = GetLogRecord();
send_http(logs, strlen(logs), exit, &err);
exit:
exit:
return err;
}
static int HttpGetTasks(httpd_request_t *req)
{
static int HttpGetTasks(httpd_request_t *req) {
OSStatus err = kNoErr;
char* tasks_str = GetTaskStr();
char *tasks_str = GetTaskStr();
send_http(tasks_str, strlen(tasks_str), exit, &err);
exit:
exit:
if (tasks_str) free(tasks_str);
return err;
}
static int HttpAddTask(httpd_request_t *req)
{
static int HttpAddTask(httpd_request_t *req) {
OSStatus err = kNoErr;
//1577369623 4 0
char buf[16] = { 0 };
char buf[16] = {0};
err = httpd_get_data(req, buf, 16);
require_noerr(err, exit);
pTimedTask task = NewTask();
if (task == NULL)
{
http_log("NewTask() error, max task num = %d!", MAX_TASK_NUM);
char* mess = "NO SPACE";
if (task == NULL) { http_log("NewTask() error, max task num = %d!", MAX_TASK_NUM);
char *mess = "NO SPACE";
send_http(mess, strlen(mess), exit, &err);
return err;
}
int re = sscanf(buf, "%ld %d %d %d", &task->prs_time, &task->socket_idx, &task->on, &task->weekday);
http_log("AddTask buf[%s] re[%d] (%ld %d %d %d)",
buf, re, task->prs_time, task->socket_idx, task->on, task->weekday);
int re = sscanf(buf, "%ld %d %d %d", &task->prs_time, &task->socket_idx, &task->on,
&task->weekday);http_log("AddTask buf[%s] re[%d] (%ld %d %d %d)",
buf, re, task->prs_time, task->socket_idx, task->on,
task->weekday);
task->socket_idx--;
if (task->prs_time < 1577428136 || task->prs_time > 9577428136
|| task->socket_idx < 0 || task->socket_idx > 5
|| (task->on != 0 && task->on != 1))
{
http_log("AddTask Error!");
|| (task->on != 0 && task->on != 1)) { http_log("AddTask Error!");
re = 0;
}
char* mess = (re == 4 && AddTask(task)) ? "OK" : "NO";
char *mess = (re == 4 && AddTask(task)) ? "OK" : "NO";
send_http(mess, strlen(mess), exit, &err);
exit:
exit:
return err;
}
static int HttpDelTask(httpd_request_t *req)
{
static int HttpDelTask(httpd_request_t *req) {
OSStatus err = kNoErr;
char* time_str = strstr(req->filename, "/task/");
if (!time_str)
{
http_log("HttpDelTask url[%s] err", req->filename);
char *time_str = strstr(req->filename, "/task/");
if (!time_str) { http_log("HttpDelTask url[%s] err", req->filename);
return err;
}
http_log("HttpDelTask url[%s] time_str[%s][%s]", req->filename, time_str, time_str + 6);
}http_log("HttpDelTask url[%s] time_str[%s][%s]", req->filename, time_str, time_str + 6);
int time1;
sscanf(time_str + 6, "%d", &time1);
char* mess = DelTask(time1) ? "OK" : "NO";
char *mess = DelTask(time1) ? "OK" : "NO";
send_http(mess, strlen(mess), exit, &err);
exit:
exit:
return err;
}
static int Otastatus(httpd_request_t *req)
{
static int LedStatus(httpd_request_t *req) {
OSStatus err = kNoErr;
char buf[16] = { 0 };
int buf_size = 97;
char *led = malloc(buf_size);
sprintf(led, "%d", MQTT_LED_ENABLED);
send_http(led, strlen(led), exit, &err);
exit:
return err;
}
static int LedSetEnabled(httpd_request_t *req) {
OSStatus err = kNoErr;
int buf_size = 97;
char *buf = malloc(buf_size);
err = httpd_get_data(req, buf, buf_size);
require_noerr(err, exit);
sscanf(buf, "%d", &MQTT_LED_ENABLED);
if (RelayOut() && MQTT_LED_ENABLED) {
UserLedSet(1);
} else {
UserLedSet(0);
}
mico_system_context_update(sys_config);
send_http("OK", 2, exit, &err);
exit:
if (buf) free(buf);
return err;
}
static int Otastatus(httpd_request_t *req) {
OSStatus err = kNoErr;
char buf[16] = {0};
sprintf(buf, "%.2f", ota_progress);
send_http(buf, strlen(buf), exit, &err);
exit:
exit:
return err;
}
static int OtaStart(httpd_request_t *req)
{
static int OtaStart(httpd_request_t *req) {
OSStatus err = kNoErr;
char buf[64] = { 0 };
char buf[64] = {0};
err = httpd_get_data(req, buf, 64);
require_noerr(err, exit);
@@ -453,45 +455,43 @@ static int OtaStart(httpd_request_t *req)
UserOtaStart(buf, NULL);
send_http("OK", 2, exit, &err);
exit:
exit:
return err;
}
const struct httpd_wsgi_call g_app_handlers[] = {
{ "/", HTTPD_HDR_DEFORT, 0, HttpGetIndexPage, NULL, NULL, NULL },
{ "/demo", HTTPD_HDR_DEFORT, 0, HttpGetDemoPage, NULL, NULL, NULL },
{ "/assets", HTTPD_HDR_ADD_SERVER|HTTPD_HDR_ADD_CONN_CLOSE, APP_HTTP_FLAGS_NO_EXACT_MATCH, HttpGetAssets, NULL, NULL, NULL },
{ "/socket", HTTPD_HDR_DEFORT, 0, NULL, HttpSetSocketStatus, NULL, NULL },
{ "/status", HTTPD_HDR_DEFORT, 0, HttpGetTc1Status, NULL, NULL, NULL },
{ "/power", HTTPD_HDR_DEFORT, 0, HttpGetPowerInfo, HttpGetPowerInfo, NULL, NULL },
{ "/wifi/config", HTTPD_HDR_DEFORT, 0, HttpGetWifiConfig, HttpSetWifiConfig, NULL, NULL },
{ "/wifi/scan", HTTPD_HDR_DEFORT, 0, HttpGetWifiScan, HttpSetWifiScan, NULL, NULL },
{ "/mqtt/config", HTTPD_HDR_DEFORT, 0, NULL, HttpSetMqttConfig, NULL, NULL },
{ "/reboot", HTTPD_HDR_DEFORT, 0, NULL, HttpSetRebootSystem, NULL, NULL },
{ "/mqtt/report/freq", HTTPD_HDR_DEFORT, 0, HttpGetMqttReportFreq, HttpSetMqttReportFreq, NULL, NULL },
{ "/log", HTTPD_HDR_DEFORT, 0, HttpGetLog, NULL, NULL, NULL },
{ "/task", HTTPD_HDR_DEFORT, APP_HTTP_FLAGS_NO_EXACT_MATCH, HttpGetTasks, HttpAddTask, NULL, HttpDelTask },
{ "/ota", HTTPD_HDR_DEFORT, 0, Otastatus, OtaStart, NULL, NULL },
{"/", HTTPD_HDR_DEFORT, 0, HttpGetIndexPage, NULL, NULL, NULL},
{"/demo", HTTPD_HDR_DEFORT, 0, HttpGetDemoPage, NULL, NULL, NULL},
{"/assets", HTTPD_HDR_ADD_SERVER |
HTTPD_HDR_ADD_CONN_CLOSE, APP_HTTP_FLAGS_NO_EXACT_MATCH, HttpGetAssets, NULL, NULL, NULL},
{"/socket", HTTPD_HDR_DEFORT, 0, NULL, HttpSetSocketStatus, NULL, NULL},
{"/status", HTTPD_HDR_DEFORT, 0, HttpGetTc1Status, NULL, NULL, NULL},
{"/power", HTTPD_HDR_DEFORT, 0, HttpGetPowerInfo, HttpGetPowerInfo, NULL, NULL},
{"/wifi/config", HTTPD_HDR_DEFORT, 0, HttpGetWifiConfig, HttpSetWifiConfig, NULL, NULL},
{"/wifi/scan", HTTPD_HDR_DEFORT, 0, HttpGetWifiScan, HttpSetWifiScan, NULL, NULL},
{"/mqtt/config", HTTPD_HDR_DEFORT, 0, NULL, HttpSetMqttConfig, NULL, NULL},
{"/reboot", HTTPD_HDR_DEFORT, 0, NULL, HttpSetRebootSystem, NULL, NULL},
{"/mqtt/report/freq", HTTPD_HDR_DEFORT, 0, HttpGetMqttReportFreq, HttpSetMqttReportFreq, NULL, NULL},
{"/log", HTTPD_HDR_DEFORT, 0, HttpGetLog, NULL, NULL, NULL},
{"/task", HTTPD_HDR_DEFORT, APP_HTTP_FLAGS_NO_EXACT_MATCH, HttpGetTasks, HttpAddTask, NULL, HttpDelTask},
{"/ota", HTTPD_HDR_DEFORT, 0, Otastatus, OtaStart, NULL, NULL},
{"/led", HTTPD_HDR_DEFORT, 0, LedStatus, LedSetEnabled, NULL, NULL},
};
static int g_app_handlers_no = sizeof(g_app_handlers)/sizeof(struct httpd_wsgi_call);
static int g_app_handlers_no = sizeof(g_app_handlers) / sizeof(struct httpd_wsgi_call);
static void AppHttpRegisterHandlers()
{
static void AppHttpRegisterHandlers() {
int rc;
rc = httpd_register_wsgi_handlers((struct httpd_wsgi_call *)g_app_handlers, g_app_handlers_no);
if (rc) {
http_log("failed to register test web handler");
rc = httpd_register_wsgi_handlers((struct httpd_wsgi_call *) g_app_handlers, g_app_handlers_no);
if (rc) { http_log("failed to register test web handler");
}
}
static int _AppHttpdStart()
{
OSStatus err = kNoErr;
http_log("initializing web-services");
static int _AppHttpdStart() {
OSStatus err = kNoErr;http_log("initializing web-services");
/*Initialize HTTPD*/
if(is_http_init == false) {
if (is_http_init == false) {
err = httpd_init();
require_noerr_action(err, exit, http_log("failed to initialize httpd"));
is_http_init = true;
@@ -499,16 +499,14 @@ static int _AppHttpdStart()
/*Start http thread*/
err = httpd_start();
if(err != kNoErr) {
http_log("failed to start httpd thread");
if (err != kNoErr) { http_log("failed to start httpd thread");
httpd_shutdown();
}
exit:
exit:
return err;
}
int AppHttpdStart(void)
{
int AppHttpdStart(void) {
OSStatus err = kNoErr;
err = _AppHttpdStart();
@@ -519,12 +517,11 @@ int AppHttpdStart(void)
is_handlers_registered = true;
}
exit:
exit:
return err;
}
int AppHttpdStop()
{
int AppHttpdStop() {
OSStatus err = kNoErr;
/* HTTPD and services */
@@ -532,6 +529,6 @@ int AppHttpdStop()
err = httpd_stop();
require_noerr_action(err, exit, http_log("failed to halt httpd"));
exit:
exit:
return err;
}

View File

@@ -63,11 +63,13 @@
'mask':'%s',\
'gateway':'%s',\
'reportFreq':'%d',\
'ledEnabled':%d,\
'up_time':%ld\
}"
#define POWER_INFO_JSON "{'sockets':'%s','idx':%d,'len':%d,'p_count':%ld,'powers':[%s],'up_time':'%s'}"
#define POWER_INFO_JSON "{'sockets':'%s','idx':%d,'len':%d,'p_count':%ld,'powers':[%s],'up_time':'%s','led_enabled':%d}"
int AppHttpdStart(void);
int AppHttpdStop();

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,7 @@
#include "stdlib.h"
#include "time.h"
#include "unistd.h"
#include "TimeUtils.h"
#include "user_gpio.h"
#include "user_wifi.h"
@@ -39,6 +40,7 @@ void appRestoreDefault_callback(void *const user_config_data, uint32_t size) {
userConfigDefault->mqtt_report_freq = 2;
userConfigDefault->p_count_2_days_ago = 0;
userConfigDefault->p_count_1_day_ago = 0;
userConfigDefault->power_led_enabled = 1;
userConfigDefault->version = USER_CONFIG_VERSION;
int i;
@@ -48,7 +50,7 @@ void appRestoreDefault_callback(void *const user_config_data, uint32_t size) {
for (i = 0; i < MAX_TASK_NUM; i++) {
userConfigDefault->timed_tasks[i].on_use = false;
}
//mico_system_context_update(sys_config);
mico_system_context_update(sys_config);
}
void recordDailyPCount() {
@@ -63,39 +65,16 @@ void recordDailyPCount() {
user_config->p_count_2_days_ago = user_config->p_count_1_day_ago;
}
user_config->p_count_1_day_ago = p_count;
mico_system_context_update(sys_config);tc1_log("WARNGIN: p_count record!");
mico_system_context_update(sys_config);tc1_log(
"WARNGIN: p_count record! p_count_1_day_ago:%d p_count_2_days_ago:%d",
p_count_1_day_ago, p_count_2_days_ago);
}
void schedule_p_count_task(mico_thread_arg_t arg) {
mico_thread_msleep(20000);tc1_log("WARNGIN: p_count timer thread created!");
mico_thread_sleep(20);tc1_log("WARNGIN: p_count timer thread created!");
while (1) {
// 获取当前时间
time_t now;
struct tm next_run;
time(&now);
struct tm *current_time = localtime(&now);tc1_log("local time %s", asctime(current_time));
// 计算下次执行时间,目标是 0 点 0 分
next_run = *current_time;
next_run.tm_hour = 0;
next_run.tm_min = 0;
next_run.tm_sec = 0;
next_run.tm_mday += 1; // 第二天
tc1_log("next time %s", asctime(&next_run));
// 计算时间间隔(秒数)
time_t next_time = mktime(&next_run);
now = mktime(current_time);
double seconds_until_next_run = difftime(next_time, now);
if (seconds_until_next_run > 0) {
// 休眠直到目标时间
tc1_log("record p_count after %f seconds", seconds_until_next_run);
mico_thread_msleep(seconds_until_next_run * 1000);
} else {
mico_thread_msleep(1000);
continue;
}
// 执行任务
recordDailyPCount();
mico_thread_msleep(1000);
mico_thread_sleep(60);
}
}
@@ -180,6 +159,8 @@ int application_start(void) {
PowerInit();
AppHttpdStart(); // start http server thread
UserLedSet(user_config->power_led_enabled)
err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "p_count",
(mico_thread_function_t) schedule_p_count_task,
0x2000, 0);

View File

@@ -63,6 +63,7 @@ typedef struct
int task_count;
uint32_t p_count_2_days_ago;
uint32_t p_count_1_day_ago;
int power_led_enabled;
pTimedTask task_top;
struct TimedTask timed_tasks[MAX_TASK_NUM];
} user_config_t;

View File

@@ -19,12 +19,20 @@
#define MQTT_SERVER_USR user_config->mqtt_user
#define MQTT_SERVER_PWD user_config->mqtt_password
#define MQTT_REPORT_FREQ user_config->mqtt_report_freq
#define MQTT_LED_ENABLED user_config->power_led_enabled
extern OSStatus UserMqttInit(void);
extern OSStatus UserMqttSend(char *arg);
extern bool UserMqttIsConnect(void);
extern OSStatus UserMqttSendSocketState(char socket_id);
extern void UserMqttHassAuto(char socket_id);
extern void UserMqttHassPower(void);
extern void UserMqttHassAutoPower(void);
#endif

View File

@@ -80,7 +80,7 @@ void UserRelaySet(unsigned char i, unsigned char on)
user_config->socket_status[i] = on;
if (RelayOut())
if (RelayOut()&&user_config->power_led_enabled)
{
UserLedSet(1);
}