mirror of https://github.com/arendst/Tasmota.git
scripter update
This commit is contained in:
parent
9add6f8d7d
commit
739f67f1e8
|
@ -466,6 +466,10 @@ void CmndStatus(void)
|
||||||
ResponseJsonEnd();
|
ResponseJsonEnd();
|
||||||
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "11"));
|
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "11"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_SCRIPT_STATUS
|
||||||
|
if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">U",2,mqtt_data);
|
||||||
|
#endif
|
||||||
mqtt_data[0] = '\0';
|
mqtt_data[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -593,7 +593,9 @@ void ws2812_set_array(float *array ,uint8_t len) {
|
||||||
#define NTYPE 0
|
#define NTYPE 0
|
||||||
#define STYPE 0x80
|
#define STYPE 0x80
|
||||||
|
|
||||||
|
#ifndef FLT_MAX
|
||||||
#define FLT_MAX 99999999
|
#define FLT_MAX 99999999
|
||||||
|
#endif
|
||||||
|
|
||||||
float median_array(float *array,uint8_t len) {
|
float median_array(float *array,uint8_t len) {
|
||||||
uint8_t ind[len];
|
uint8_t ind[len];
|
||||||
|
@ -2571,7 +2573,7 @@ int16_t Run_Scripter(const char *type, int8_t tlen, char *js) {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
else if (!strncmp(lp,"=>",2) || !strncmp(lp,"->",2) || !strncmp(lp,"print",5)) {
|
else if (!strncmp(lp,"=>",2) || !strncmp(lp,"->",2) || !strncmp(lp,"+>",2) || !strncmp(lp,"print",5)) {
|
||||||
// execute cmd
|
// execute cmd
|
||||||
uint8_t sflag=0,pflg=0,svmqtt,swll;
|
uint8_t sflag=0,pflg=0,svmqtt,swll;
|
||||||
if (*lp=='p') {
|
if (*lp=='p') {
|
||||||
|
@ -2580,6 +2582,7 @@ int16_t Run_Scripter(const char *type, int8_t tlen, char *js) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (*lp=='-') sflag=1;
|
if (*lp=='-') sflag=1;
|
||||||
|
if (*lp=='+') sflag=2;
|
||||||
lp+=2;
|
lp+=2;
|
||||||
}
|
}
|
||||||
char *slp=lp;
|
char *slp=lp;
|
||||||
|
@ -2609,18 +2612,21 @@ int16_t Run_Scripter(const char *type, int8_t tlen, char *js) {
|
||||||
else toLog(&tmp[5]);
|
else toLog(&tmp[5]);
|
||||||
} else {
|
} else {
|
||||||
if (!sflag) {
|
if (!sflag) {
|
||||||
|
tasm_cmd_activ=1;
|
||||||
snprintf_P(log_data, sizeof(log_data), PSTR("Script: performs \"%s\""), tmp);
|
snprintf_P(log_data, sizeof(log_data), PSTR("Script: performs \"%s\""), tmp);
|
||||||
AddLog(glob_script_mem.script_loglevel&0x7f);
|
AddLog(glob_script_mem.script_loglevel&0x7f);
|
||||||
|
} else if (sflag==2) {
|
||||||
|
// allow recursive call
|
||||||
} else {
|
} else {
|
||||||
|
tasm_cmd_activ=1;
|
||||||
svmqtt=Settings.flag.mqtt_enabled;
|
svmqtt=Settings.flag.mqtt_enabled;
|
||||||
swll=Settings.weblog_level;
|
swll=Settings.weblog_level;
|
||||||
Settings.flag.mqtt_enabled=0;
|
Settings.flag.mqtt_enabled=0;
|
||||||
Settings.weblog_level=0;
|
Settings.weblog_level=0;
|
||||||
}
|
}
|
||||||
tasm_cmd_activ=1;
|
|
||||||
ExecuteCommand((char*)tmp, SRC_RULE);
|
ExecuteCommand((char*)tmp, SRC_RULE);
|
||||||
tasm_cmd_activ=0;
|
tasm_cmd_activ=0;
|
||||||
if (sflag) {
|
if (sflag==1) {
|
||||||
Settings.flag.mqtt_enabled=svmqtt;
|
Settings.flag.mqtt_enabled=svmqtt;
|
||||||
Settings.weblog_level=swll;
|
Settings.weblog_level=swll;
|
||||||
}
|
}
|
||||||
|
@ -3388,7 +3394,7 @@ const char SCRIPT_HUE_LIGHTS_STATUS_JSON1[] PROGMEM =
|
||||||
"\"reachable\":true}"
|
"\"reachable\":true}"
|
||||||
",\"type\":\"{type}\","
|
",\"type\":\"{type}\","
|
||||||
"\"name\":\"{j1\","
|
"\"name\":\"{j1\","
|
||||||
"\"modelid\":\"LCT007\","
|
"\"modelid\":\"{m1}\","
|
||||||
"\"uniqueid\":\"{j2\","
|
"\"uniqueid\":\"{j2\","
|
||||||
"\"swversion\":\"5.50.1.19085\"}";
|
"\"swversion\":\"5.50.1.19085\"}";
|
||||||
|
|
||||||
|
@ -3444,16 +3450,61 @@ const char SCRIPT_HUE_LIGHTS_STATUS_JSON2[] PROGMEM =
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
Color Ligh
|
||||||
|
Dimmable Light
|
||||||
|
Color Temperature Light
|
||||||
|
Extended Color Light
|
||||||
|
On/Off light
|
||||||
|
|
||||||
|
ZGPSwitch
|
||||||
|
ZLLSwitch
|
||||||
|
CLIPSwitch
|
||||||
|
CLIPOpenClose
|
||||||
|
CLIPPresence
|
||||||
|
CLIPTemperature
|
||||||
|
CLIPHumidity
|
||||||
|
Daylight
|
||||||
|
CLIPLightlevel
|
||||||
|
|
||||||
|
|
||||||
temperature ZLLTemperature
|
temperature ZLLTemperature
|
||||||
lightlevel ZLLLightLevel
|
lightlevel ZLLLightLevel
|
||||||
presence ZLLPresence
|
presence ZLLPresence
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
case 'T':
|
||||||
|
response->replace("{type}","ZLLTemperature");
|
||||||
|
temp=glob_script_mem.fvars[hue_script[hue_devs].index[2]-1];
|
||||||
|
light_status += "\"temperature\":";
|
||||||
|
light_status += String(temp*100);
|
||||||
|
light_status += ",";
|
||||||
|
break;
|
||||||
|
case 'L':
|
||||||
|
response->replace("{type}","ZLLLightLevel");
|
||||||
|
temp=glob_script_mem.fvars[hue_script[hue_devs].index[2]-1];
|
||||||
|
light_status += "\"lightlevel\":";
|
||||||
|
light_status += String(temp);
|
||||||
|
light_status += ",";
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
response->replace("{type}","ZLLPresence");
|
||||||
|
temp=glob_script_mem.fvars[hue_script[hue_devs].index[0]-1];
|
||||||
|
light_status += "\"presence\":";
|
||||||
|
if (temp==0)light_status += "false";
|
||||||
|
else light_status += "true";
|
||||||
|
light_status += ",";
|
||||||
|
break;
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
void Script_HueStatus(String *response, uint16_t hue_devs) {
|
void Script_HueStatus(String *response, uint16_t hue_devs) {
|
||||||
|
|
||||||
if (hue_script[hue_devs].type=='P') {
|
if (hue_script[hue_devs].type=='p') {
|
||||||
*response+=FPSTR(SCRIPT_HUE_LIGHTS_STATUS_JSON2);
|
*response+=FPSTR(SCRIPT_HUE_LIGHTS_STATUS_JSON2);
|
||||||
response->replace("{j1",hue_script[hue_devs].name);
|
response->replace("{j1",hue_script[hue_devs].name);
|
||||||
response->replace("{j2", GetHueDeviceId(hue_devs));
|
response->replace("{j2", GetHueDeviceId(hue_devs));
|
||||||
|
@ -3502,36 +3553,29 @@ void Script_HueStatus(String *response, uint16_t hue_devs) {
|
||||||
|
|
||||||
float temp;
|
float temp;
|
||||||
switch (hue_script[hue_devs].type) {
|
switch (hue_script[hue_devs].type) {
|
||||||
case 'E':
|
case 'C':
|
||||||
response->replace("{type}","Extended color light");
|
response->replace("{type}","Color Ligh"); // alexa ok
|
||||||
|
response->replace("{m1","LST001");
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'D':
|
||||||
response->replace("{type}","color light");
|
response->replace("{type}","Dimmable Light"); // alexa NO
|
||||||
|
response->replace("{m1","LWB004");
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
response->replace("{type}","ZLLTemperature");
|
response->replace("{type}","Color Temperature Light"); // alexa NO
|
||||||
temp=glob_script_mem.fvars[hue_script[hue_devs].index[2]-1];
|
response->replace("{m1","LTW011");
|
||||||
light_status += "\"temperature\":";
|
|
||||||
light_status += String(temp*100);
|
|
||||||
light_status += ",";
|
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'E':
|
||||||
response->replace("{type}","ZLLLightLevel");
|
response->replace("{type}","Extended color light"); // alexa ok
|
||||||
temp=glob_script_mem.fvars[hue_script[hue_devs].index[2]-1];
|
response->replace("{m1","LCT007");
|
||||||
light_status += "\"lightlevel\":";
|
|
||||||
light_status += String(temp);
|
|
||||||
light_status += ",";
|
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'S':
|
||||||
response->replace("{type}","ZLLPresence");
|
response->replace("{type}","On/Off light"); // alexa ok
|
||||||
temp=glob_script_mem.fvars[hue_script[hue_devs].index[0]-1];
|
response->replace("{m1","LCT007");
|
||||||
light_status += "\"presence\":";
|
|
||||||
if (temp==0)light_status += "false";
|
|
||||||
else light_status += "true";
|
|
||||||
light_status += ",";
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
response->replace("{type}","color light");
|
response->replace("{type}","color light");
|
||||||
|
response->replace("{m1","LST001");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3664,7 +3708,7 @@ void Script_Check_Hue(String *response) {
|
||||||
lp++;
|
lp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 1
|
#if 0
|
||||||
if (response) {
|
if (response) {
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("Hue: %d"), hue_devs);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("Hue: %d"), hue_devs);
|
||||||
toLog(">>>>");
|
toLog(">>>>");
|
||||||
|
|
Loading…
Reference in New Issue