Merge pull request #7234 from gemu2015/scripter-update

scripter FUNC_SET_POWER into separate section >P
This commit is contained in:
Theo Arends 2019-12-16 10:14:34 +01:00 committed by GitHub
commit 246e026970
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -1030,8 +1030,10 @@ char *isvar(char *lp, uint8_t *vtype,struct T_INDEX *tind,float *fp,char *sp,Jso
if ((*jo).is<char*>(vn)) {
if (!strncmp(str_value,"ON",2)) {
if (fp) *fp=1;
goto nexit;
} else if (!strncmp(str_value,"OFF",3)) {
if (fp) *fp=0;
goto nexit;
} else {
*vtype=STR_RES;
tind->bits.constant=1;
@ -1039,6 +1041,7 @@ char *isvar(char *lp, uint8_t *vtype,struct T_INDEX *tind,float *fp,char *sp,Jso
if (sp) strlcpy(sp,str_value,SCRIPT_MAXSSIZE);
return lp+len;
}
} else {
if (fp) {
if (!strncmp(vn.c_str(),"Epoch",5)) {
@ -1047,6 +1050,7 @@ char *isvar(char *lp, uint8_t *vtype,struct T_INDEX *tind,float *fp,char *sp,Jso
*fp=CharToFloat((char*)str_value);
}
}
nexit:
*vtype=NUM_RES;
tind->bits.constant=1;
tind->bits.is_string=0;
@ -4843,6 +4847,12 @@ bool Xdrv10(uint8_t function)
result = ScriptCommand();
break;
case FUNC_SET_POWER:
#ifdef SCRIPT_POWER_SECTION
if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">P",2,0);
#else
if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">E",2,0);
#endif
break;
case FUNC_RULES_PROCESS:
if (bitRead(Settings.rule_enabled, 0)) Run_Scripter(">E",2,mqtt_data);
break;