From 0007e7c67280c4f3816a0e60aa545c32b53c0896 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Fri, 30 Apr 2021 12:34:00 +0200 Subject: [PATCH] Zigbee avoir erasing ZbData if zigbee is not started --- tasmota/xdrv_23_zigbee_4b_data.ino | 4 +--- tasmota/xdrv_23_zigbee_A_impl.ino | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tasmota/xdrv_23_zigbee_4b_data.ino b/tasmota/xdrv_23_zigbee_4b_data.ino index 080afe8a2..1c4b9b525 100644 --- a/tasmota/xdrv_23_zigbee_4b_data.ino +++ b/tasmota/xdrv_23_zigbee_4b_data.ino @@ -220,6 +220,7 @@ bool hydrateDevicesData(void) { \*********************************************************************************************/ void hibernateAllData(void) { if (Rtc.utc_time < START_VALID_TIME) { return; } + if (zigbee_devices.devicesSize() == 0) { return; } // safe-guard, if data is empty, don't save anything Univ_Write_File f; const char * storage_class = PSTR(""); @@ -242,9 +243,6 @@ void hibernateAllData(void) { #endif if (f.valid()) { - // first prefix is number of devices - uint8_t device_num = zigbee_devices.devicesSize(); - for (const auto & device : zigbee_devices.getDevices()) { // allocte a buffer for a single device SBuffer buf = hibernateDeviceData(device); diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index d1eb6d8bc..973a5a902 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -2177,8 +2177,10 @@ bool Xdrv23(uint8_t function) result = DecodeCommand(kZbCommands, ZigbeeCommand, kZbSynonyms); break; case FUNC_SAVE_BEFORE_RESTART: - hibernateAllData(); - restoreDumpAllDevices(); + if (!zigbee.init_phase) { + hibernateAllData(); + restoreDumpAllDevices(); + } break; } }