mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-11 20:48:16 +08:00
去除插座中文名
This commit is contained in:
@@ -62,8 +62,6 @@ mico_timer_t timer_handle;
|
||||
static char timer_status = 0;
|
||||
void UserMqttTimerFunc(void *arg)
|
||||
{
|
||||
char* buf1 = malloc(1024); //idx为1位时长度为24
|
||||
|
||||
LinkStatusTypeDef LinkStatus;
|
||||
micoWlanGetLinkStatus(&LinkStatus);
|
||||
if (LinkStatus.is_connected != 1)
|
||||
@@ -93,7 +91,7 @@ void UserMqttTimerFunc(void *arg)
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
UserMqttHassAutoName(timer_status - 8);
|
||||
UserMqttHassAuto(timer_status - 8);
|
||||
break;
|
||||
case 14:
|
||||
UserMqttHassAutoPowerName();
|
||||
@@ -464,29 +462,6 @@ OSStatus UserMqttSendSocketState(char socket_id)
|
||||
|
||||
//hass mqtt自动发现数据开关发送
|
||||
void UserMqttHassAuto(char socket_id)
|
||||
{
|
||||
char *send_buf = NULL;
|
||||
char *topic_buf = NULL;
|
||||
send_buf = malloc(512); //
|
||||
topic_buf = malloc(128); //
|
||||
if (send_buf != NULL && topic_buf != NULL)
|
||||
{
|
||||
sprintf(topic_buf, "homeassistant/switch/%s/socket_%d/config", str_mac, socket_id);
|
||||
sprintf(send_buf, "{"
|
||||
"\"name\":\"zTC1_socket%d_%s\","
|
||||
"\"stat_t\":\"homeassistant/switch/%s/socket_%d/state\","
|
||||
"\"cmd_t\":\"device/ztc1/set\","
|
||||
"\"pl_on\":\"{\\\"mac\\\":\\\"%s\\\",\\\"socket_%d\\\":{\\\"on\\\":1}}\","
|
||||
"\"pl_off\":\"{\\\"mac\\\":\\\"%s\\\",\\\"socket_%d\\\":{\\\"on\\\":0,\\\"ttt1\\\":1}}\""
|
||||
"}",
|
||||
socket_id, str_mac + 8, str_mac, socket_id, str_mac, socket_id, str_mac, socket_id);
|
||||
UserMqttSendTopic(topic_buf, send_buf, 1);
|
||||
}
|
||||
if (send_buf) free(send_buf);
|
||||
if (topic_buf) free(topic_buf);
|
||||
|
||||
}
|
||||
void UserMqttHassAutoName(char socket_id)
|
||||
{
|
||||
char *send_buf = NULL;
|
||||
char *topic_buf = NULL;
|
||||
@@ -495,13 +470,13 @@ void UserMqttHassAutoName(char socket_id)
|
||||
if (send_buf != NULL && topic_buf != NULL)
|
||||
{
|
||||
sprintf(topic_buf, "homeassistant/switch/%s/socket_%d/config", str_mac, socket_id);
|
||||
sprintf(send_buf, "{"
|
||||
"\"name\":\"%s\","
|
||||
"\"stat_t\":\"homeassistant/switch/%s/socket_%d/state\","
|
||||
"\"cmd_t\":\"device/ztc1/set\","
|
||||
"\"pl_on\":\"set socket %s %d 1\","
|
||||
"\"pl_off\":\"set socket %s %d 0\"}",
|
||||
"SSS", str_mac, socket_id, str_mac, socket_id, str_mac, socket_id);
|
||||
sprintf(send_buf,
|
||||
"{\"name\":\"TC1-Socket-%s-%d\","
|
||||
"\"stat_t\":\"homeassistant/switch/%s/socket_%d/state\","
|
||||
"\"cmd_t\":\"device/ztc1/set\","
|
||||
"\"pl_on\":\"set socket %s %d 1\","
|
||||
"\"pl_off\":\"set socket %s %d 0\"}",
|
||||
str_mac+8, socket_id, str_mac, socket_id, str_mac, socket_id, str_mac, socket_id);
|
||||
UserMqttSendTopic(topic_buf, send_buf, 0);
|
||||
}
|
||||
if (send_buf)
|
||||
|
||||
@@ -22,7 +22,6 @@ extern OSStatus UserMqttSend(char *arg);
|
||||
extern bool UserMqttIsConnect(void);
|
||||
extern OSStatus UserMqttSendSocketState(char socket_id);
|
||||
extern void UserMqttHassAuto(char socket_id);
|
||||
extern void UserMqttHassAutoName(char socket_id);
|
||||
extern void UserMqttHassPower(void);
|
||||
extern void UserMqttHassAutoPower(void);
|
||||
extern void UserMqttHassAutoPowerName(void);
|
||||
|
||||
Reference in New Issue
Block a user