[ Devices allowed to join ]
")); // Terminate current multi column table and open new table + } #endif } } +// Web handler to refresh the map, the redirect to show map +void ZigbeeMapRefresh(void) { + if ((!zigbee.init_phase) && (!zigbee.mapping_in_progress)) { + ZigbeeMapAllDevices(); + } + Webserver->sendHeader("Location","/zbm"); // Add a header to respond with a new location for the browser to go to the home page again + Webserver->send(302); +} + +// Display a graphical representation of the Zigbee map using vis.js network +void ZigbeeShowMap(void) { + AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP "Zigbee Mapper")); + + // if no map, then launch a new mapping + if ((!zigbee.init_phase) && (!zigbee.mapping_ready) && (!zigbee.mapping_in_progress)) { + ZigbeeMapAllDevices(); + } + + WSContentStart_P(PSTR("Tasmota Zigbee Mapping")); + WSContentSendStyle(); + + if (zigbee.init_phase) { + WSContentSend_P(PSTR("Zigbee not started")); + } else if (zigbee.mapping_in_progress) { + int32_t mapping_remaining = 1 + (zigbee.mapping_end_time - millis()) / 1000; + if (mapping_remaining < 0) { mapping_remaining = 0; } + WSContentSend_P(PSTR("Mapping in progress (%d s. remaining)"), mapping_remaining); + WSContentSend_P(HTTP_AUTO_REFRESH_PAGE); + } else if (!zigbee.mapping_ready) { + WSContentSend_P(PSTR("No mapping")); + } else { + WSContentSend_P(PSTR( + "" + "" + "" + )); + WSContentSend_P(HTTP_BTN_ZB_MAP_REFRESH); + } + WSContentSpaceButton(BUTTON_MAIN); + WSContentStop(); +} + /*********************************************************************************************\ * Interface \*********************************************************************************************/ @@ -1920,12 +1998,17 @@ bool Xdrv23(uint8_t function) case FUNC_WEB_SENSOR: ZigbeeShow(false); break; -#ifdef USE_ZIGBEE_EZSP // GUI xmodem case FUNC_WEB_ADD_HANDLER: +#ifdef USE_ZIGBEE_EZSP WebServer_on(PSTR("/" WEB_HANDLE_ZIGBEE_XFER), HandleZigbeeXfer); - break; #endif // USE_ZIGBEE_EZSP + WebServer_on(PSTR("/zbm"), ZigbeeShowMap, HTTP_GET); // add web handler for Zigbee map + WebServer_on(PSTR("/zbr"), ZigbeeMapRefresh, HTTP_GET); // add web handler for Zigbee map refresh + break; + case FUNC_WEB_ADD_MAIN_BUTTON: + WSContentSend_P(HTTP_BTN_ZB_BUTTONS); + break; #endif // USE_WEBSERVER case FUNC_PRE_INIT: ZigbeeInit();