Fixed Zigbee Aqara attributes on ESP32 (#20452)

This commit is contained in:
s-hadinger 2024-01-09 22:30:38 +01:00 committed by GitHub
parent 345de0aded
commit 453a3462b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 36 deletions

View File

@ -26,6 +26,7 @@ All notable changes to this project will be documented in this file.
- Header `Host` is now collected by Webserver - Header `Host` is now collected by Webserver
### Fixed ### Fixed
- Fixed Zigbee Aqara attributes on ESP32
### Removed ### Removed

View File

@ -1304,42 +1304,36 @@ void ZCLFrame::syntheticAqaraCubeOrButton(class Z_attribute_list &attr_list, cla
if (modelId.startsWith(F("lumi.sensor_cube"))) { // only for Aqara cube if (modelId.startsWith(F("lumi.sensor_cube"))) { // only for Aqara cube
int32_t val = attr.getInt(); int32_t val = attr.getInt();
#ifdef ESP8266 static const char *aqara_cube = PSTR("AqaraCube");
const __FlashStringHelper *aqara_cube = F("AqaraCube"); static const char *aqara_cube_side = PSTR("AqaraCubeSide");
const __FlashStringHelper *aqara_cube_side = F("AqaraCubeSide"); static const char *aqara_cube_from_side = PSTR("AqaraCubeFromSide");
const __FlashStringHelper *aqara_cube_from_side = F("AqaraCubeFromSide");
#else
const char *aqara_cube = "AqaraCube";
const char *aqara_cube_side = "AqaraCubeSide";
const char *aqara_cube_from_side = "AqaraCubeFromSide";
#endif
switch (val) { switch (val) {
case 0: case 0:
attr_list.addAttribute(aqara_cube).setStr(PSTR("shake")); attr_list.addAttributePMEM(aqara_cube).setStr(PSTR("shake"));
break; break;
case 2: case 2:
attr_list.addAttribute(aqara_cube).setStr(PSTR("wakeup")); attr_list.addAttributePMEM(aqara_cube).setStr(PSTR("wakeup"));
break; break;
case 3: case 3:
attr_list.addAttribute(aqara_cube).setStr(PSTR("fall")); attr_list.addAttributePMEM(aqara_cube).setStr(PSTR("fall"));
break; break;
case 64 ... 127: case 64 ... 127:
attr_list.addAttribute(aqara_cube).setStr(PSTR("flip90")); attr_list.addAttributePMEM(aqara_cube).setStr(PSTR("flip90"));
attr_list.addAttribute(aqara_cube_side).setInt(val % 8); attr_list.addAttributePMEM(aqara_cube_side).setInt(val % 8);
attr_list.addAttribute(aqara_cube_from_side).setInt((val - 64) / 8); attr_list.addAttributePMEM(aqara_cube_from_side).setInt((val - 64) / 8);
break; break;
case 128 ... 132: case 128 ... 132:
attr_list.addAttribute(aqara_cube).setStr(PSTR("flip180")); attr_list.addAttributePMEM(aqara_cube).setStr(PSTR("flip180"));
attr_list.addAttribute(aqara_cube_side).setInt(val - 128); attr_list.addAttributePMEM(aqara_cube_side).setInt(val - 128);
break; break;
case 256 ... 261: case 256 ... 261:
attr_list.addAttribute(aqara_cube).setStr(PSTR("slide")); attr_list.addAttributePMEM(aqara_cube).setStr(PSTR("slide"));
attr_list.addAttribute(aqara_cube_side).setInt(val - 256); attr_list.addAttributePMEM(aqara_cube_side).setInt(val - 256);
break; break;
case 512 ... 517: case 512 ... 517:
attr_list.addAttribute(aqara_cube).setStr(PSTR("tap")); attr_list.addAttributePMEM(aqara_cube).setStr(PSTR("tap"));
attr_list.addAttribute(aqara_cube_side).setInt(val - 512); attr_list.addAttributePMEM(aqara_cube_side).setInt(val - 512);
break; break;
} }
attr_list.removeAttribute(&attr); attr_list.removeAttribute(&attr);
@ -1363,26 +1357,21 @@ void ZCLFrame::syntheticAqaraCubeOrButton(class Z_attribute_list &attr_list, cla
// presentValue = x + 512 = double tap while side x is on top // presentValue = x + 512 = double tap while side x is on top
} else if (modelId.startsWith(F("lumi.remote")) || modelId.startsWith(F("lumi.sensor_swit"))) { // only for Aqara buttons WXKG11LM & WXKG12LM, 'swit' because of #9923 } else if (modelId.startsWith(F("lumi.remote")) || modelId.startsWith(F("lumi.sensor_swit"))) { // only for Aqara buttons WXKG11LM & WXKG12LM, 'swit' because of #9923
int32_t val = attr.getInt(); int32_t val = attr.getInt();
#ifdef ESP8266 static const char *aqara_click = PSTR("click"); // deprecated
const __FlashStringHelper *aqara_click = F("click"); // deprecated static const char *aqara_action = PSTR("action"); // deprecated
const __FlashStringHelper *aqara_action = F("action"); // deprecated
#else
const char *aqara_click = "click"; // deprecated
const char *aqara_action = "action"; // deprecated
#endif
Z_attribute & attr_click = attr_list.addAttribute(PSTR("Click"), true); Z_attribute & attr_click = attr_list.addAttribute(PSTR("Click"), true);
switch (val) { switch (val) {
case 0: case 0:
attr_list.addAttribute(aqara_action).setStr(PSTR("hold")); // deprecated attr_list.addAttributePMEM(aqara_action).setStr(PSTR("hold")); // deprecated
attr_click.setStr(PSTR("hold")); attr_click.setStr(PSTR("hold"));
break; break;
case 1: case 1:
attr_list.addAttribute(aqara_click).setStr(PSTR("single")); // deprecated attr_list.addAttributePMEM(aqara_click).setStr(PSTR("single")); // deprecated
attr_click.setStr(PSTR("single")); attr_click.setStr(PSTR("single"));
break; break;
case 2: case 2:
attr_list.addAttribute(aqara_click).setStr(PSTR("double")); // deprecated attr_list.addAttributePMEM(aqara_click).setStr(PSTR("double")); // deprecated
attr_click.setStr(PSTR("double")); attr_click.setStr(PSTR("double"));
break; break;
case 3: case 3:
@ -1392,23 +1381,23 @@ void ZCLFrame::syntheticAqaraCubeOrButton(class Z_attribute_list &attr_list, cla
attr_click.setStr(PSTR("quadruple")); attr_click.setStr(PSTR("quadruple"));
break; break;
case 16: case 16:
attr_list.addAttribute(aqara_action).setStr(PSTR("hold")); // deprecated attr_list.addAttributePMEM(aqara_action).setStr(PSTR("hold")); // deprecated
attr_click.setStr(PSTR("hold")); attr_click.setStr(PSTR("hold"));
break; break;
case 17: case 17:
attr_list.addAttribute(aqara_action).setStr(PSTR("release")); // deprecated attr_list.addAttributePMEM(aqara_action).setStr(PSTR("release")); // deprecated
attr_click.setStr(PSTR("release")); attr_click.setStr(PSTR("release"));
break; break;
case 18: case 18:
attr_list.addAttribute(aqara_action).setStr(PSTR("shake")); // deprecated attr_list.addAttributePMEM(aqara_action).setStr(PSTR("shake")); // deprecated
attr_click.setStr(PSTR("shake")); attr_click.setStr(PSTR("shake"));
break; break;
case 255: case 255:
attr_list.addAttribute(aqara_action).setStr(PSTR("release")); // deprecated attr_list.addAttributePMEM(aqara_action).setStr(PSTR("release")); // deprecated
attr_click.setStr(PSTR("release")); attr_click.setStr(PSTR("release"));
break; break;
default: default:
attr_list.addAttribute(aqara_click).setUInt(val); attr_list.addAttributePMEM(aqara_click).setUInt(val);
attr_click.setStr(PSTR("release")); attr_click.setStr(PSTR("release"));
break; break;
} }