Addressed automation issue by extending true/false parsing
Added true/false parsing to all integer-based Characteristics. Previously true/false was only parsed for BOOL Characteristics. For integer-based on/off Characteristics, the Home App would send a 0 for off, and a 1 for on, consistent with HAP-R2. BUT...when using Home App AUTOMATIONS, the Home App would send true/false for integer-based Characteristics, which is inconsistent with HAP-R2. This meant automations worked with lights (that use the boolean ON Characteristic) but not with fans (that use the uint8 ACTIVE Characteristic). With this "fix", true/false will be recognized all the time (except for float- and string-based Characteristics. Confirmed that fans now work with Home App Automations.
This commit is contained in:
parent
8dd9a40f77
commit
3cc14c3a8d
|
|
@ -1722,27 +1722,47 @@ StatusCode SpanCharacteristic::loadUpdate(char *val, char *ev){
|
|||
break;
|
||||
|
||||
case INT:
|
||||
if(!sscanf(val,"%d",&newValue.INT))
|
||||
if(!strcmp(val,"false"))
|
||||
newValue.INT=0;
|
||||
else if(!strcmp(val,"true"))
|
||||
newValue.INT=1;
|
||||
else if(!sscanf(val,"%d",&newValue.INT))
|
||||
return(StatusCode::InvalidValue);
|
||||
break;
|
||||
|
||||
case UINT8:
|
||||
if(!sscanf(val,"%hhu",&newValue.UINT8))
|
||||
if(!strcmp(val,"false"))
|
||||
newValue.UINT8=0;
|
||||
else if(!strcmp(val,"true"))
|
||||
newValue.UINT8=1;
|
||||
else if(!sscanf(val,"%hhu",&newValue.UINT8))
|
||||
return(StatusCode::InvalidValue);
|
||||
break;
|
||||
|
||||
case UINT16:
|
||||
if(!sscanf(val,"%hu",&newValue.UINT16))
|
||||
if(!strcmp(val,"false"))
|
||||
newValue.UINT16=0;
|
||||
else if(!strcmp(val,"true"))
|
||||
newValue.UINT16=1;
|
||||
else if(!sscanf(val,"%hu",&newValue.UINT16))
|
||||
return(StatusCode::InvalidValue);
|
||||
break;
|
||||
|
||||
case UINT32:
|
||||
if(!sscanf(val,"%u",&newValue.UINT32))
|
||||
if(!strcmp(val,"false"))
|
||||
newValue.UINT32=0;
|
||||
else if(!strcmp(val,"true"))
|
||||
newValue.UINT32=1;
|
||||
else if(!sscanf(val,"%u",&newValue.UINT32))
|
||||
return(StatusCode::InvalidValue);
|
||||
break;
|
||||
|
||||
case UINT64:
|
||||
if(!sscanf(val,"%llu",&newValue.UINT64))
|
||||
if(!strcmp(val,"false"))
|
||||
newValue.UINT64=0;
|
||||
else if(!strcmp(val,"true"))
|
||||
newValue.UINT64=1;
|
||||
else if(!sscanf(val,"%llu",&newValue.UINT64))
|
||||
return(StatusCode::InvalidValue);
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue