mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
Add some zigbee webinfo
This commit is contained in:
parent
5fe75496f9
commit
a05e939be9
@ -1595,9 +1595,7 @@ bool HandleRootStatusRefresh(void)
|
||||
WSContentBegin(200, CT_HTML);
|
||||
WSContentSend_P(PSTR("{t}"));
|
||||
XsnsCall(FUNC_WEB_SENSOR);
|
||||
#ifdef USE_SCRIPT_WEB_DISPLAY
|
||||
XdrvCall(FUNC_WEB_SENSOR);
|
||||
#endif
|
||||
|
||||
WSContentSend_P(PSTR("</table>"));
|
||||
|
||||
|
@ -1223,7 +1223,7 @@ int32_t Z_AqaraCubeFunc(const class ZCLFrame *zcl, uint16_t shortaddr, JsonObjec
|
||||
|
||||
const char * modelId_c = zigbee_devices.getModelId(shortaddr); // null if unknown
|
||||
String modelId((char*) modelId_c);
|
||||
|
||||
|
||||
if (modelId.startsWith(F("lumi.sensor_cube."))) { // only for Aqara cube
|
||||
int32_t val = value;
|
||||
const __FlashStringHelper *aqara_cube = F("AqaraCube");
|
||||
|
@ -757,15 +757,18 @@ int32_t Z_ReceiveAfIncomingMessage(int32_t res, const class SBuffer &buf) {
|
||||
linkquality, securityuse, seqnumber,
|
||||
timestamp);
|
||||
zcl_received.log();
|
||||
|
||||
ZdSetLinkQuality(srcaddr, linkquality);
|
||||
|
||||
char shortaddr[8];
|
||||
snprintf_P(shortaddr, sizeof(shortaddr), PSTR("0x%04X"), srcaddr);
|
||||
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& json = jsonBuffer.createObject();
|
||||
|
||||
|
||||
if ( (!zcl_received.isClusterSpecificCommand()) && (ZCL_DEFAULT_RESPONSE == zcl_received.getCmdId())) {
|
||||
zcl_received.parseResponse(); // Zigbee general "Degault Response", publish ZbResponse message
|
||||
} else {
|
||||
} else {
|
||||
// Build the ZbReceive json
|
||||
if ( (!zcl_received.isClusterSpecificCommand()) && (ZCL_REPORT_ATTRIBUTES == zcl_received.getCmdId())) {
|
||||
zcl_received.parseReportAttributes(json); // Zigbee report attributes from sensors
|
||||
|
@ -1068,6 +1068,77 @@ void CmndZbConfig(void) {
|
||||
hex_precfgkey_l, hex_precfgkey_h);
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Database of linkqualities - there must be a better way to implement this ...
|
||||
\*********************************************************************************************/
|
||||
|
||||
const uint8_t MAX_ZBRECORDS = 16;
|
||||
|
||||
typedef struct Z_DevRecord_t {
|
||||
uint16_t shortaddr;
|
||||
uint8_t linkquality;
|
||||
} Z_DevRecord_t;
|
||||
|
||||
Z_DevRecord_t Z_DevRecord[MAX_ZBRECORDS];
|
||||
uint8_t Z_DevIndex = 0;
|
||||
|
||||
void ZdSetLinkQuality(uint16_t shortaddr, uint8_t linkquality) {
|
||||
if (Z_DevIndex < MAX_ZBRECORDS) {
|
||||
uint32_t i;
|
||||
for (i = 0; i < Z_DevIndex; i++) {
|
||||
if (shortaddr == Z_DevRecord[i].shortaddr) {
|
||||
Z_DevRecord[i].linkquality = linkquality;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Z_DevRecord[i].shortaddr = shortaddr;
|
||||
Z_DevRecord[i].linkquality = linkquality;
|
||||
Z_DevIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ZdGetLinkQuality(uint16_t shortaddr) {
|
||||
for (uint32_t i = 0; i < Z_DevIndex; i++) {
|
||||
if (shortaddr == Z_DevRecord[i].shortaddr) {
|
||||
return Z_DevRecord[i].linkquality;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
|
||||
void ZigbeeShow(bool json)
|
||||
{
|
||||
if (json) {
|
||||
return;
|
||||
#ifdef USE_WEBSERVER
|
||||
} else {
|
||||
char spart1[33];
|
||||
char spart2[8];
|
||||
|
||||
uint32_t zigbee_num = zigbee_devices.devicesSize();
|
||||
for (uint32_t i = 0; i < zigbee_num; i++) {
|
||||
uint16_t shortaddr = zigbee_devices.devicesAt(i).shortaddr;
|
||||
char *name = (char*)zigbee_devices.getFriendlyName(shortaddr);
|
||||
if (nullptr == name) {
|
||||
snprintf_P(spart1, sizeof(spart1), PSTR(D_DEVICE " 0x%04X"), shortaddr);
|
||||
name = spart1;
|
||||
}
|
||||
snprintf_P(spart2, sizeof(spart2), PSTR("-"));
|
||||
uint8_t lq = ZdGetLinkQuality(shortaddr);
|
||||
if (lq) {
|
||||
snprintf_P(spart2, sizeof(spart2), PSTR("%d"), lq);
|
||||
}
|
||||
|
||||
WSContentSend_PD(PSTR("{s}%s{m}LQ %s{e}"), name, spart2);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
\*********************************************************************************************/
|
||||
@ -1089,6 +1160,11 @@ bool Xdrv23(uint8_t function)
|
||||
ZigbeeStateMachine_Run();
|
||||
}
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_WEB_SENSOR:
|
||||
ZigbeeShow(false);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
case FUNC_PRE_INIT:
|
||||
ZigbeeInit();
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user